From 4baa075bd93f878ee708817f911fe89c102dec02 Mon Sep 17 00:00:00 2001 From: Philippe Miossec Date: Sun, 31 Jan 2016 00:51:33 +0100 Subject: [PATCH 1/2] fix: correctly get branch name from the command line --- tasks/command.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tasks/command.js b/tasks/command.js index ef2130c..d70e541 100755 --- a/tasks/command.js +++ b/tasks/command.js @@ -35,8 +35,8 @@ if (process.argv.join('').replace(/\\/g,'/').indexOf('/grunt') === -1) { options.app_name = program.app_name; } - if (program.branch_name){ - options.branch_name = program.branch_name; + if (program.branch){ + options.branch_name = program.branch; console.log(' - Branch %s', program.branch); } if (program.debug){ From 4ce6128103ece64b44695ac196b457e63649229b Mon Sep 17 00:00:00 2001 From: Philippe Miossec Date: Sun, 31 Jan 2016 00:58:18 +0100 Subject: [PATCH 2/2] feat: improve `git log` synthax command to use the branch name and permit to run the command for every commitish (branch, tag, sha1) --- tasks/lib/get-gitlog-commands.js | 2 +- test/git_changelog_generate.spec.js | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/tasks/lib/get-gitlog-commands.js b/tasks/lib/get-gitlog-commands.js index 7743f03..12b69ae 100644 --- a/tasks/lib/get-gitlog-commands.js +++ b/tasks/lib/get-gitlog-commands.js @@ -4,7 +4,7 @@ var debug = require('debug')('changelog:getGitLogCommands'); function getGitLogCommands() { debug('getting log commands'); - this.cmd.gitLog = 'git log ' + this.options.branch_name + ' --grep="%s" -E --format=%s %s..HEAD'; + this.cmd.gitLog = 'git log --grep="%s" -E --format=%s %s..' + (this.options.branch_name ? this.options.branch_name : 'HEAD'); this.cmd.gitLogNoTag = 'git log ' + this.options.branch_name + ' --grep="%s" -E --format=%s'; } diff --git a/test/git_changelog_generate.spec.js b/test/git_changelog_generate.spec.js index c2b6637..b2f4224 100644 --- a/test/git_changelog_generate.spec.js +++ b/test/git_changelog_generate.spec.js @@ -186,7 +186,8 @@ describe('git_changelog_generate.js', function() { changelog.options.branch_name = branch_name; changelog.getGitLogCommands(); - expect(changelog.cmd.gitLog).to.include('git log ' + branch_name); + expect(changelog.cmd.gitLog).to.include('git log ') + .and.include('..' + branch_name); expect(changelog.cmd.gitLogNoTag).to.include('git log ' + branch_name); });