Log Message
applying some git pull requests
Modified Paths
- trunk/hudson/plugins/view-job-filters/pom.xml
- trunk/hudson/plugins/view-job-filters/src/main/java/hudson/views/AbstractBuildTrendFilter.java
- trunk/hudson/plugins/view-job-filters/src/main/java/hudson/views/GitLegacyValuesProvider.java
- trunk/hudson/plugins/view-job-filters/src/main/java/hudson/views/UpstreamDownstreamJobsFilter.java
- trunk/hudson/plugins/view-job-filters/src/test/java/hudson/views/BuildTrendFilterTest.java
Added Paths
Diff
Modified: trunk/hudson/plugins/view-job-filters/pom.xml (40966 => 40967)
--- trunk/hudson/plugins/view-job-filters/pom.xml 2013-08-03 22:33:26 UTC (rev 40966)
+++ trunk/hudson/plugins/view-job-filters/pom.xml 2013-08-11 01:43:27 UTC (rev 40967)
@@ -2,9 +2,9 @@
<modelVersion>4.0.0</modelVersion>
<parent>
- <groupId>org.jvnet.hudson.plugins</groupId>
- <artifactId>plugin</artifactId>
- <version>1.395</version>
+ <groupId>org.jenkins-ci.plugins</groupId>
+ <artifactId>plugin</artifactId>
+ <version>1.509.2</version>
</parent>
<artifactId>view-job-filters</artifactId>
@@ -26,27 +26,31 @@
<connection>scm:svn:https://svn.jenkins-ci.org/tags/view-job-filters-1.23</connection>
<developerConnection>scm:svn:https://svn.jenkins-ci.org/tags/view-job-filters-1.23</developerConnection>
<url>https://svn.jenkins-ci.org/tags/view-job-filters-1.23</url>
+ <!-- If on GitHub:
+ <connection>scm:git:git://github.com/jenkinsci/${artifactId}-plugin.git</connection>
+ <developerConnection>scm:git:[email protected]:jenkinsci/${artifactId}-plugin.git</developerConnection>
+ <url>https://github.com/jenkinsci/${artifactId}-plugin</url>
+ -->
</scm>
<dependencies>
<dependency>
- <groupId>org.jvnet.hudson.plugins</groupId>
+ <groupId>org.jenkins-ci.plugins</groupId>
<artifactId>cvs</artifactId>
- <version>1.1</version>
+ <version>1.4</version>
<scope>compile</scope>
<optional>true</optional>
</dependency>
<dependency>
- <groupId>org.jvnet.hudson.plugins</groupId>
+ <groupId>org.jenkins-ci.plugins</groupId>
<artifactId>subversion</artifactId>
- <version>1.11</version>
+ <version>1.24</version>
<scope>compile</scope>
<optional>true</optional>
</dependency>
<dependency>
- <groupId>org.jenkinsci.plugins</groupId>
+ <groupId>org.jenkins-ci.plugins</groupId>
<artifactId>git</artifactId>
- <!-- Use this version so we can cover legacy values too -->
- <version>1.1.9</version>
+ <version>1.2.0</version>
<optional>true</optional>
</dependency>
<dependency>
@@ -57,16 +61,16 @@
<optional>true</optional>
</dependency>
<dependency>
- <groupId>org.jvnet.hudson.plugins</groupId>
+ <groupId>org.jenkins-ci.plugins</groupId>
<artifactId>email-ext</artifactId>
- <version>2.7</version>
+ <version>2.11</version>
<scope>compile</scope>
<optional>true</optional>
</dependency>
<dependency>
- <groupId>org.jvnet.hudson.plugins</groupId>
+ <groupId>org.jenkins-ci.plugins</groupId>
<artifactId>m2-extra-steps</artifactId>
- <version>1.1.3</version>
+ <version>1.1.7</version>
<scope>compile</scope>
<optional>true</optional>
</dependency>
Modified: trunk/hudson/plugins/view-job-filters/src/main/java/hudson/views/AbstractBuildTrendFilter.java (40966 => 40967)
--- trunk/hudson/plugins/view-job-filters/src/main/java/hudson/views/AbstractBuildTrendFilter.java 2013-08-03 22:33:26 UTC (rev 40966)
+++ trunk/hudson/plugins/view-job-filters/src/main/java/hudson/views/AbstractBuildTrendFilter.java 2013-08-11 01:43:27 UTC (rev 40967)
@@ -74,22 +74,15 @@
while (run != null) {
// check the different types of durations to see if we've checked back far enough
- if (amount > 0) {
- count++;
- if (amountType == AmountType.Builds) {
- if (count > amount) {
- break;
- }
- } else {
- // get the amount of time since it last built
- long now = System.currentTimeMillis();
- long then = run.getTimeInMillis();
- float diff = now - then;
- diff = amountType.convertMillisToAmount(diff);
- if (diff > amount) {
- break;
- }
- }
+ if (amount > 0 && amountType != AmountType.Builds) {
+ // get the amount of time since it last built
+ long now = System.currentTimeMillis();
+ long then = run.getTimeInMillis();
+ float diff = now - then;
+ diff = amountType.convertMillisToAmount(diff);
+ if (diff > amount) {
+ break;
+ }
}
// now evaluate the build status
boolean runMatches = matchesRun(run);
@@ -109,6 +102,11 @@
}
_oneMatched_ = true;
+ if (amount > 0 && amountType == AmountType.Builds) {
+ if (++count >= amount) {
+ break;
+ }
+ }
run = run.getPreviousBuild();
}
// if we're talking about "all builds" and there was at least one build, then
Modified: trunk/hudson/plugins/view-job-filters/src/main/java/hudson/views/GitLegacyValuesProvider.java (40966 => 40967)
--- trunk/hudson/plugins/view-job-filters/src/main/java/hudson/views/GitLegacyValuesProvider.java 2013-08-03 22:33:26 UTC (rev 40966)
+++ trunk/hudson/plugins/view-job-filters/src/main/java/hudson/views/GitLegacyValuesProvider.java 2013-08-11 01:43:27 UTC (rev 40967)
@@ -1,9 +1,9 @@
package hudson.views;
import java.util.List;
+import org.eclipse.jgit.transport.RemoteConfig;
+import org.eclipse.jgit.transport.URIish;
-import org.spearce.jgit.transport.URIish;
-
public class GitLegacyValuesProvider extends GitValuesProvider {
@SuppressWarnings("unchecked")
@@ -14,11 +14,11 @@
public void addRepositoryValues(Object repoObject, List<String> values) {
// it's possible that the old api is still in the classloader,
// so let's check the runtime instance as well
- if (repoObject instanceof org.eclipse.jgit.transport.RemoteConfig) {
+ if (repoObject instanceof RemoteConfig) {
super.addRepositoryValues(repoObject, values);
} else {
// use legacy api
- org.spearce.jgit.transport.RemoteConfig repo = (org.spearce.jgit.transport.RemoteConfig) repoObject;
+ RemoteConfig repo = (RemoteConfig) repoObject;
List<URIish> uris = repo.getURIs();
if (uris != null) {
for (URIish uri: uris) {
Modified: trunk/hudson/plugins/view-job-filters/src/main/java/hudson/views/UpstreamDownstreamJobsFilter.java (40966 => 40967)
--- trunk/hudson/plugins/view-job-filters/src/main/java/hudson/views/UpstreamDownstreamJobsFilter.java 2013-08-03 22:33:26 UTC (rev 40966)
+++ trunk/hudson/plugins/view-job-filters/src/main/java/hudson/views/UpstreamDownstreamJobsFilter.java 2013-08-11 01:43:27 UTC (rev 40967)
@@ -98,7 +98,7 @@
boolean isUpstream = false;
if (second instanceof AbstractProject) {
AbstractProject secondProject = (AbstractProject) second;
- List<AbstractProject> upstream = secondProject.getBuildTriggerUpstreamProjects();
+ List<AbstractProject> upstream = secondProject.getUpstreamProjects();
isUpstream = upstream.contains(first);
}
if (!isUpstream && mavenHelper != null) {
Added: trunk/hudson/plugins/view-job-filters/src/test/java/hudson/views/AbstractBuildTrendFilterTest.java (0 => 40967)
--- trunk/hudson/plugins/view-job-filters/src/test/java/hudson/views/AbstractBuildTrendFilterTest.java (rev 0)
+++ trunk/hudson/plugins/view-job-filters/src/test/java/hudson/views/AbstractBuildTrendFilterTest.java 2013-08-11 01:43:27 UTC (rev 40967)
@@ -0,0 +1,41 @@
+package hudson.views;
+
+import hudson.model.AllView;
+import hudson.model.FreeStyleProject;
+import hudson.model.Result;
+import hudson.model.TopLevelItem;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import java.util.concurrent.Callable;
+import static org.junit.Assert.*;
+import org.junit.Test;
+import org.junit.Rule;
+import org.jvnet.hudson.test.Bug;
+import org.jvnet.hudson.test.FailureBuilder;
+import org.jvnet.hudson.test.JenkinsRule;
+
+public class AbstractBuildTrendFilterTest {
+
+ @Rule public JenkinsRule j = new JenkinsRule();
+
+ @Bug(18986)
+ @Test public void lazyLoading() throws Exception {
+ final FreeStyleProject p1 = j.createFreeStyleProject("p1");
+ RunLoadCounter.prepare(p1);
+ p1.getBuildersList().add(new FailureBuilder());
+ for (int i = 0; i < 5; i++) {
+ j.assertBuildStatus(Result.FAILURE, p1.scheduleBuild2(0).get());
+ }
+ final FreeStyleProject p2 = j.createFreeStyleProject("p2");
+ j.assertBuildStatusSuccess(p2.scheduleBuild2(0));
+ final ViewJobFilter filter = new BuildTrendFilter("AtLeastOne", "Stable", 3, "Builds", "includeMatched");
+ assertEquals(Collections.singletonList(p2), RunLoadCounter.assertMaxLoads(p1, 3, new Callable<List<TopLevelItem>>() {
+ @Override public List<TopLevelItem> call() throws Exception {
+ return filter.filter(new ArrayList<TopLevelItem>(), Arrays.<TopLevelItem>asList(p1, p2), new AllView("_"));
+ }
+ }));
+ }
+
+}
\ No newline at end of file
Property changes on: trunk/hudson/plugins/view-job-filters/src/test/java/hudson/views/AbstractBuildTrendFilterTest.java
___________________________________________________________________
Added: svn:mime-type
Modified: trunk/hudson/plugins/view-job-filters/src/test/java/hudson/views/BuildTrendFilterTest.java (40966 => 40967)
--- trunk/hudson/plugins/view-job-filters/src/test/java/hudson/views/BuildTrendFilterTest.java 2013-08-03 22:33:26 UTC (rev 40966)
+++ trunk/hudson/plugins/view-job-filters/src/test/java/hudson/views/BuildTrendFilterTest.java 2013-08-11 01:43:27 UTC (rev 40967)
@@ -8,9 +8,15 @@
import hudson.triggers.TimerTrigger.TimerTriggerCause;
import hudson.views.BuildTrendFilter.StatusType;
import junit.framework.TestCase;
+import org.acegisecurity.context.SecurityContextHolder;
public class BuildTrendFilterTest extends TestCase {
+ @Override protected void setUp() throws Exception {
+ // Only necessary if run as part of the whole project:
+ SecurityContextHolder.getContext().setAuthentication(null);
+ }
+
public void testCauses() {
doTestCause(StatusType.Completed, null, false);
doTestCause(StatusType.Completed, new UserCause(), false);
Added: trunk/hudson/plugins/view-job-filters/src/test/java/hudson/views/RunLoadCounter.java (0 => 40967)
--- trunk/hudson/plugins/view-job-filters/src/test/java/hudson/views/RunLoadCounter.java (rev 0)
+++ trunk/hudson/plugins/view-job-filters/src/test/java/hudson/views/RunLoadCounter.java 2013-08-11 01:43:27 UTC (rev 40967)
@@ -0,0 +1,151 @@
+/*
+ * The MIT License
+ *
+ * Copyright 2013 Jesse Glick.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+package hudson.views;
+
+import hudson.Launcher;
+import hudson.model.AbstractBuild;
+import hudson.model.AbstractProject;
+import hudson.model.BuildListener;
+import hudson.model.Run;
+import hudson.model.RunAction;
+import hudson.tasks.BuildStepMonitor;
+import hudson.tasks.Notifier;
+import java.io.IOException;
+import java.util.concurrent.Callable;
+import java.util.concurrent.atomic.AtomicInteger;
+import org.kohsuke.accmod.Restricted;
+import org.kohsuke.accmod.restrictions.NoExternalUse;
+
+// TODO use official version when depending on 1.517+ or 1.509.3
+
+/**
+ * Utility to determine when a build record is loaded.
+ */
+@SuppressWarnings({"unchecked", "rawtypes"}) // API design mistakes
+public final class RunLoadCounter {
+
+ private static final ThreadLocal<String> currProject = new ThreadLocal<String>();
+ private static final ThreadLocal<AtomicInteger> currCount = new ThreadLocal<AtomicInteger>();
+
+ /**
+ * Prepares a new project to be measured.
+ * Call this <em>before</em> starting builds.
+ * @param project a project of any kind
+ * @throws IOException if preparations fail
+ */
+ public static void prepare(AbstractProject<?,?> project) throws IOException {
+ project.getPublishersList().add(new MarkerAdder());
+ }
+
+ /**
+ * Counts how many build records are loaded as a result of some task.
+ * @param project a project on which {@link #prepare} was called prior to creating builds
+ * @param thunk a task which is expected to load some build records
+ * @return how many build records were actually {@linkplain Run#onLoad loaded} as a result
+ */
+ public static int countLoads(AbstractProject<?,?> project, Runnable thunk) {
+ project._getRuns().purgeCache();
+ currProject.set(project.getFullName());
+ currCount.set(new AtomicInteger());
+ thunk.run();
+ return currCount.get().get();
+ }
+
+ /**
+ * Asserts that at most a certain number of build records are loaded as a result of some task.
+ * @param project a project on which {@link #prepare} was called prior to creating builds
+ * @param max the maximum number of build records we expect to load
+ * @param thunk a task which is expected to load some build records
+ * @return the result of the task, if any
+ * @throws Exception if the task failed
+ * @throws AssertionError if one more than max build record is loaded
+ * @param <T> the return value type
+ */
+ public static <T> T assertMaxLoads(AbstractProject<?,?> project, int max, Callable<T> thunk) throws Exception {
+ project._getRuns().purgeCache();
+ currProject.set(project.getFullName());
+ currCount.set(new AtomicInteger(-(max + 1)));
+ return thunk.call();
+ }
+
+ private RunLoadCounter() {}
+
+ /**
+ * Used internally.
+ */
+ @Restricted(NoExternalUse.class)
+ public static final class Marker implements RunAction {
+
+ private final String project;
+ private final int build;
+
+ Marker(String project, int build) {
+ this.project = project;
+ this.build = build;
+ }
+
+ @Override public void onLoad() {
+ if (project.equals(currProject.get())) {
+ System.err.println("loaded " + project + " #" + build);
+ assert currCount.get().incrementAndGet() != 0 : "too many build records loaded from " + project;
+ }
+ }
+
+ @Override public void onAttached(Run r) {}
+
+ @Override public void onBuildComplete() {}
+
+ @Override public String getIconFileName() {
+ return null;
+ }
+
+ @Override public String getDisplayName() {
+ return null;
+ }
+
+ @Override public String getUrlName() {
+ return null;
+ }
+
+ }
+
+ /**
+ * Used internally.
+ */
+ @Restricted(NoExternalUse.class)
+ public static final class MarkerAdder extends Notifier {
+
+ @Override public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListener listener) throws InterruptedException, IOException {
+ build.addAction(new Marker(build.getParent().getFullName(), build.getNumber()));
+ return true;
+ }
+
+ @Override public BuildStepMonitor getRequiredMonitorService() {
+ return BuildStepMonitor.NONE;
+ }
+
+ }
+
+}
Property changes on: trunk/hudson/plugins/view-job-filters/src/test/java/hudson/views/RunLoadCounter.java
___________________________________________________________________
Added: svn:mime-type
You received this message because you are subscribed to the Google Groups "Jenkins Commits" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.
