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

Making reverse migration tool handle more kinds of item groups.

上级 0a9b6382
...@@ -293,15 +293,21 @@ public final class RunIdMigrator { ...@@ -293,15 +293,21 @@ public final class RunIdMigrator {
unmigrateJobsDir(jobs); unmigrateJobsDir(jobs);
} }
private static void unmigrateJobsDir(File jobs) throws Exception { private static void unmigrateJobsDir(File jobs) throws Exception {
System.err.println(jobs + " will be inspected for build directories to restore"); for (File job : jobs.listFiles()) {
for (File kid : jobs.listFiles()) { File[] kids = job.listFiles();
File builds = new File(kid, "builds"); if (kids == null) {
if (builds.isDirectory()) { // kid is a job continue;
unmigrateBuildsDir(builds);
} }
File jobs2 = new File(kid, "jobs"); for (File kid : kids) {
if (jobs2.isDirectory()) { // kid is a folder if (!kid.isDirectory()) {
unmigrateJobsDir(jobs2); 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 { ...@@ -96,7 +96,7 @@ public class RunIdMigratorTest {
@Test public void reverseImmediately() throws Exception { @Test public void reverseImmediately() throws Exception {
File root = dir; 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>"); 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("lastFailedBuild", "-1");
link("lastSuccessfulBuild", "99"); link("lastSuccessfulBuild", "99");
...@@ -108,7 +108,7 @@ public class RunIdMigratorTest { ...@@ -108,7 +108,7 @@ public class RunIdMigratorTest {
@Test public void reverseAfterNewBuilds() throws Exception { @Test public void reverseAfterNewBuilds() throws Exception {
File root = dir; 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("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", ""); 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()); 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.
先完成此消息的编辑!
想要评论请 注册