@Before
 public void createGitRepository() throws IOException, InterruptedException {
   tempAllocator = new TemporaryDirectoryAllocator();
   testGitDir = tempAllocator.allocate();
   TaskListener listener = StreamTaskListener.fromStderr();
   testGitClient = Git.with(listener, new EnvVars()).in(testGitDir).getClient();
   testGitClient.init();
 }
 @Before
 public void setUp() throws Exception {
   try {
     listener = StreamTaskListener.fromStderr();
     File file = temporaryFolder.getRoot();
     testRepo = new TestIntegrityRepo("unnamed", file, listener);
     name1 = testRepo.userName1;
     name2 = testRepo.userName2;
     workDir = testRepo.IntegrityDir;
     workspace = testRepo.IntegrityDirPath;
   } catch (Throwable e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
   }
 }
Beispiel #3
0
 /** Inverse of {@link #doMigrate}. */
 private void unmigrateBuildsDir(File builds) throws Exception {
   File mapFile = new File(builds, MAP_FILE);
   if (!mapFile.isFile()) {
     System.err.println(builds + " does not look to have been migrated yet; skipping");
     return;
   }
   for (File build : builds.listFiles()) {
     int number;
     try {
       number = Integer.parseInt(build.getName());
     } catch (NumberFormatException x) {
       continue;
     }
     File buildXml = new File(build, "build.xml");
     if (!buildXml.isFile()) {
       System.err.println(buildXml + " did not exist");
       continue;
     }
     String xml = FileUtils.readFileToString(buildXml, Charsets.UTF_8);
     Matcher m = TIMESTAMP_ELT.matcher(xml);
     if (!m.find()) {
       System.err.println(buildXml + " did not contain <timestamp> as expected");
       continue;
     }
     long timestamp = Long.parseLong(m.group(1));
     String nl = m.group(2);
     xml = m.replaceFirst("  <number>" + number + "</number>" + nl);
     m = ID_ELT.matcher(xml);
     String id;
     if (m.find()) {
       id = m.group(1);
       xml = m.replaceFirst("");
     } else {
       // Post-migration build. We give it a new ID based on its timestamp.
       id = legacyIdFormatter.format(new Date(timestamp));
     }
     FileUtils.write(buildXml, xml, Charsets.UTF_8);
     if (!build.renameTo(new File(builds, id))) {
       System.err.println(build + " could not be renamed");
     }
     Util.createSymlink(builds, id, Integer.toString(number), StreamTaskListener.fromStderr());
   }
   Util.deleteFile(mapFile);
   System.err.println(builds + " has been restored to its original format");
 }