Skip to content

Commit 74e9bba

Browse files
authored
Merge pull request mozilla#346 from kumar303/commit-msg
chore: Added linting of changelog style commit messages
2 parents 21855ae + 45aa375 commit 74e9bba

File tree

5 files changed

+49
-1
lines changed

5 files changed

+49
-1
lines changed

.conventional-changelog-lintrc

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"extends": ["angular"],
3+
"rules": {
4+
"body-tense": [0, "never"],
5+
"subject-tense": [0, "never"],
6+
"footer-tense": [0, "never"],
7+
"subject-case": [0, "never"],
8+
"subject-full-stop": [0, "never"]
9+
}
10+
}

.travis.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ node_js:
55
- '4'
66
before_install:
77
- npm install -g npm
8-
script: COVERAGE=y npm test
8+
script: COVERAGE=y npm test && npm run lint-commit-msg
99
after_script: npm run publish-coverage
1010
notifications:
1111
irc:

CONTRIBUTING.md

+7
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,13 @@ Examples:
8383
If you want to use scopes then it would look more like:
8484
`feat(dysfunctioner): Added --quiet option`.
8585

86+
### Check for commit message lint
87+
88+
You can test that your commit message is formatted in a way that will support
89+
our changelog generator like this:
90+
91+
npm run lint-commit-msg
92+
8693
## Squashing commits
8794

8895
When fixing up a pull request based on code review comments,

Gruntfile.js

+28
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/*eslint prefer-template: 0*/
22
var path = require('path');
33
var spawn = require('child_process').spawn;
4+
var semver = require('semver');
45

56
module.exports = function(grunt) {
67

@@ -47,13 +48,40 @@ module.exports = function(grunt) {
4748
grunt.registerTask('lint', 'checks for syntax errors', function() {
4849
if (process.env.SKIP_LINT) {
4950
grunt.log.writeln('lint task skipped because of $SKIP_LINT');
51+
} else if (semver.satisfies(process.version, '< 4.0.0')) {
52+
// eslint now requires a new-ish Node.
53+
grunt.log.writeln('task skipped because this version of Node is too old');
5054
} else {
5155
grunt.task.run([
5256
'newer:eslint',
5357
]);
5458
}
5559
});
5660

61+
grunt.registerTask(
62+
'lint-commit-msg', 'checks for commit message lint', function() {
63+
var done = this.async();
64+
if (semver.satisfies(process.version, '>= 4.0.0')) {
65+
66+
var proc = spawn('conventional-changelog-lint', ['--from', 'master']);
67+
proc.stderr.on('data', function(data) {
68+
grunt.log.write(data);
69+
});
70+
proc.stdout.on('data', function(data) {
71+
grunt.log.write(data);
72+
});
73+
proc.on('close', function(code) {
74+
var succeeded = code === 0;
75+
done(succeeded);
76+
});
77+
78+
} else {
79+
grunt.log.writeln(
80+
'task skipped because this version of Node is too old');
81+
done(true);
82+
}
83+
});
84+
5785
grunt.registerTask(
5886
'check-for-smoke',
5987
'checks to see if web-ext is completely broken', function() {

package.json

+3
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"start": "node -e \"require('grunt').cli()\" null develop",
1717
"flow-check": "node -e \"require('grunt').cli()\" null flowbin:check",
1818
"lint": "node -e \"require('grunt').cli()\" null lint",
19+
"lint-commit-msg": "node -e \"require('grunt').cli()\" null lint-commit-msg",
1920
"test": "node -e \"require('grunt').cli()\" null test",
2021
"publish-coverage": "node -e \"require('grunt').cli()\" null coveralls"
2122
},
@@ -70,6 +71,7 @@
7071
"babel-preset-es2015": "6.9.0",
7172
"babel-preset-stage-2": "6.11.0",
7273
"chai": "3.5.0",
74+
"conventional-changelog-lint": "1.0.0",
7375
"copy-dir": "0.3.0",
7476
"coveralls": "2.11.9",
7577
"deepcopy": "0.6.3",
@@ -89,6 +91,7 @@
8991
"load-grunt-tasks": "3.5.0",
9092
"mocha": "2.5.3",
9193
"mocha-multi": "0.9.0",
94+
"semver": "5.2.0",
9295
"shelljs": "0.7.0",
9396
"sinon": "1.17.4",
9497
"webpack": "1.13.1",

0 commit comments

Comments
 (0)