From 6788d86709677ae2102ed081e266e5b8fa15c94e Mon Sep 17 00:00:00 2001 From: George Kalpakas Date: Sun, 17 Feb 2019 11:00:50 +0200 Subject: [PATCH] build: fix `validate-commit-message` on Windows (#28780) Previously, the `validate-commit-message` gulp task was using the `git log ... ^r1 r2` syntax to list commits between the base branch and the current head. This didn't work as expected on Windows, because `^` is the escape character. As a result, the command was equivalent to `git log ... r1 r2` on Windows, which essentially logs all commits reachable from either `r1` or `r2`. This commit fixes it by switching to git's [double-dot range notation][1] (`r1..r2`), which is an alias for the `^r1 r2` syntax and works correctly on all platforms. [1]: https://git-scm.com/docs/gitrevisions#_dotted_range_notations Fixes #16830 PR Close #28780 --- tools/gulp-tasks/validate-commit-message.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/gulp-tasks/validate-commit-message.js b/tools/gulp-tasks/validate-commit-message.js index 6b04a2e2da..a688a9587a 100644 --- a/tools/gulp-tasks/validate-commit-message.js +++ b/tools/gulp-tasks/validate-commit-message.js @@ -31,7 +31,7 @@ module.exports = (gulp) => () => { // We need to fetch origin explicitly because it might be stale. // I couldn't find a reliable way to do this without fetch. const result = shelljs.exec( - `git fetch origin ${baseBranch} && git log --reverse --format=%s HEAD ^origin/${baseBranch}`); + `git fetch origin ${baseBranch} && git log --reverse --format=%s origin/${baseBranch}..HEAD`); if (result.code) { throw new Error(`Failed to fetch commits: ${result.stderr}`); @@ -39,10 +39,10 @@ module.exports = (gulp) => () => { const commitsByLine = result.trim().split(/\n/).filter(line => line != ''); - console.log(`Examining ${commitsByLine.length} commits between HEAD and ${baseBranch}`); + console.log(`Examining ${commitsByLine.length} commit(s) between ${baseBranch} and HEAD`); if (commitsByLine.length == 0) { - console.log(`There are zero new commits between this HEAD and ${baseBranch}`); + console.log(`There are zero new commits between ${baseBranch} and HEAD`); } const someCommitsInvalid = !commitsByLine.every(validateCommitMessage);