From 68c20a8aabbfffefa696805345c4b813ba60fd62 Mon Sep 17 00:00:00 2001 From: Pete Cook Date: Thu, 20 Jun 2019 13:50:14 +0100 Subject: [PATCH] Add --append-git-log option Closes https://github.com/CookPete/auto-changelog/pull/118 Fixes https://github.com/CookPete/auto-changelog/issues/117 --- README.md | 1 + src/commits.js | 2 +- src/run.js | 4 +++- src/utils.js | 2 +- 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 522f1457..d9632587 100644 --- a/README.md +++ b/README.md @@ -41,6 +41,7 @@ Options: --include-branch [branch] # one or more branches to include commits from, comma separated --release-summary # display tagged commit message body as release summary --handlebars-setup [file] # handlebars setup file + --append-git-log [string] # string to append to git log command --stdout # output changelog to stdout -V, --version # output the version number -h, --help # output usage information diff --git a/src/commits.js b/src/commits.js index 7df4fbe3..37af8178 100644 --- a/src/commits.js +++ b/src/commits.js @@ -21,7 +21,7 @@ const MERGE_PATTERNS = [ export async function fetchCommits (remote, options, branch = null, onProgress) { const command = branch ? `git log ${branch}` : 'git log' const format = await getLogFormat() - const log = await cmd(`${command} --shortstat --pretty=format:${format}`, onProgress) + const log = await cmd(`${command} --shortstat --pretty=format:${format} ${options.appendGitLog}`, onProgress) return parseCommits(log, remote, options) } diff --git a/src/run.js b/src/run.js index 9e8a2650..cccb5ad4 100644 --- a/src/run.js +++ b/src/run.js @@ -15,7 +15,8 @@ const DEFAULT_OPTIONS = { commitLimit: 3, backfillLimit: 3, tagPrefix: '', - sortCommits: 'relevance' + sortCommits: 'relevance', + appendGitLog: '' } const PACKAGE_FILE = 'package.json' @@ -44,6 +45,7 @@ async function getOptions (argv) { .option('--include-branch ', 'one or more branches to include commits from, comma separated', str => str.split(',')) .option('--release-summary', 'use tagged commit message body as release summary') .option('--handlebars-setup ', 'handlebars setup file') + .option('--append-git-log ', 'string to append to git log command') .option('--stdout', 'output changelog to stdout') .version(version) .parse(argv) diff --git a/src/utils.js b/src/utils.js index 30e5471e..474840ec 100644 --- a/src/utils.js +++ b/src/utils.js @@ -18,7 +18,7 @@ export function formatBytes (bytes) { // Simple util for calling a child process export function cmd (string, onProgress) { - const [ cmd, ...args ] = string.split(' ') + const [ cmd, ...args ] = string.trim().split(' ') return new Promise((resolve, reject) => { const child = spawn(cmd, args) let data = ''