Skip to content

Commit 00049f7

Browse files
committed
chore(release): ignore reverted commits
1 parent d981af0 commit 00049f7

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

RELEASE_PROCESS.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,18 @@ Please follow [the spec](https://www.conventionalcommits.org/en/v1.0.0-beta.4/#c
1717

1818
Please have in mind that the only line you have to add is the selected one. Github already takes care of adding the PR title to the body of the merge commit.
1919

20+
## Reverting a release
21+
22+
If you've released something you were not supposed to and want to remove that release from npm, remove the git tag and then rollback the changes, you have a few options:
23+
24+
### Reset master branch
25+
26+
Cleanest way is to just reset the master branch and remove the last few commits, so the ideal is just do reset and force-push.
27+
28+
### Revert unwanted commits
29+
30+
If you want some of the newest commits but want to remove older ones you can just revert the commit with `git revert MERGE_PR_COMMIT_HASH`. Please have in mind that in case your merge commit contains a commit with a breaking change flag, you need to revert that commit BEFORE reverting the PR merge commit.
31+
2032
## Git flow
2133

2234
### develop & next tags

release/monorepo-setup.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,21 @@ const git = async (args, options = {}) => {
88
return stdout;
99
};
1010

11+
const revertRegexSubject = new RegExp('^Revert "(.*)"');
12+
const revertRegexBody = new RegExp('This reverts commit ([a-z0-9]*)');
13+
1114
async function filterCommits(path, regex, pluginConfig, commits) {
15+
const revertedCommits = commits
16+
.filter((commit) => {
17+
return revertRegexSubject.test(commit.subject);
18+
})
19+
.map((commit) => {
20+
const [_, reverted] = commit.body.match(revertRegexBody);
21+
return reverted;
22+
});
23+
1224
const mergeCommits = commits.filter((commit) => {
25+
if (revertedCommits.includes(commit.hash)) return false;
1326
const regexPassed = regex ? regex.test(commit.subject) : true;
1427
const noteKeywordsPassed = pluginConfig.parserOpts.noteKeywords.find(
1528
(keyword) => commit.body && commit.body.includes(keyword),

0 commit comments

Comments
 (0)