Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[JENKINS-20392] Fix "Recent History" for merge jobs.
To compute the recent-history, jenkins uses a hashmap of branch-names
and commit-ids. The bug has two sources:
1) To fill the hashmap, jenkins uses only the branch-name and
commit-ids of those commits, that triggered the build. The
merge-commits created by jenkins are ignored (see
BuildData.java#L129).
2) To calculate the "Recent Changes", jenkins searches for the
branch-names of the commit, that was built. But jenkins considers the
merge-commit not part of any branch (the call to getRevisionsForSHA1
in PreBuildMerge.java#L93 returns a Revision without associated
branches).

The patch fixes this bug by 1) including the branches of the current
commit in the recent-changes-hashmap and 2) associating the current
commit with the correct branch-name.
  • Loading branch information
mlex committed May 1, 2014
1 parent 8544f21 commit b280169
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
Expand Up @@ -7,6 +7,7 @@
import hudson.plugins.git.GitException;
import hudson.plugins.git.GitSCM;
import hudson.plugins.git.Revision;
import hudson.plugins.git.Branch;
import hudson.plugins.git.UserMergeOptions;
import hudson.plugins.git.extensions.GitClientType;
import hudson.plugins.git.extensions.GitSCMExtension;
Expand Down Expand Up @@ -90,7 +91,9 @@ public Revision decorateRevisionToBuild(GitSCM scm, AbstractBuild<?, ?> build, G

build.addAction(new MergeRecord(remoteBranchRef,target.getName()));

return new GitUtils(listener,git).getRevisionForSHA1(git.revParse(HEAD));
Revision mergeRevision = new GitUtils(listener,git).getRevisionForSHA1(git.revParse(HEAD));
mergeRevision.getBranches().add(new Branch(remoteBranchRef, target));
return mergeRevision;
}

@Override
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/hudson/plugins/git/util/BuildData.java
Expand Up @@ -131,6 +131,9 @@ public void saveBuild(Build build) {
for(Branch branch : build.marked.getBranches()) {
buildsByBranchName.put(fixNull(branch.getName()), build);
}
for(Branch branch : build.revision.getBranches()) {
buildsByBranchName.put(fixNull(branch.getName()), build);
}
}

public Build getLastBuildOfBranch(String branch) {
Expand Down

0 comments on commit b280169

Please sign in to comment.