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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ But the comparison isn't quite as strict, generally leading to a shorter list of
* `--version`: Only prints branch-diff's package.json version.
* `--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`.
* `--require-label`: Only include commits in the list that come from a GitHub pull request with the given label. Multiple `--require-label` options may be provided, they will also be split by `,`. e.g. `--require-label=test,doc`.
* `--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.
Expand Down
23 changes: 22 additions & 1 deletion branch-diff.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,14 @@ function diffCollected (options, branchCommits, callback) {
})
}

if (options.requireLabels) {
list = list.filter((commit) => {
return commit.labels && commit.labels.some((label) => {
return options.requireLabels.indexOf(label) >= 0
})
})
}

if (options.group)
list = groupCommits(list)

Expand Down Expand Up @@ -146,6 +154,7 @@ if (require.main === module) {
, group = argv.group || argv.g
, endRef = argv['end-ref']
, excludeLabels = []
, requireLabels = []
, options


Expand All @@ -164,7 +173,19 @@ if (require.main === module) {
excludeLabels = excludeLabels.concat(argv['exclude-label'])
}

options = { simple: format === 'simple', group, excludeLabels, endRef }
if (argv['require-label']) {
if (!Array.isArray(argv['require-label']))
argv['require-label'] = argv['require-label'].split(',')
requireLabels = requireLabels.concat(argv['require-label'])
}

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

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