-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #27 from ariatemplates/script
External script to post process commits
- Loading branch information
Showing
4 changed files
with
149 additions
and
40 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
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
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
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,30 @@ | ||
/** | ||
* Waffle.io uses the syntax `[Connected to #123]` to link PRs to the original task | ||
*/ | ||
const WAFFLE_INFO = /\[connected to #\d+\]\s?/gi; | ||
const ISSUE_ID = /#(\d+)/; | ||
|
||
module.exports = function (data, callback) { | ||
const rewritten = data.commits.map((commit) => { | ||
const matches = commit.title.match(WAFFLE_INFO); | ||
if (matches) { | ||
// extra metadata to remember the linked tasks | ||
commit.tasks = matches.map((m) => m.match(ISSUE_ID)[1]); | ||
// remove it from the title | ||
commit.title = commit.title.replace(WAFFLE_INFO, ''); | ||
} | ||
|
||
if (commit.title.indexOf('[skip ci]') !== -1) { | ||
// Filter out commits we don't care about | ||
return null; | ||
} | ||
|
||
return commit; | ||
}); | ||
|
||
callback({ | ||
commits: rewritten.filter(Boolean), | ||
// rewrite the range because the template only cares about the starting point | ||
range: data.range.split('.')[0], | ||
}); | ||
} |