semantic-release-gitmoji
Advanced tools
Comparing version 1.0.0 to 1.1.0
{ | ||
"plugins": [ | ||
"semantic-release-gitmoji", | ||
[ | ||
"semantic-release-gitmoji", { | ||
"releaseRules": { | ||
"patch": { | ||
"include": [ | ||
":bento:" | ||
] | ||
} | ||
} | ||
} | ||
], | ||
"@semantic-release/github", | ||
"@semantic-release/npm" | ||
"@semantic-release/npm", | ||
[ | ||
"@semantic-release/git", { | ||
"message": ":bookmark: ${nextRelease.version} [skip ci]\n\nhttps://github.com/momocow/semantic-release-gitmoji/releases/tag/${nextRelease.gitTag}" | ||
} | ||
] | ||
] | ||
} |
@@ -7,4 +7,7 @@ const issueRegex = require('issue-regex') | ||
function parseIssues ({ message = '' } = {}, options) { | ||
return (message.match(issueRegex()) || []) | ||
function parseIssuesAndTasks ({ message = '' } = {}, options) { | ||
const matched = message.match(/(?:^|\s)wip(#\w[\w-_]*)(?:$|\s)/) | ||
// e.g. replace wip#1 to #1 | ||
const issues = (message.replace(/wip(#\d+)/g, '$1').match(issueRegex()) || []) | ||
.map((issue) => ({ | ||
@@ -14,2 +17,9 @@ text: issue, | ||
})) | ||
return { | ||
issues, | ||
task: matched ? matched[0] | ||
: issues.length === 1 && issues[0].text.startsWith('#') ? issues[0].text | ||
: null | ||
} | ||
} | ||
@@ -29,2 +39,3 @@ | ||
module.exports = function parseCommits (commits = [], mixins = {}, options = {}) { | ||
const taskMap = new Map() | ||
return commits | ||
@@ -35,3 +46,4 @@ .map(c => ({ | ||
...parseGitmoji(c), | ||
issues: parseIssues(c, options.issues) | ||
...parseIssuesAndTasks(c, options.issues), | ||
wip: [] | ||
})) | ||
@@ -42,2 +54,13 @@ .reduce((acc, commit) => { | ||
acc[commit.gitmoji].push(commit) | ||
if (commit.task) { | ||
// commits are in the descending order | ||
if (!taskMap.has(commit.task) && commit.gitmoji !== '🚧') { | ||
// it is the final commit if it has not been in the task map | ||
taskMap.set(commit.task, commit) | ||
} else if (taskMap.has(commit.task) && commit.gitmoji === '🚧') { | ||
// the final commit exists so this commit is the releted wip commits | ||
taskMap.get(commit.task).wip.push(commit) | ||
} | ||
} | ||
} | ||
@@ -44,0 +67,0 @@ return acc |
@@ -51,2 +51,5 @@ const hbs = require('handlebars') | ||
Object.values(this._context.commits) | ||
.forEach(commits => commits.reverse()) | ||
debug('Gitmoji commits:') | ||
@@ -53,0 +56,0 @@ Object.keys(this._context.commits) |
{ | ||
"name": "semantic-release-gitmoji", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"description": "Different from conventional changelog, Gitmoji commits are used to determine a release type and generate release notes.", | ||
@@ -10,3 +10,3 @@ "main": "index.js", | ||
"lint": "eslint ./index.js ./lib/**/*.js", | ||
"init": "npm link ../semantic-release-gitmoji", | ||
"link": "npm link ../semantic-release-gitmoji --no-save", | ||
"test": "ava test/**/*.test.js" | ||
@@ -34,2 +34,3 @@ }, | ||
"devDependencies": { | ||
"@semantic-release/git": "^7.0.5", | ||
"@semantic-release/github": "^5.2.1", | ||
@@ -36,0 +37,0 @@ "@semantic-release/npm": "^5.1.1", |
@@ -1,14 +0,14 @@ | ||
# [v1.0.0](https://github.com/momocow/semantic-release-gitmoji/compare/v0.0.0...v1.0.0) (2018-11-21) | ||
# [v1.0.0](https://github.com/momocow/semantic-release-gitmoji/compare/v0.0.0...v1.0.0) ({datetime}) | ||
## ✨ New Features | ||
- [`commit_short`](https://github.com/momocow/semantic-release-gitmoji/commit/commit_short) Add a new feature | ||
- [`commit_short`](https://github.com/momocow/semantic-release-gitmoji/commit/commit_short) Add a new feature | ||
- [`commit_short`](https://github.com/momocow/semantic-release-gitmoji/commit/commit_short) Add a new feature | ||
- [`commit_short`](https://github.com/momocow/semantic-release-gitmoji/commit/commit_short) Add a new feature | ||
## 🐛 Bug Fixes | ||
- [`commit_short`](https://github.com/momocow/semantic-release-gitmoji/commit/commit_short) Fix bugs | ||
- [`commit_short`](https://github.com/momocow/semantic-release-gitmoji/commit/commit_short) Fix bugs | ||
- [`commit_short`](https://github.com/momocow/semantic-release-gitmoji/commit/commit_short) Fix bugs | ||
- [`commit_short`](https://github.com/momocow/semantic-release-gitmoji/commit/commit_short) Fix bugs | ||
- [`commit_short`](https://github.com/momocow/semantic-release-gitmoji/commit/commit_short) Fix bugs | ||
- [`commit_short`](https://github.com/momocow/semantic-release-gitmoji/commit/commit_short) Fix bugs | ||
- [`commit_short`](https://github.com/momocow/semantic-release-gitmoji/commit/commit_short) Fix bugs | ||
- [`commit_short`](https://github.com/momocow/semantic-release-gitmoji/commit/commit_short) Fix bugs | ||
## 💥 Breaking Changes | ||
- [`commit_short`](https://github.com/momocow/semantic-release-gitmoji/commit/commit_short) Introduce a breaking change | ||
- [`commit_short`](https://github.com/momocow/semantic-release-gitmoji/commit/commit_short) Introduce a breaking change |
@@ -1,12 +0,12 @@ | ||
# [v0.1.0](https://github.com/momocow/semantic-release-gitmoji/compare/v0.0.0...v0.1.0) (2018-11-21) | ||
# [v0.1.0](https://github.com/momocow/semantic-release-gitmoji/compare/v0.0.0...v0.1.0) ({datetime}) | ||
## ✨ New Features | ||
- [`commit_short`](https://github.com/momocow/semantic-release-gitmoji/commit/commit_short) Add a new feature | ||
- [`commit_short`](https://github.com/momocow/semantic-release-gitmoji/commit/commit_short) Add a new feature | ||
- [`commit_short`](https://github.com/momocow/semantic-release-gitmoji/commit/commit_short) Add a new feature | ||
- [`commit_short`](https://github.com/momocow/semantic-release-gitmoji/commit/commit_short) Add a new feature | ||
## 🐛 Bug Fixes | ||
- [`commit_short`](https://github.com/momocow/semantic-release-gitmoji/commit/commit_short) Fix bugs | ||
- [`commit_short`](https://github.com/momocow/semantic-release-gitmoji/commit/commit_short) Fix bugs | ||
- [`commit_short`](https://github.com/momocow/semantic-release-gitmoji/commit/commit_short) Fix bugs | ||
- [`commit_short`](https://github.com/momocow/semantic-release-gitmoji/commit/commit_short) Fix bugs | ||
- [`commit_short`](https://github.com/momocow/semantic-release-gitmoji/commit/commit_short) Fix bugs | ||
- [`commit_short`](https://github.com/momocow/semantic-release-gitmoji/commit/commit_short) Fix bugs | ||
- [`commit_short`](https://github.com/momocow/semantic-release-gitmoji/commit/commit_short) Fix bugs | ||
- [`commit_short`](https://github.com/momocow/semantic-release-gitmoji/commit/commit_short) Fix bugs | ||
@@ -1,8 +0,8 @@ | ||
# [v0.0.1](https://github.com/momocow/semantic-release-gitmoji/compare/v0.0.0...v0.0.1) (2018-11-21) | ||
# [v0.0.1](https://github.com/momocow/semantic-release-gitmoji/compare/v0.0.0...v0.0.1) ({datetime}) | ||
## 🐛 Bug Fixes | ||
- [`commit_short`](https://github.com/momocow/semantic-release-gitmoji/commit/commit_short) Fix bugs | ||
- [`commit_short`](https://github.com/momocow/semantic-release-gitmoji/commit/commit_short) Fix bugs | ||
- [`commit_short`](https://github.com/momocow/semantic-release-gitmoji/commit/commit_short) Fix bugs | ||
- [`commit_short`](https://github.com/momocow/semantic-release-gitmoji/commit/commit_short) Fix bugs | ||
- [`commit_short`](https://github.com/momocow/semantic-release-gitmoji/commit/commit_short) Fix bugs | ||
- [`commit_short`](https://github.com/momocow/semantic-release-gitmoji/commit/commit_short) Fix bugs | ||
- [`commit_short`](https://github.com/momocow/semantic-release-gitmoji/commit/commit_short) Fix bugs | ||
- [`commit_short`](https://github.com/momocow/semantic-release-gitmoji/commit/commit_short) Fix bugs | ||
const test = require('ava') | ||
const sinon = require('sinon') | ||
const dateFormat = require('dateformat') | ||
@@ -11,4 +12,7 @@ const { generateNotes } = require('../..') | ||
const now = new Date() | ||
function readNotesSync (name) { | ||
return readFileSync(path.join(__dirname, 'fixtures', 'notes', `notes-${name}.md`), 'utf8') | ||
.replace(/\{datetime\}/g, dateFormat(now, 'yyyy-mm-dd')) | ||
} | ||
@@ -62,2 +66,13 @@ | ||
expectedNotes: readNotesSync('major') | ||
}, | ||
{ | ||
name: 'default config + WIP context w/ minor updates', | ||
pluginConfig: {}, | ||
context: getContext('wip', { | ||
nextRelease: { | ||
version: '1.0.0', | ||
gitTag: 'v1.0.0' | ||
} | ||
}), | ||
expectedNotes: readNotesSync('wip') | ||
} | ||
@@ -64,0 +79,0 @@ ] |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
32919
32
604
15