style: add combined task to format from git diff and status commands (#24969)
PR Close #24969
This commit is contained in:
parent
ac3252a73b
commit
4c819f79b2
|
@ -29,7 +29,9 @@ function loadTask(fileName, taskName) {
|
|||
|
||||
gulp.task('format:enforce', loadTask('format', 'enforce'));
|
||||
gulp.task('format', loadTask('format', 'format'));
|
||||
gulp.task('format:changed', loadTask('format', 'format-changed'));
|
||||
gulp.task('format:changes', loadTask('format', 'format-changes'));
|
||||
gulp.task('format:diff', loadTask('format', 'format-diff'));
|
||||
gulp.task('format:changed', ['format:changes', 'format:diff']);
|
||||
gulp.task('build.sh', loadTask('build', 'all'));
|
||||
gulp.task('build.sh:no-bundle', loadTask('build', 'no-bundle'));
|
||||
gulp.task('lint', ['format:enforce', 'validate-commit-messages', 'tslint']);
|
||||
|
|
|
@ -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('.'));
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue