Skip to content

Instantly share code, notes, and snippets.

@gzaripov
Created October 12, 2019 21:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gzaripov/f4259b2fe8cabd65a04c886f1e81201c to your computer and use it in GitHub Desktop.
Save gzaripov/f4259b2fe8cabd65a04c886f1e81201c to your computer and use it in GitHub Desktop.
Rewrite git mesage
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