Search in sources :

Example 41 with Modification

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

the class ModificationsMother method multipleModificationList.

public static List<Modification> multipleModificationList(RevisionToUse revisionToUse) {
    Modification modification1 = new Modification(MOD_USER, MOD_COMMENT, EMAIL_ADDRESS, TWO_DAYS_AGO_CHECKIN, revisionToUse.next());
    modification1.createModifiedFile(MOD_FILE_BUILD_XML, "\\build", MOD_MODIFIED_ACTION);
    Modification modification2 = new Modification(MOD_USER_COMMITTER, MOD_COMMENT_2, EMAIL_ADDRESS, YESTERDAY_CHECKIN, revisionToUse.next());
    modification2.createModifiedFile(MOD_FILE_OLD_BUILD_XML, "\\build", MOD_MODIFIED_ACTION);
    Modification modification3 = new Modification(MOD_USER_WITH_HTML_CHAR, MOD_COMMENT_3, EMAIL_ADDRESS, TODAY_CHECKIN, revisionToUse.next());
    modification3.createModifiedFile(MOD_FILE_READ_ME, "\\build", MOD_MODIFIED_ACTION);
    List<Modification> modifications = new ArrayList<>();
    modifications.add(modification3);
    modifications.add(modification2);
    modifications.add(modification1);
    return modifications;
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification)

Example 42 with Modification

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

the class ModificationsMother method modifyOneFile.

public static MaterialRevisions modifyOneFile(Materials materials, String revision, String comment, String committer) {
    MaterialRevisions materialRevisions = new MaterialRevisions();
    Materials expandedMaterials = new Materials();
    for (Material material : materials) {
        expandedMaterials.add(material);
    }
    for (Material material : expandedMaterials) {
        Modification modification;
        if (material instanceof DependencyMaterial) {
            DependencyMaterial dependencyMaterial = (DependencyMaterial) material;
            modification = oneModifiedFile(committer, dependencyMaterial.getPipelineName() + "/1/" + dependencyMaterial.getStageName() + "/" + revision, TWO_DAYS_AGO_CHECKIN, dependencyMaterial.getPipelineName() + "-1.2.3");
        } else {
            modification = oneModifiedFile(committer, revision, comment, TWO_DAYS_AGO_CHECKIN);
        }
        materialRevisions.addRevision(new MaterialRevision(material, true, modification));
    }
    return materialRevisions;
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) Materials(com.thoughtworks.go.config.materials.Materials) Material(com.thoughtworks.go.domain.materials.Material) DependencyMaterial(com.thoughtworks.go.config.materials.dependency.DependencyMaterial) SvnMaterial(com.thoughtworks.go.config.materials.svn.SvnMaterial) DependencyMaterial(com.thoughtworks.go.config.materials.dependency.DependencyMaterial) DependencyMaterialRevision(com.thoughtworks.go.domain.materials.dependency.DependencyMaterialRevision) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision)

Example 43 with Modification

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

the class StageConverter method createBuildCause.

private ArrayList<StageNotificationDTO.MaterialRevisionDTO> createBuildCause(BuildCause buildCause) {
    ArrayList<StageNotificationDTO.MaterialRevisionDTO> revisions = new ArrayList<>();
    for (MaterialRevision currentRevision : buildCause.getMaterialRevisions()) {
        Map<String, Object> attributes = currentRevision.getMaterial().getAttributes(false);
        ArrayList<StageNotificationDTO.ModificationDTO> modifications = new ArrayList<>();
        for (Modification modification : currentRevision.getModifications()) {
            modifications.add(new StageNotificationDTO.ModificationDTO(modification.getRevision(), modification.getModifiedTime(), modification.getAdditionalDataMap()));
        }
        revisions.add(new StageNotificationDTO.MaterialRevisionDTO(attributes, currentRevision.isChanged(), modifications));
    }
    return revisions;
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) ArrayList(java.util.ArrayList) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision)

Example 44 with Modification

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

the class DependencyMaterialRevision method convert.

/**
 * @deprecated used only in tests
 */
public MaterialRevision convert(Material material, Date modifiedTime) {
    ArrayList<Modification> modifications = new ArrayList<>();
    modifications.add(new Modification(modifiedTime, getRevision(), getPipelineLabel(), null));
    return new MaterialRevision(material, modifications);
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) ArrayList(java.util.ArrayList) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision)

Example 45 with Modification

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

the class GitCommand method gitLog.

private List<Modification> gitLog(String... args) {
    // Git log will only show changes before the currently checked out revision
    InMemoryStreamConsumer outputStreamConsumer = inMemoryConsumer();
    try {
        if (!isSubmodule) {
            fetch(outputStreamConsumer);
        }
    } catch (Exception e) {
        throw new RuntimeException(String.format("Working directory: %s\n%s", workingDir, outputStreamConsumer.getStdError()), e);
    }
    CommandLine gitCmd = git(environment).withArg("log").withArgs(args).withWorkingDir(workingDir);
    ConsoleResult result = runOrBomb(gitCmd);
    GitModificationParser parser = new GitModificationParser();
    List<Modification> mods = parser.parse(result.output());
    for (Modification mod : mods) {
        addModifiedFiles(mod);
    }
    return mods;
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification)

Aggregations

Modification (com.thoughtworks.go.domain.materials.Modification)246 Test (org.junit.Test)176 Date (java.util.Date)76 MaterialRevision (com.thoughtworks.go.domain.MaterialRevision)65 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)54 DependencyMaterial (com.thoughtworks.go.config.materials.dependency.DependencyMaterial)40 MaterialRevisions (com.thoughtworks.go.domain.MaterialRevisions)38 ArrayList (java.util.ArrayList)35 File (java.io.File)25 BuildCause (com.thoughtworks.go.domain.buildcause.BuildCause)21 Modifications (com.thoughtworks.go.domain.materials.Modifications)21 SvnMaterial (com.thoughtworks.go.config.materials.svn.SvnMaterial)20 Material (com.thoughtworks.go.domain.materials.Material)20 Username (com.thoughtworks.go.server.domain.Username)17 StringRevision (com.thoughtworks.go.domain.materials.mercurial.StringRevision)16 HashMap (java.util.HashMap)16 StringContains.containsString (org.hamcrest.core.StringContains.containsString)15 DependencyMaterialRevision (com.thoughtworks.go.domain.materials.dependency.DependencyMaterialRevision)14 Stage (com.thoughtworks.go.domain.Stage)13 ModifiedFile (com.thoughtworks.go.domain.materials.ModifiedFile)13