提交 589d74a5 编写于 作者: J Jesse Glick

Making reverse migration tool handle more kinds of item groups.

上级 0a9b6382
......@@ -293,15 +293,21 @@ public final class RunIdMigrator {
unmigrateJobsDir(jobs);
}
private static void unmigrateJobsDir(File jobs) throws Exception {
System.err.println(jobs + " will be inspected for build directories to restore");
for (File kid : jobs.listFiles()) {
File builds = new File(kid, "builds");
if (builds.isDirectory()) { // kid is a job
unmigrateBuildsDir(builds);
for (File job : jobs.listFiles()) {
File[] kids = job.listFiles();
if (kids == null) {
continue;
}
File jobs2 = new File(kid, "jobs");
if (jobs2.isDirectory()) { // kid is a folder
unmigrateJobsDir(jobs2);
for (File kid : kids) {
if (!kid.isDirectory()) {
continue;
}
if (kid.getName().equals("builds")) {
unmigrateBuildsDir(kid);
} else {
// Might be jobs, modules, promotions, etc.; we assume an ItemGroup.getRootDirFor implementation returns grandchildren.
unmigrateJobsDir(kid);
}
}
}
}
......
......@@ -96,7 +96,7 @@ public class RunIdMigratorTest {
@Test public void reverseImmediately() throws Exception {
File root = dir;
dir = new File(dir, "jobs/somefolder/jobs/someproject/builds");
dir = new File(dir, "jobs/somefolder/jobs/someproject/promotions/OK/builds");
write("99/build.xml", "<?xml version='1.0' encoding='UTF-8'?>\n<run>\n <stuff>ok</stuff>\n <id>2014-01-02_03-04-05</id>\n <timestamp>1388649845000</timestamp>\n <otherstuff>ok</otherstuff>\n</run>");
link("lastFailedBuild", "-1");
link("lastSuccessfulBuild", "99");
......@@ -108,7 +108,7 @@ public class RunIdMigratorTest {
@Test public void reverseAfterNewBuilds() throws Exception {
File root = dir;
dir = new File(dir, "jobs/someproject/builds");
dir = new File(dir, "jobs/someproject/modules/test$test/builds");
write("1/build.xml", "<?xml version='1.0' encoding='UTF-8'?>\n<run>\n <stuff>ok</stuff>\n <timestamp>1388649845000</timestamp>\n <otherstuff>ok</otherstuff>\n</run>");
write("legacyIds", "");
assertEquals("{1={build.xml='<?xml version='1.0' encoding='UTF-8'?>\n<run>\n <stuff>ok</stuff>\n <timestamp>1388649845000</timestamp>\n <otherstuff>ok</otherstuff>\n</run>'}, legacyIds=''}", summarize());
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册