Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[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 be18903
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 25 deletions.
@@ -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;
Expand All @@ -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
Expand Down
17 changes: 0 additions & 17 deletions src/main/java/hudson/plugins/git/util/BuildData.java
Expand Up @@ -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.