Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,13 @@ But the comparison isn't quite as strict, generally leading to a shorter list of

### Options

* `--simple` or `-s`: Don't print full markdown output, good for console printing without the additional fluff.
* `--group` or `-g`: Group commits by prefix, this uses the part of the commit summary that is usually used in Node.js core to indicate subsystem for example. Groups are made up of numbers, letters, `,` and `-`, followed by a `:`.
* `--exclude-label`: Exclude any commits from the list that come from a GitHub pull request with the given label. Multiple `--exclude-label` options may be provided, they will also be split by `,`. e.g. `--exclude-label=semver-major,meta`.
* `--patch-only`: An alias for `--exclude-label=semver-major,semver-minor`.
* `--format`: Dictates what formatting the output will have. Possible options are: `simple`, `sha`. The default is to print markdown-formatted output.
- `simple`: Don't print full markdown output, good for console printing without the additional fluff.
- `sha`: Print only the 10-character truncated commit shasums. Good for piping though additional tooling, such as `xargs git cherry-pick` for applying commits.
* `--simple` or `-s`: An alias for `--format=simple`.

## License

Expand Down
18 changes: 13 additions & 5 deletions branch-diff.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,12 @@ function diffCollected (options, branchCommits, callback) {
}


function printCommits (list, simple) {
list = list.map((commit) => commitToOutput(commit, simple, ghId))
function printCommits (list, format) {
if (format === 'sha') {
list = list.map((commit) => `${commit.sha.substr(0, 10)}`)
} else {
list = list.map((commit) => commitToOutput(commit, format === 'simple', ghId))
}

let out = list.join('\n') + '\n'

Expand Down Expand Up @@ -129,12 +133,16 @@ if (require.main === module) {
let argv = require('minimist')(process.argv.slice(2))
, branch1 = argv._[0]
, branch2 = argv._[1]
, simple = argv.simple || argv.s
, format = argv.format
, group = argv.group || argv.g
, endRef = argv['end-ref']
, excludeLabels = []
, options


if (argv.simple || argv.s)
format = 'simple'

if (argv['patch-only'])
excludeLabels = [ 'semver-minor', 'semver-major' ]
if (argv['exclude-label']) {
Expand All @@ -143,12 +151,12 @@ if (require.main === module) {
excludeLabels = excludeLabels.concat(argv['exclude-label'])
}

options = { simple, group, excludeLabels, endRef }
options = { simple: format === 'simple', group, excludeLabels, endRef }

branchDiff(branch1, branch2, options, (err, list) => {
if (err)
throw err

printCommits(list, simple)
printCommits(list, format)
})
}