Esempio n. 1
0
  @Test
  public void testCompareRemoteRevisionWithAllExcluded() throws IOException, InterruptedException {
    CVSSCM scm =
        new CVSSCM(
            CVSROOT,
            "module",
            BRANCH,
            null,
            true,
            true,
            false,
            "src/main/web/.*\\.java\nsrc/main/web/.*\\.xml") {
          @Override
          List<String> update(
              ModuleLocation moduleLocation,
              boolean dryRun,
              Launcher launcher,
              FilePath workspace,
              TaskListener listener,
              Date date)
              throws IOException, InterruptedException {
            return newArrayList("src/main/web/pom.xml", "src/main/web/Test2.java");
          }

          @Override
          String isUpdatable(ModuleLocation location, FilePath dir)
              throws IOException, InterruptedException {
            return null;
          }
        };
    PollingResult result = scm.compareRemoteRevisionWith(null, null, null, null, null);
    assertEquals(result, PollingResult.NO_CHANGES);
  }
Esempio n. 2
0
  private boolean createTag(
      String tagName,
      TaskListener listener,
      File destdir,
      String moduleLocalDir,
      String module,
      boolean isFlatten)
      throws IOException, InterruptedException {
    FilePath path =
        (isFlatten
            ? new FilePath(destdir).child(module)
            : new FilePath(destdir).child(moduleLocalDir).child(module));
    boolean isDir = path.isDirectory();

    ArgumentListBuilder cmd = new ArgumentListBuilder();
    cmd.add(scmInstance.getDescriptor().getCvsExeOrDefault(), "tag");
    if (isDir) {
      cmd.add("-R");
    }
    cmd.add(tagName);
    if (!isDir) {
      cmd.add(path.getName());
      path = path.getParent();
    }

    if (!scmInstance.run(new Launcher.LocalLauncher(listener), cmd, listener, path)) {
      listener.getLogger().println(Messages.CVSSCM_TaggingFailed());
      return false;
    }
    return true;
  }
Esempio n. 3
0
 @Test
 public void testLegacy() {
   CVSSCM scm = new CVSSCM(CVSROOT, "module", BRANCH, null, true, true, false, null);
   // there are 1 modules, but enabled legacy mode
   assertFalse(scm.isFlatten());
   assertTrue(scm.isLegacy());
   assertEquals(scm.getModuleLocations().length, 1);
 }
Esempio n. 4
0
 @Test
 public void testLegacyGetModuleLocations() {
   CVSSCM scm = new CVSSCM(CVSROOT, MODULES, BRANCH, null, true, false, false, null);
   // there are 3 modules
   assertFalse(scm.isFlatten());
   assertTrue(scm.isLegacy());
   assertEquals(scm.getModuleLocations().length, 1);
 }
Esempio n. 5
0
  /** Performs tagging. */
  public void perform(String tagName, TaskListener listener) {
    File destdir = null;
    try {
      destdir = Util.createTempDir();

      // unzip the archive
      listener
          .getLogger()
          .println(hudson.scm.cvs.Messages.CVSSCM_ExpandingWorkspaceArchive(destdir));
      Expand e = new Expand();
      e.setProject(new org.apache.tools.ant.Project());
      e.setDest(destdir);
      e.setSrc(CVSSCM.getArchiveFile(build));
      e.setTaskType("unzip");
      e.execute();

      // run cvs tag command
      listener.getLogger().println(hudson.scm.cvs.Messages.CVSSCM_TaggingWorkspace());
      for (ModuleLocation moduleLocation : scmInstance.getModuleLocations()) {
        @SuppressWarnings("unchecked")
        ModuleLocation parametrizedLocation =
            new ParametrizedModuleLocationImpl(moduleLocation, build.getBuildVariables());
        for (String module : parametrizedLocation.getNormalizedModules()) {
          if (!createTag(
              tagName,
              listener,
              destdir,
              parametrizedLocation.getLocalDir(),
              module,
              scmInstance.isFlatten())) {
            return;
          }
        }
      }

      // completed successfully
      onTagCompleted(tagName);
      build.save();
    } catch (Throwable e) {
      e.printStackTrace(listener.fatalError(e.getMessage()));
    } finally {
      try {
        if (destdir != null) {
          listener.getLogger().println("cleaning up " + destdir);
          Util.deleteRecursive(destdir);
        }
      } catch (IOException e) {
        e.printStackTrace(listener.fatalError(e.getMessage()));
      }
    }
  }
Esempio n. 6
0
 @Test
 public void testGetModuleLocations() {
   CVSSCM scm =
       new CVSSCM(
           Arrays.asList(new ModuleLocationImpl(CVSROOT, MODULES, BRANCH, false, LOCAL_DIR)),
           null,
           true,
           false,
           null,
           false);
   // there are 3 modules
   assertFalse(scm.isFlatten());
   assertTrue(scm.isLegacy());
   assertEquals(scm.getModuleLocations().length, 1);
   assertEquals(scm.getAllModules().length, 3);
 }
Esempio n. 7
0
 @Test
 public void testRemoveInvalidEntries() {
   CVSSCM scm = new CVSSCM(null, MODULES, BRANCH, null, true, false, false, null);
   assertEquals(scm.getModuleLocations().length, 0);
 }