提交 7b0d9086 编写于 作者: D dodok1

[FIXED HUDSON-2488] affectedPaths are computed correctly to MavenModule relativePaths

git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@18223 71c3de6d-444a-0410-be80-ed276b4c234a
上级 5951d7a9
......@@ -26,6 +26,8 @@ package hudson.scm;
import hudson.model.AbstractBuild;
import hudson.model.User;
import hudson.scm.SubversionChangeLogSet.LogEntry;
import hudson.scm.SubversionSCM.ModuleLocation;
import org.kohsuke.stapler.export.Exported;
import org.kohsuke.stapler.export.ExportedBean;
......@@ -154,13 +156,48 @@ public final class SubversionChangeLogSet extends ChangeLogSet<LogEntry> {
public Collection<String> getAffectedPaths() {
return new AbstractList<String>() {
public String get(int index) {
return paths.get(index).value;
return preparePath(paths.get(index).value);
}
public int size() {
return paths.size();
}
};
}
private String preparePath(String path) {
SubversionSCM scm = (SubversionSCM) getParent().build.getProject().getScm();
ModuleLocation[] locations = scm.getLocations();
for (int i = 0; i < locations.length; i++) {
String commonPart = findCommonPart(locations[i].remote, path);
if (commonPart != null) {
if (path.startsWith("/")) {
path = path.substring(1);
}
String newPath = path.substring(commonPart.length());
if (newPath.startsWith("/")) {
newPath = newPath.substring(1);
}
return newPath;
}
}
return path;
}
private String findCommonPart(String folder, String filePath) {
if (folder == null || filePath == null) {
return null;
}
if (filePath.startsWith("/")) {
filePath = filePath.substring(1);
}
for (int i = 0; i < folder.length(); i++) {
String part = folder.substring(i);
if (filePath.startsWith(part)) {
return part;
}
}
return null;
}
public void setUser(String author) {
this.author = User.get(author);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册