style: add combined task to format from git diff and status commands (#24969)

PR Close #24969
This commit is contained in:
Brandon Roberts
2018-09-07 11:54:47 -05:00
committed by Alex Rickabaugh
parent ac3252a73b
commit 4c819f79b2
2 changed files with 22 additions and 2 deletions

View File

@ -103,7 +103,7 @@ module.exports = {
},
// Format only the changed source code files with clang-format (see .clang-format)
'format-changed': (gulp) => () => {
'format-changes': (gulp) => () => {
const format = require('gulp-clang-format');
const clangFormat = require('clang-format');
const gulpFilter = require('gulp-filter');
@ -112,5 +112,23 @@ module.exports = {
.pipe(gulpFilter(srcsToFmt))
.pipe(format.format('file', clangFormat))
.pipe(gulp.dest('.'));
},
// Format only the changed source code files diffed from the provided branch with clang-format
// (see .clang-format)
'format-diff': (gulp) => () => {
const format = require('gulp-clang-format');
const clangFormat = require('clang-format');
const gulpFilter = require('gulp-filter');
const minimist = require('minimist');
const gulpGit = require('gulp-git');
const args = minimist(process.argv.slice(2));
const branch = args.branch || 'master';
return gulpGit.diff(branch, {log: false})
.pipe(gulpFilter(srcsToFmt))
.pipe(format.format('file', clangFormat))
.pipe(gulp.dest('.'));
}
};