Skip to content
Permalink
Browse files

[Fix JENKINS-29482] Don't hide build history when prune stale branche…

…s is on

Reverts "prune deleted branches from BuildData to avoid growing memory consumption"

This reverts the bulk of commit 163e60f.
The two test cases which were added are still retained, though it is odd
that they are unaffected by reverting the change to the production code.
As far as I can tell, the BuildData.purgeStaleBranches method was not
called by any test, even though it seems it should have been called.
  • Loading branch information
MarkEWaite committed Jul 18, 2015
1 parent cc2ddb7 commit be1890377a4623be9483e6b70df22cd8da2f7616
@@ -1,13 +1,11 @@
package hudson.plugins.git.extensions.impl;

import hudson.Extension;
import hudson.model.Run;
import hudson.model.TaskListener;
import hudson.plugins.git.GitException;
import hudson.plugins.git.GitSCM;
import hudson.plugins.git.extensions.GitSCMExtension;
import hudson.plugins.git.extensions.GitSCMExtensionDescriptor;
import hudson.plugins.git.util.BuildData;
import org.jenkinsci.plugins.gitclient.FetchCommand;
import org.jenkinsci.plugins.gitclient.GitClient;
import org.kohsuke.stapler.DataBoundConstructor;
@@ -31,12 +29,6 @@ public void decorateFetchCommand(GitSCM scm, GitClient git, TaskListener listene
cmd.prune();
}

@Override
public void onCheckoutCompleted(GitSCM scm, Run<?, ?> build, GitClient git, TaskListener listener) throws IOException, InterruptedException, GitException {
build.getAction(BuildData.class).purgeStaleBranches(git.getBranches());

}

@Extension
public static class DescriptorImpl extends GitSCMExtensionDescriptor {
@Override
@@ -244,21 +244,4 @@ public String toString() {
",buildsByBranchName="+buildsByBranchName+
",lastBuild="+lastBuild+"]";
}

/**
* Remove branches from BuildData that have been seen in the past but do not exist anymore
* @param keepBranches all branches available in current repository state
*/
public void purgeStaleBranches(Set<Branch> keepBranches) {
Set<String> names = new HashSet<String>(buildsByBranchName.keySet());
for (Branch branch : keepBranches) {
String name = branch.getName();
if (name.startsWith("remotes/")) {
names.remove(name.substring(8));
}
}
for (String name : names) {
buildsByBranchName.remove(name);
}
}
}

0 comments on commit be18903

Please sign in to comment.