Skip to content

Commit

Permalink
feat: Opt-in acceptInvalidCommits option
Browse files Browse the repository at this point in the history
  • Loading branch information
Jan Krems committed Jan 18, 2016
1 parent fb9605a commit e16eb35
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 3 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ For more customization, you can use `.nlmrc` or an `nlm` section in `package.jso
* `channels`: A map of branch name to npm `dist-tag`. When publishing, this will determine what will be published and how it's tagged. By default there's one entry in this map: `{ master: 'latest' }`. Which means that a publish from `master` updates the `latest` tag and publish from any other branch does nothing.
* `license.files`: List of files and/or directories to add license headers to.
* `license.exclude`: List of files to exclude that would otherwise be included. `nlm` will always exclude anything in `node_modules`.
* `acceptInvalidCommits`: Accept commit messages even if they can't be parsed.
It's highly discouraged to use this option.
In this mode any commit with an invalid commit message will be treated as "semver-major".

If there's no file named `LICENSE` in the repository, `nlm` won't attempt to add the headers.

Expand Down
3 changes: 2 additions & 1 deletion lib/commands/verify.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ function verify(cwd, pkg, options) {

function setReleaseType() {
/* eslint no-console:0 */
options.releaseType = determineReleaseInfo(options.commits);
options.releaseType =
determineReleaseInfo(options.commits, options.acceptInvalidCommits);
console.log('[nlm] Changes are %j', options.releaseType);
}

Expand Down
10 changes: 8 additions & 2 deletions lib/steps/release-info.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ function isBreaking(note) {
}

var RELEASE_TYPES = ['none', 'patch', 'minor', 'major'];
function determineReleaseInfo(commits) {
function determineReleaseInfo(commits, acceptInvalidCommits) {
var releaseType = 0;

var invalidCommits = [];
Expand Down Expand Up @@ -117,7 +117,13 @@ function determineReleaseInfo(commits) {
}

if (invalidCommits.length) {
throw new InvalidCommitsError(invalidCommits);
if (acceptInvalidCommits) {
// Since we can't tell what those commits actually did,
// we always treat invalid commits as "major"
releaseType = 3;
} else {
throw new InvalidCommitsError(invalidCommits);
}
}

return RELEASE_TYPES[releaseType];
Expand Down
6 changes: 6 additions & 0 deletions test/steps/release-info.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,5 +82,11 @@ describe('determineReleaseInfo', function () {
'[2] https://git-scm.com/docs/git-rebase',
].join('\n'), error.message);
});

describe('with --acceptInvalidCommits', function () {
it('is cautious and considers it "major"', function () {
assert.equal('major', determineReleaseInfo(commits, true));
});
});
});
});

0 comments on commit e16eb35

Please sign in to comment.