mirror of
https://github.com/jenkinsci/jenkins.git
synced 2026-11-11 19:16:42 +00:00
pushing down the dependency change set feature.
git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@2007 71c3de6d-444a-0410-be80-ed276b4c234a
This commit is contained in:
1 parent
407fd9adb8
commit
1837fc4a10
2 files changed
+61
-60
No files matched your search
@@ -3,6 +3,7 @@ package hudson.model;
|
||||
import hudson.Launcher;
|
||||
import hudson.Proc.LocalProc;
|
||||
import hudson.Util;
|
||||
import hudson.tasks.Fingerprinter.FingerprintAction;
|
||||
import hudson.maven.MavenBuild;
|
||||
import static hudson.model.Hudson.isWindows;
|
||||
import hudson.model.listeners.SCMListener;
|
||||
@@ -23,6 +24,7 @@ import java.io.PrintStream;
|
||||
import java.util.Calendar;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import java.util.Collections;
|
||||
|
||||
/**
|
||||
* Base implementation of {@link Run}s that build software.
|
||||
@@ -287,6 +289,65 @@ public abstract class AbstractBuild<P extends AbstractProject<P,R>,R extends Abs
|
||||
return r;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the changes in the dependency between the given build and this build.
|
||||
*/
|
||||
public Map<AbstractProject,DependencyChange> getDependencyChanges(AbstractBuild from) {
|
||||
if(from==null) return Collections.emptyMap(); // make it easy to call this from views
|
||||
FingerprintAction n = this.getAction(FingerprintAction.class);
|
||||
FingerprintAction o = from.getAction(FingerprintAction.class);
|
||||
if(n==null || o==null) return Collections.emptyMap();
|
||||
|
||||
Map<AbstractProject,Integer> ndep = n.getDependencies();
|
||||
Map<AbstractProject,Integer> odep = o.getDependencies();
|
||||
|
||||
Map<AbstractProject,DependencyChange> r = new HashMap<AbstractProject,DependencyChange>();
|
||||
|
||||
for (Map.Entry<AbstractProject,Integer> entry : odep.entrySet()) {
|
||||
AbstractProject p = entry.getKey();
|
||||
Integer oldNumber = entry.getValue();
|
||||
Integer newNumber = ndep.get(p);
|
||||
if(newNumber!=null && oldNumber.compareTo(newNumber)<0) {
|
||||
r.put(p,new DependencyChange(p,oldNumber,newNumber));
|
||||
}
|
||||
}
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a change in the dependency.
|
||||
*/
|
||||
public static final class DependencyChange {
|
||||
/**
|
||||
* The dependency project.
|
||||
*/
|
||||
public final AbstractProject project;
|
||||
/**
|
||||
* Version of the dependency project used in the previous build.
|
||||
*/
|
||||
public final int fromId;
|
||||
/**
|
||||
* {@link Build} object for {@link #fromId}. Can be null if the log is gone.
|
||||
*/
|
||||
public final AbstractBuild from;
|
||||
/**
|
||||
* Version of the dependency project used in this build.
|
||||
*/
|
||||
public final int toId;
|
||||
|
||||
public final AbstractBuild to;
|
||||
|
||||
public DependencyChange(AbstractProject<?,?> project, int fromId, int toId) {
|
||||
this.project = project;
|
||||
this.fromId = fromId;
|
||||
this.toId = toId;
|
||||
this.from = project.getBuildByNumber(fromId);
|
||||
this.to = project.getBuildByNumber(toId);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
//
|
||||
// web methods
|
||||
|
||||
@@ -15,8 +15,6 @@ import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -86,64 +84,6 @@ public final class Build extends AbstractBuild<Project,Build> {
|
||||
return n;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the changes in the dependency between the given build and this build.
|
||||
*/
|
||||
public Map<Project,DependencyChange> getDependencyChanges(Build from) {
|
||||
if(from==null) return Collections.emptyMap(); // make it easy to call this from views
|
||||
FingerprintAction n = this.getAction(FingerprintAction.class);
|
||||
FingerprintAction o = from.getAction(FingerprintAction.class);
|
||||
if(n==null || o==null) return Collections.emptyMap();
|
||||
|
||||
Map<Project,Integer> ndep = n.getDependencies();
|
||||
Map<Project,Integer> odep = o.getDependencies();
|
||||
|
||||
Map<Project,DependencyChange> r = new HashMap<Project,DependencyChange>();
|
||||
|
||||
for (Map.Entry<Project,Integer> entry : odep.entrySet()) {
|
||||
Project p = entry.getKey();
|
||||
Integer oldNumber = entry.getValue();
|
||||
Integer newNumber = ndep.get(p);
|
||||
if(newNumber!=null && oldNumber.compareTo(newNumber)<0) {
|
||||
r.put(p,new DependencyChange(p,oldNumber,newNumber));
|
||||
}
|
||||
}
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a change in the dependency.
|
||||
*/
|
||||
public static final class DependencyChange {
|
||||
/**
|
||||
* The dependency project.
|
||||
*/
|
||||
public final Project project;
|
||||
/**
|
||||
* Version of the dependency project used in the previous build.
|
||||
*/
|
||||
public final int fromId;
|
||||
/**
|
||||
* {@link Build} object for {@link #fromId}. Can be null if the log is gone.
|
||||
*/
|
||||
public final Build from;
|
||||
/**
|
||||
* Version of the dependency project used in this build.
|
||||
*/
|
||||
public final int toId;
|
||||
|
||||
public final Build to;
|
||||
|
||||
public DependencyChange(Project project, int fromId, int toId) {
|
||||
this.project = project;
|
||||
this.fromId = fromId;
|
||||
this.toId = toId;
|
||||
this.from = project.getBuildByNumber(fromId);
|
||||
this.to = project.getBuildByNumber(toId);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* During the build this field remembers {@link Environment}s created by
|
||||
* {@link BuildWrapper}. This design is bit ugly but forced due to compatibility.
|
||||
|
||||
Reference in new issue
Block a user