Skip to content

Instantly share code, notes, and snippets.

@TheSavior
Created March 15, 2015 01:08
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 TheSavior/253441fd8b503a30c79e to your computer and use it in GitHub Desktop.
Save TheSavior/253441fd8b503a30c79e to your computer and use it in GitHub Desktop.
Get common git sha ancestor between a sha and a branch
getCommonAncestor: function(headSha, baseBranch) {
return new Bluebird(function(resolve) {
var command = "bash -c 'diff -u <(git rev-list --all " + headSha + ") "+
"<(git rev-list --first-parent " + baseBranch+")' "+
"| sed -ne 's/^ //p' | head -1";
execute(command, function(data) {
resolve(data);
});
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment