-
Notifications
You must be signed in to change notification settings - Fork 713
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
176 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
## Git Commit Messages | ||
|
||
* Use the present tense ("Add feature" not "Added feature") | ||
* Use the imperative mood ("Move cursor to..." not "Moves cursor to...") | ||
* Limit the first line to 72 characters or less | ||
* Reference issues and pull requests liberally | ||
* Consider starting the commit message with an applicable emoji: | ||
* :art: `:art:` when improving the format/structure of the code | ||
* :racehorse: `:racehorse:` when improving performance | ||
* :non-potable_water: `:non-potable_water:` when plugging memory leaks | ||
* :memo: `:memo:` when writing docs | ||
* :penguin: `:penguin:` when fixing something on Linux | ||
* :apple: `:apple:` when fixing something on Mac OS | ||
* :checkered_flag: `:checkered_flag:` when fixing something on Windows | ||
* :bug: `:bug:` when fixing a bug | ||
* :fire: `:fire:` when removing code or files | ||
* :green_heart: `:green_heart:` when fixing the CI build | ||
* :white_check_mark: `:white_check_mark:` when adding tests | ||
* :lock: `:lock:` when dealing with security | ||
* :arrow_up: `:arrow_up:` when upgrading dependencies | ||
* :arrow_down: `:arrow_down:` when downgrading dependencies | ||
* :shirt: `:shirt:` when removing linter warnings | ||
|
||
Based on https://github.com/atom/atom/blob/master/CONTRIBUTING.md#git-commit-messages |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
'use strict'; | ||
var dateFormat = require('dateformat'); | ||
var Q = require('q'); | ||
var readFile = Q.denodeify(require('fs').readFile); | ||
var resolve = require('path').resolve; | ||
var semver = require('semver'); | ||
var through = require('through2'); | ||
|
||
var regex = /tag:\s*[v=]?(.+?)[,\)]/gi; | ||
|
||
function presetOpts(cb) { | ||
var parserOpts = { | ||
headerPattern: /^(:.*?:) (.*)$/, | ||
headerCorrespondence: [ | ||
'emoji', | ||
'shortDesc' | ||
] | ||
}; | ||
|
||
var transform = through.obj(function(chunk, enc, cb) { | ||
if (typeof chunk.gitTags === 'string') { | ||
var match = regex.exec(chunk.gitTags); | ||
if (match) { | ||
chunk.version = match[1]; | ||
} | ||
} | ||
|
||
if (chunk.committerDate) { | ||
chunk.committerDate = dateFormat(chunk.committerDate, 'yyyy-mm-dd', true); | ||
} | ||
|
||
cb(null, chunk); | ||
}); | ||
|
||
var writerOpts = { | ||
transform: function(commit) { | ||
var emojiLength; | ||
|
||
if (!commit.emoji || typeof commit.emoji !== 'string') { | ||
return; | ||
} | ||
|
||
commit.emoji = commit.emoji.substring(0, 72); | ||
emojiLength = commit.emoji.length; | ||
|
||
if (typeof commit.hash === 'string') { | ||
commit.hash = commit.hash.substring(0, 7); | ||
} | ||
|
||
if (typeof commit.shortDesc === 'string') { | ||
commit.shortDesc = commit.shortDesc.substring(0, 72 - emojiLength); | ||
} | ||
|
||
return commit; | ||
}, | ||
groupBy: 'emoji', | ||
commitGroupsSort: 'title', | ||
commitsSort: ['emoji', 'shortDesc'], | ||
generateOn: function(commit) { | ||
return semver.valid(commit.version); | ||
} | ||
}; | ||
|
||
Q.all([ | ||
readFile(resolve(__dirname, '../templates/jquery/template.hbs'), 'utf-8'), | ||
readFile(resolve(__dirname, '../templates/jquery/header.hbs'), 'utf-8'), | ||
readFile(resolve(__dirname, '../templates/jquery/commit.hbs'), 'utf-8') | ||
]) | ||
.spread(function(template, header, commit) { | ||
writerOpts.mainTemplate = template; | ||
writerOpts.headerPartial = header; | ||
writerOpts.commitPartial = commit; | ||
|
||
cb(null, { | ||
parserOpts: parserOpts, | ||
transform: transform, | ||
writerOpts: writerOpts | ||
}); | ||
}); | ||
} | ||
|
||
module.exports = presetOpts; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
* {{#if shortDesc}}{{shortDesc}}{{else}}{{header}}{{/if}} | ||
|
||
{{~!-- commit hash --}} {{#if @root.linkReferences}}([{{hash}}]({{@root.host}}/{{#if @root.owner}}{{@root.owner}}/{{/if}}{{@root.repository}}/{{@root.commit}}/{{hash}})){{else}}{{hash~}}{{/if}} | ||
|
||
{{~!-- commit references --}}{{#if references}}, closes{{~#each references}} {{#if @root.linkReferences}}[{{#if this.owner}}{{this.owner}}/{{/if}}{{this.repository}}#{{this.issue}}]({{@root.host}}/{{#if this.repository}}{{#if this.owner}}{{this.owner}}/{{/if}}{{this.repository}}{{else}}{{#if @root.owner}}{{@root.owner}}/{{/if}}{{@root.repository}}{{/if}}/{{@root.issue}}/{{this.issue}}){{else}}{{this.repository}}#{{this.issue}}{{/if}}{{/each}}{{/if}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
<a name="{{version}}"></a> | ||
{{#if isPatch}}##{{else}}#{{/if}} {{version}}{{#if title}} "{{title}}"{{/if}}{{#if date}} ({{date}}){{/if}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{{> header}} | ||
|
||
{{#each commitGroups}} | ||
|
||
{{#if title}} | ||
### {{title}} | ||
|
||
{{/if}} | ||
{{#each commits}} | ||
{{> commit root=@root}} | ||
{{/each}} | ||
{{/each}} | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
'use strict'; | ||
var conventionalChangelog = require('../'); | ||
var expect = require('chai').expect; | ||
var shell = require('shelljs'); | ||
var through = require('through2'); | ||
var writeFileSync = require('fs').writeFileSync; | ||
|
||
describe('presets', function() { | ||
describe('atom', function() { | ||
before(function() { | ||
shell.cd('atom'); | ||
shell.exec('git init'); | ||
writeFileSync('test1', ''); | ||
shell.exec('git add --all && git commit -m":arrow_down: exception-reporting"'); | ||
writeFileSync('test2', ''); | ||
shell.exec('git add --all && git commit -m\':bug: `updateContentDimensions` when model changes\''); | ||
writeFileSync('test3', ''); | ||
shell.exec('git add --all && git commit -m"Merge pull request #7881 from atom/bf-upgrade-babel-to-5.6.17"'); | ||
writeFileSync('test4', ''); | ||
shell.exec('git add --all && git commit -m":arrow_up: language-gfm@0.79.0"'); | ||
writeFileSync('test5', ''); | ||
shell.exec('git add --all && git commit -m":arrow_up: one-dark/light-ui@v1.0.1"'); | ||
}); | ||
|
||
after(function() { | ||
shell.cd('../'); | ||
}); | ||
|
||
it('should work if there is no semver tag', function(done) { | ||
conventionalChangelog({ | ||
preset: 'atom' | ||
}) | ||
.pipe(through(function(chunk) { | ||
chunk = chunk.toString(); | ||
|
||
expect(chunk).to.include(':arrow_down:'); | ||
expect(chunk).to.include('`updateContentDimensions` when model changes'); | ||
expect(chunk).to.include(':arrow_up:'); | ||
expect(chunk).to.include('one-dark/light-ui@v1.0.1'); | ||
|
||
expect(chunk).to.not.include('7881'); | ||
|
||
done(); | ||
})); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters