File tree Expand file tree Collapse file tree 2 files changed +22
-2
lines changed Expand file tree Collapse file tree 2 files changed +22
-2
lines changed Original file line number Diff line number Diff line change @@ -29,7 +29,9 @@ function loadTask(fileName, taskName) {
2929
3030gulp . task ( 'format:enforce' , loadTask ( 'format' , 'enforce' ) ) ;
3131gulp . task ( 'format' , loadTask ( 'format' , 'format' ) ) ;
32- gulp . task ( 'format:changed' , loadTask ( 'format' , 'format-changed' ) ) ;
32+ gulp . task ( 'format:changes' , loadTask ( 'format' , 'format-changes' ) ) ;
33+ gulp . task ( 'format:diff' , loadTask ( 'format' , 'format-diff' ) ) ;
34+ gulp . task ( 'format:changed' , [ 'format:changes' , 'format:diff' ] ) ;
3335gulp . task ( 'build.sh' , loadTask ( 'build' , 'all' ) ) ;
3436gulp . task ( 'build.sh:no-bundle' , loadTask ( 'build' , 'no-bundle' ) ) ;
3537gulp . task ( 'lint' , [ 'format:enforce' , 'validate-commit-messages' , 'tslint' ] ) ;
Original file line number Diff line number Diff line change @@ -103,7 +103,7 @@ module.exports = {
103103 } ,
104104
105105 // Format only the changed source code files with clang-format (see .clang-format)
106- 'format-changed ' : ( gulp ) => ( ) => {
106+ 'format-changes ' : ( gulp ) => ( ) => {
107107 const format = require ( 'gulp-clang-format' ) ;
108108 const clangFormat = require ( 'clang-format' ) ;
109109 const gulpFilter = require ( 'gulp-filter' ) ;
@@ -112,5 +112,23 @@ module.exports = {
112112 . pipe ( gulpFilter ( srcsToFmt ) )
113113 . pipe ( format . format ( 'file' , clangFormat ) )
114114 . pipe ( gulp . dest ( '.' ) ) ;
115+ } ,
116+
117+ // Format only the changed source code files diffed from the provided branch with clang-format
118+ // (see .clang-format)
119+ 'format-diff' : ( gulp ) => ( ) => {
120+ const format = require ( 'gulp-clang-format' ) ;
121+ const clangFormat = require ( 'clang-format' ) ;
122+ const gulpFilter = require ( 'gulp-filter' ) ;
123+ const minimist = require ( 'minimist' ) ;
124+ const gulpGit = require ( 'gulp-git' ) ;
125+
126+ const args = minimist ( process . argv . slice ( 2 ) ) ;
127+ const branch = args . branch || 'master' ;
128+
129+ return gulpGit . diff ( branch , { log : false } )
130+ . pipe ( gulpFilter ( srcsToFmt ) )
131+ . pipe ( format . format ( 'file' , clangFormat ) )
132+ . pipe ( gulp . dest ( '.' ) ) ;
115133 }
116134} ;
You can’t perform that action at this time.
0 commit comments