How can I check with java api that one branch merged to another?
In pure git I can
git branch --no-merged master git branch --merged master
Community moderators have prevented the ability to post new answers.
private boolean isMergedBranch(Repository repository, Branch branch, Branch baseBranch) { final Integer[] commitsCount = new Integer[1]; commitsCount[0] = 0; CommitCallback commitCallback = new AbstractCommitCallback() { @Override public boolean onCommit(Commit commit) { commitsCount[0]++; return true; } }; compareService.streamCommits( new CompareRequest.Builder() .fromRef(branch.getId(), repository) .toRef(baseBranch.getId(), repository) .build(), commitCallback ); return commitsCount[0] == 0; }
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.