git-common-ancestor

2.0.0 • Public • Published

git-common-ancestor

Build Status devDependency Status devDependency Status

Find the branching point between two points in a git repo. Knowing the branching point is often useful when writing tools that need to look at the changes made on a branch.

For example, if you want to run a linter on all the files that were changed on your branch, you would use this tool to find the point that your branch was created from your main branch and then use git diff to find the files changed between those revisions.

Installation

$ npm install git-common-ancestor --save-dev

API Usage

Git Graph

#ofShaAndBranch(string sha, string branch) -> Promise(string sha)

var gitCommonAncestor = require('git-common-ancestor');
var sha = '70d708aacad0dcc40346cb15fd05ddb14e8e5f29';

gitCommonAncestor.ofShaAndBranch(sha, 'master')
.then(function(branchPoint) {
  assert.strictEqual(branchPoint, '0b256cbf19f306e4fc4090b0b4bec096d1bfd5eb')
});

#fromBranch(string branch) -> Promise(string sha)

Calls ofShaAndBranch passing in the current sha and diffing against the given branch.

var gitCommonAncestor = require('git-common-ancestor');
gitCommonAncestor.fromBranch('master')
.then(function(branchPoint) {
  // Where the current sha branched from master
})

CLI Usage

> git-common-ancestor --branch master
a061416bb6307cd69f155e6a2ebffe75a5be2624
 
> git-common-ancestor --sha 92ce1d5 --branch master
f7d7655f237486d52e8b71a8bb701e63121bec9b

Readme

Keywords

none

Package Sidebar

Install

npm i git-common-ancestor

Weekly Downloads

1

Version

2.0.0

License

Apache-2.0

Last publish

Collaborators

  • eliwhite