Skip to content

Instantly share code, notes, and snippets.

@locnguyen
Last active February 1, 2018 05:15
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 locnguyen/bd6d69c87582befa295f31f10bd1dd46 to your computer and use it in GitHub Desktop.
Save locnguyen/bd6d69c87582befa295f31f10bd1dd46 to your computer and use it in GitHub Desktop.
Search release branches by git commit messaage
const childProcess = require('child_process');
const { exec } = childProcess;
exec(`git log --oneline --all --grep "${process.argv[2]}"`, (err, stdout, stderr) => {
if (err) {
console.error(err);
return;
}
const logResults = stdout.split('\n').filter(out => out.length).map(out => ({
sha: out.slice(0, 8),
message: out.slice(9, out.length)
}));
logResults.map(log => exec(`git branch -r --contains ${log.sha} --list "origin/release/*"`, (err, stdout, stderr) => {
if (err) {
console.error(err);
return;
}
console.log(JSON.stringify({
sha: log.sha,
message: log.message.trim(),
branches: stdout.split('\n').filter(out => out.length).map(out => out.trim())
}, null, 4));
}));
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment