Search in sources :

Example 86 with ScmFile

use of org.apache.maven.scm.ScmFile in project maven-scm by apache.

the class GitDiffConsumerTest method testLog2Consumer.

public void testLog2Consumer() throws Exception {
    GitDiffConsumer consumer = new GitDiffConsumer(new DefaultLog(), null);
    File f = getTestFile("src/test/resources/git/diff/git-diff2.log");
    BufferedReader r = new BufferedReader(new FileReader(f));
    String line;
    while ((line = r.readLine()) != null) {
        consumer.consumeLine(line);
    }
    List<ScmFile> changedFiles = consumer.getChangedFiles();
    assertEquals(2, changedFiles.size());
    testScmFile(changedFiles.get(0), "pom.xml", ScmFileStatus.MODIFIED);
    testScmFile(changedFiles.get(1), "test.txt", ScmFileStatus.MODIFIED);
    Map<String, CharSequence> differences = consumer.getDifferences();
    assertNotNull(differences);
    StringBuilder addDiffs = new StringBuilder(differences.get("pom.xml"));
    assertNotNull(addDiffs);
    assertTrue(addDiffs.indexOf("+  <!-- test -->") >= 0);
    addDiffs = new StringBuilder(differences.get("test.txt"));
    assertNotNull(addDiffs);
    assertTrue(addDiffs.indexOf("+maven-scm git provider works fine :-)") >= 0);
}
Also used : DefaultLog(org.apache.maven.scm.log.DefaultLog) BufferedReader(java.io.BufferedReader) FileReader(java.io.FileReader) ScmFile(org.apache.maven.scm.ScmFile) File(java.io.File) ScmFile(org.apache.maven.scm.ScmFile)

Example 87 with ScmFile

use of org.apache.maven.scm.ScmFile in project maven-scm by apache.

the class GitDiffConsumerTest method testLog1Consumer.

public void testLog1Consumer() throws Exception {
    GitDiffConsumer consumer = new GitDiffConsumer(new DefaultLog(), null);
    File f = getTestFile("src/test/resources/git/diff/git-diff1.log");
    BufferedReader r = new BufferedReader(new FileReader(f));
    String line;
    while ((line = r.readLine()) != null) {
        consumer.consumeLine(line);
    }
    List<ScmFile> changedFiles = consumer.getChangedFiles();
    assertEquals(1, changedFiles.size());
    testScmFile((ScmFile) changedFiles.get(0), "olamy.test", ScmFileStatus.MODIFIED);
    Map<String, CharSequence> differences = consumer.getDifferences();
    assertNotNull(differences);
    StringBuilder readmeDiffs = new StringBuilder(differences.get("olamy.test"));
    assertNotNull(readmeDiffs);
    assertTrue(readmeDiffs.indexOf("+new line") >= 0);
}
Also used : DefaultLog(org.apache.maven.scm.log.DefaultLog) BufferedReader(java.io.BufferedReader) FileReader(java.io.FileReader) ScmFile(org.apache.maven.scm.ScmFile) File(java.io.File) ScmFile(org.apache.maven.scm.ScmFile)

Example 88 with ScmFile

use of org.apache.maven.scm.ScmFile in project maven-scm by apache.

the class PerforceTagConsumerTest method testGoodParse.

public void testGoodParse() throws Exception {
    File testFile = getTestFile("src/test/resources/perforce/tag_good.txt");
    PerforceTagConsumer consumer = new PerforceTagConsumer();
    FileInputStream fis = new FileInputStream(testFile);
    BufferedReader in = new BufferedReader(new InputStreamReader(fis));
    String s = in.readLine();
    while (s != null) {
        consumer.consumeLine(s);
        s = in.readLine();
    }
    assertEquals("", consumer.getOutput());
    assertTrue(consumer.isSuccess());
    List<ScmFile> results = consumer.getTagged();
    assertEquals("Wrong number of entries returned", 2, results.size());
    String entry = results.get(0).getPath();
    assertTrue(entry.endsWith("pom.xml"));
}
Also used : InputStreamReader(java.io.InputStreamReader) BufferedReader(java.io.BufferedReader) ScmFile(org.apache.maven.scm.ScmFile) File(java.io.File) FileInputStream(java.io.FileInputStream) ScmFile(org.apache.maven.scm.ScmFile)

Example 89 with ScmFile

use of org.apache.maven.scm.ScmFile in project maven-scm by apache.

the class PerforceUnEditConsumerTest method testGoodParse.

public void testGoodParse() throws Exception {
    File testFile = getTestFile("src/test/resources/perforce/unedit_good.txt");
    PerforceUnEditConsumer consumer = new PerforceUnEditConsumer();
    FileInputStream fis = new FileInputStream(testFile);
    BufferedReader in = new BufferedReader(new InputStreamReader(fis));
    String s = in.readLine();
    while (s != null) {
        consumer.consumeLine(s);
        s = in.readLine();
    }
    assertTrue(consumer.isSuccess());
    List<ScmFile> edits = consumer.getEdits();
    assertEquals("Wrong number of entries returned", 2, edits.size());
    String entry = edits.get(0).getPath();
    assertTrue(entry.startsWith("//"));
    assertTrue(entry.endsWith(".classpath"));
}
Also used : InputStreamReader(java.io.InputStreamReader) BufferedReader(java.io.BufferedReader) ScmFile(org.apache.maven.scm.ScmFile) File(java.io.File) FileInputStream(java.io.FileInputStream) ScmFile(org.apache.maven.scm.ScmFile)

