Created
October 12, 2019 21:07
-
-
Save gzaripov/54f7a62a2b73b613e9a2f5620fabe8f6 to your computer and use it in GitHub Desktop.
Rewrite git mesage
This file contains hidden or 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
const readline = require("readline"); | |
const rl = readline.createInterface({ | |
input: process.stdin, | |
output: process.stdout, | |
terminal: false | |
}); | |
rl.on("line", function(line) { | |
console.log(changeMessage(line, "TOLOKA-11426")); | |
}); | |
const MESSAGE_REGEX = /(refactor|chore|feat|fix): (.*)/; | |
function changeMessage(message, ticket) { | |
if (!MESSAGE_REGEX.test(message)) { | |
return message; | |
} | |
return message.replace(MESSAGE_REGEX, `${ticket}: $2`); | |
} | |
// changeMessage("refactor: dfdkfsd", "TOLOKA-11426"); // ? | |
// changeMessage("chore: dfdkfsd", "TOLOKA-11426"); // ? | |
// changeMessage("feat: dfdkfsd", "TOLOKA-11426"); // ? | |
// changeMessage("fix: dfdkfsd", "TOLOKA-11426"); // ? | |
// changeMessage( | |
// "Merge remote-tracking branch 'remotes/origin/master' into feature/TOL… …", | |
// "TOLOKA-11426" | |
// ); // ? | |
// command | |
// git filter-branch -f --msg-filter ' | |
// node /Users/gzarip/filter-message.js | |
// ' HEAD~277..HEAD |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment