Thursday 15 March 2012

How to determine with JGit which branches have been merged to master? -



How to determine with JGit which branches have been merged to master? -

how utilize jgit determine branches have been merged master?

i want equivalent of normal git command:

git branch -a --merged

is possible in jgit?

revwalk#ismergedinto() can used determine if commit merged another. is, ismergedinto returns true if commit given in first argument ancestor of sec given commit.

class="lang-java prettyprint-override">revwalk revwalk = new revwalk( repository ); revcommit masterhead = revwalk.parsecommit( repository.resolve( "refs/heads/master" ); revcommit otherhead = revwalk.parsecommit( repository.resolve( "refs/heads/other-branch" ); if( revwalk.ismergedinto( otherhead, masterhead ) ) { ... } revwalk.release();

to list of branches listbranchescommandcan used:

class="lang-java prettyprint-override">list<ref> branches = git.wrap( repository ).listbranches().setlistmode( listmode.all ).call();

jgit

No comments:

Post a Comment