Example 90 with ScmFile

use of org.apache.maven.scm.ScmFile in project maven-scm by apache.

the class SynergyCheckOutCommand method executeCheckOutCommand.

/**
 * {@inheritDoc}
 */
protected CheckOutScmResult executeCheckOutCommand(ScmProviderRepository repository, ScmFileSet fileSet, ScmVersion version, boolean recursive, boolean shallow) throws ScmException {
    if (fileSet.getFileList().size() != 0) {
        throw new ScmException("This provider doesn't support checking out subsets of a project");
    }
    if (getLogger().isDebugEnabled()) {
        getLogger().debug("executing checkout command...");
    }
    SynergyScmProviderRepository repo = (SynergyScmProviderRepository) repository;
    if (getLogger().isDebugEnabled()) {
        getLogger().debug(fileSet.toString());
    }
    String ccmAddr = SynergyUtil.start(getLogger(), repo.getUser(), repo.getPassword(), null);
    File waPath;
    try {
        String projectSpec = SynergyUtil.getWorkingProject(getLogger(), repo.getProjectSpec(), repo.getUser(), ccmAddr);
        if (projectSpec != null) {
            if (getLogger().isInfoEnabled()) {
                getLogger().info("A working project already exists [" + projectSpec + "].");
            }
            SynergyUtil.synchronize(getLogger(), projectSpec, ccmAddr);
        } else {
            SynergyUtil.checkoutProject(getLogger(), null, repo.getProjectSpec(), version, repo.getProjectPurpose(), repo.getProjectRelease(), ccmAddr);
            projectSpec = SynergyUtil.getWorkingProject(getLogger(), repo.getProjectSpec(), repo.getUser(), ccmAddr);
            if (getLogger().isInfoEnabled()) {
                getLogger().info("A new working project [" + projectSpec + "] was created.");
            }
        }
        SynergyUtil.reconfigure(getLogger(), projectSpec, ccmAddr);
        waPath = SynergyUtil.getWorkArea(getLogger(), projectSpec, ccmAddr);
    } finally {
        SynergyUtil.stop(getLogger(), ccmAddr);
    }
    File source = new File(waPath, repo.getProjectName());
    if (getLogger().isInfoEnabled()) {
        getLogger().info("We will now copy files from Synergy Work Area [" + source + "] to expected folder [" + fileSet.getBasedir() + "]");
    }
    // Move files to the expected folder
    try {
        FileUtils.copyDirectoryStructure(source, fileSet.getBasedir());
    } catch (IOException e1) {
        throw new ScmException("Unable to copy directory structure", e1);
    }
    if (getLogger().isDebugEnabled()) {
        getLogger().debug("We will list content of checkout directory.");
    }
    // We need to list files in the directory
    List<ScmFile> files = new ArrayList<ScmFile>();
    try {
        @SuppressWarnings("unchecked") List<File> realFiles = FileUtils.getFiles(fileSet.getBasedir(), null, "_ccmwaid.inf");
        for (File f : realFiles) {
            files.add(new ScmFile(f.getPath(), ScmFileStatus.CHECKED_OUT));
        }
    } catch (IOException e) {
        throw new ScmException("Unable to list files in checkout directory", e);
    }
    if (getLogger().isDebugEnabled()) {
        getLogger().debug("checkout command end successfully ...");
    }
    return new CheckOutScmResult(files, new ScmResult("multiple commandline", "OK", "OK", true));
}
Also used : ScmException(org.apache.maven.scm.ScmException) SynergyScmProviderRepository(org.apache.maven.scm.provider.synergy.repository.SynergyScmProviderRepository) CheckOutScmResult(org.apache.maven.scm.command.checkout.CheckOutScmResult) ScmResult(org.apache.maven.scm.ScmResult) ArrayList(java.util.ArrayList) CheckOutScmResult(org.apache.maven.scm.command.checkout.CheckOutScmResult) IOException(java.io.IOException) ScmFile(org.apache.maven.scm.ScmFile) File(java.io.File) ScmFile(org.apache.maven.scm.ScmFile)

Aggregations

ScmFile (org.apache.maven.scm.ScmFile)198 File (java.io.File)102 ArrayList (java.util.ArrayList)51 ScmException (org.apache.maven.scm.ScmException)34 BufferedReader (java.io.BufferedReader)21 DefaultLog (org.apache.maven.scm.log.DefaultLog)20 ScmFileStatus (org.apache.maven.scm.ScmFileStatus)19 ScmFileSet (org.apache.maven.scm.ScmFileSet)17 InputStreamReader (java.io.InputStreamReader)16 ScmResult (org.apache.maven.scm.ScmResult)15 StatusScmResult (org.apache.maven.scm.command.status.StatusScmResult)15 IOException (java.io.IOException)14 CheckInScmResult (org.apache.maven.scm.command.checkin.CheckInScmResult)13 Matcher (java.util.regex.Matcher)11 AddScmResult (org.apache.maven.scm.command.add.AddScmResult)11 CheckOutScmResult (org.apache.maven.scm.command.checkout.CheckOutScmResult)10 UpdateScmResult (org.apache.maven.scm.command.update.UpdateScmResult)10 Commandline (org.codehaus.plexus.util.cli.Commandline)10 SynergyScmProviderRepository (org.apache.maven.scm.provider.synergy.repository.SynergyScmProviderRepository)9 FileInputStream (java.io.FileInputStream)8