Search in sources :

Example 1 with ModifiedFile

use of com.thoughtworks.go.domain.materials.ModifiedFile in project gocd by gocd.

the class TfsSDKCommand method getModifiedFiles.

ArrayList<ModifiedFile> getModifiedFiles(Changeset changeset) {
    ArrayList<ModifiedFile> files = new ArrayList<>();
    for (Change change : changeset.getChanges()) {
        ModifiedFile modifiedFile = new ModifiedFile(change.getItem().getServerItem(), "", ModifiedAction.unknown);
        files.add(modifiedFile);
    }
    return files;
}
Also used : ArrayList(java.util.ArrayList) ModifiedFile(com.thoughtworks.go.domain.materials.ModifiedFile)

Example 2 with ModifiedFile

use of com.thoughtworks.go.domain.materials.ModifiedFile in project gocd by gocd.

the class GitCommandTest method shouldRetrieveLatestModificationFromBranch.

@Test
public void shouldRetrieveLatestModificationFromBranch() throws Exception {
    GitTestRepo branchedRepo = GitTestRepo.testRepoAtBranch(GIT_FOO_BRANCH_BUNDLE, BRANCH, temporaryFolder);
    GitCommand branchedGit = new GitCommand(null, createTempWorkingDirectory(), BRANCH, false, new HashMap<>(), null);
    branchedGit.clone(inMemoryConsumer(), branchedRepo.projectRepositoryUrl());
    Modification mod = branchedGit.latestModification().get(0);
    assertThat(mod.getUserName(), is("Chris Turner <cturner@thoughtworks.com>"));
    assertThat(mod.getComment(), is("Started foo branch"));
    assertThat(mod.getModifiedTime(), is(parseRFC822("Tue, 05 Feb 2009 14:28:08 -0800")));
    assertThat(mod.getRevision(), is("b4fa7271c3cef91822f7fa502b999b2eab2a380d"));
    List<ModifiedFile> files = mod.getModifiedFiles();
    assertThat(files.size(), is(1));
    assertThat(files.get(0).getFileName(), is("first.txt"));
    assertThat(files.get(0).getAction(), is(ModifiedAction.modified));
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) GitTestRepo(com.thoughtworks.go.domain.materials.git.GitTestRepo) ModifiedFile(com.thoughtworks.go.domain.materials.ModifiedFile) Test(org.junit.Test)

Example 3 with ModifiedFile

use of com.thoughtworks.go.domain.materials.ModifiedFile in project gocd by gocd.

the class SvnLogXmlParserTest method shouldGetAllModifiedFilesUnderRootPath.

@Test
public void shouldGetAllModifiedFilesUnderRootPath() {
    SvnLogXmlParser parser = new SvnLogXmlParser();
    List<Modification> materialRevisions = parser.parse(MULTIPLE_FILES, "", new SAXBuilder());
    Modification mod = materialRevisions.get(0);
    List<ModifiedFile> files = mod.getModifiedFiles();
    assertThat(files.size(), is(2));
    ModifiedFile file = files.get(0);
    assertThat(file.getFileName(), is("/trunk/revision3.txt"));
    assertThat(file.getAction(), is(ModifiedAction.added));
    file = files.get(1);
    assertThat(file.getFileName(), is("/branch/1.1/readme.txt"));
    assertThat(file.getAction(), is(ModifiedAction.deleted));
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) SAXBuilder(org.jdom2.input.SAXBuilder) ModifiedFile(com.thoughtworks.go.domain.materials.ModifiedFile) Test(org.junit.jupiter.api.Test)

Example 4 with ModifiedFile

use of com.thoughtworks.go.domain.materials.ModifiedFile in project gocd by gocd.

the class SvnLogXmlParserTest method shouldParse.

@Test
public void shouldParse() throws ParseException {
    SvnLogXmlParser parser = new SvnLogXmlParser();
    List<Modification> materialRevisions = parser.parse(XML, "", new SAXBuilder());
    assertThat(materialRevisions.size(), is(1));
    Modification mod = materialRevisions.get(0);
    assertThat(mod.getRevision(), is("3"));
    assertThat(mod.getUserName(), is("cceuser"));
    assertThat(mod.getModifiedTime(), is(convertDate("2008-03-11T07:52:41.162075Z")));
    assertThat(mod.getComment(), is("[Liyanhui & Gabbar] Checked in new file for test"));
    List<ModifiedFile> files = mod.getModifiedFiles();
    assertThat(files.size(), is(1));
    ModifiedFile file = files.get(0);
    assertThat(file.getFileName(), is("/trunk/revision3.txt"));
    assertThat(file.getAction(), is(ModifiedAction.added));
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) SAXBuilder(org.jdom2.input.SAXBuilder) ModifiedFile(com.thoughtworks.go.domain.materials.ModifiedFile) Test(org.junit.jupiter.api.Test)

Example 5 with ModifiedFile

use of com.thoughtworks.go.domain.materials.ModifiedFile in project gocd by gocd.

the class SvnLogXmlParserTest method shouldFilterModifiedFilesByPath.

@Test
public void shouldFilterModifiedFilesByPath() {
    SvnLogXmlParser parser = new SvnLogXmlParser();
    List<Modification> materialRevisions = parser.parse(MULTIPLE_FILES, "/branch", new SAXBuilder());
    Modification mod = materialRevisions.get(0);
    List<ModifiedFile> files = mod.getModifiedFiles();
    assertThat(files.size(), is(1));
    ModifiedFile file = files.get(0);
    assertThat(file.getFileName(), is("/branch/1.1/readme.txt"));
    assertThat(file.getAction(), is(ModifiedAction.deleted));
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) SAXBuilder(org.jdom2.input.SAXBuilder) ModifiedFile(com.thoughtworks.go.domain.materials.ModifiedFile) Test(org.junit.jupiter.api.Test)

Aggregations

ModifiedFile (com.thoughtworks.go.domain.materials.ModifiedFile)12 Modification (com.thoughtworks.go.domain.materials.Modification)10 Test (org.junit.jupiter.api.Test)8 ArrayList (java.util.ArrayList)3 Date (java.util.Date)3 SAXBuilder (org.jdom2.input.SAXBuilder)3 MaterialInstance (com.thoughtworks.go.domain.MaterialInstance)2 Test (org.junit.Test)2 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)1 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)1 GitMaterial (com.thoughtworks.go.config.materials.git.GitMaterial)1 XmlWriterContext (com.thoughtworks.go.domain.XmlWriterContext)1 Modifications (com.thoughtworks.go.domain.materials.Modifications)1 DependencyMaterialRevision (com.thoughtworks.go.domain.materials.dependency.DependencyMaterialRevision)1 GitTestRepo (com.thoughtworks.go.domain.materials.git.GitTestRepo)1 TimeProvider (com.thoughtworks.go.util.TimeProvider)1 ConsoleResult (com.thoughtworks.go.util.command.ConsoleResult)1 Element (org.dom4j.Element)1