mirror of
https://github.com/scm-manager/scm-manager.git
synced 2026-01-01 05:09:50 +01:00
return null if commit was not merged into requested branch
This commit is contained in:
@@ -132,13 +132,16 @@ public class GitLogCommand extends AbstractGitCommand implements LogCommand
|
||||
{
|
||||
converter = new GitChangesetConverter(gr, revWalk);
|
||||
|
||||
if (request != null &&
|
||||
!Strings.isNullOrEmpty(request.getBranch()) &&
|
||||
revWalk.isMergedInto(commit, findTipCommitForRequestBranch(request, gr, revWalk))) {
|
||||
changeset = converter.createChangeset(commit, request.getBranch());
|
||||
if (isBranchRequested(request)) {
|
||||
String branch = request.getBranch();
|
||||
if (isMergedIntoBranch(gr, revWalk, commit, branch)) {
|
||||
logger.trace("returning commit {} with branch {}", commit.getId(), branch);
|
||||
changeset = converter.createChangeset(commit, branch);
|
||||
} else {
|
||||
logger.debug("returning null, because commit {} was not merged into branch {}", commit.getId(), branch);
|
||||
}
|
||||
} else {
|
||||
changeset = converter.createChangeset(commit);
|
||||
|
||||
}
|
||||
}
|
||||
else if (logger.isWarnEnabled())
|
||||
@@ -165,8 +168,16 @@ public class GitLogCommand extends AbstractGitCommand implements LogCommand
|
||||
return changeset;
|
||||
}
|
||||
|
||||
private RevCommit findTipCommitForRequestBranch(LogCommandRequest request, Repository gr, RevWalk revWalk) throws IOException {
|
||||
return revWalk.parseCommit(GitUtil.getCommit(gr, revWalk, gr.findRef(request.getBranch())));
|
||||
private boolean isMergedIntoBranch(Repository repository, RevWalk revWalk, RevCommit commit, String branchName) throws IOException {
|
||||
return revWalk.isMergedInto(commit, findHeadCommitOfBranch(repository, revWalk, branchName));
|
||||
}
|
||||
|
||||
private boolean isBranchRequested(LogCommandRequest request) {
|
||||
return request != null && !Strings.isNullOrEmpty(request.getBranch());
|
||||
}
|
||||
|
||||
private RevCommit findHeadCommitOfBranch(Repository repository, RevWalk revWalk, String branchName) throws IOException {
|
||||
return revWalk.parseCommit(GitUtil.getCommit(repository, revWalk, repository.findRef(branchName)));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user