use of com.thoughtworks.go.domain.materials.git.GitTestRepo in project gocd by gocd.
the class GitMaterialTest method setup.
@Before
public void setup() throws Exception {
temporaryFolder.create();
GitTestRepo gitRepo = new GitTestRepo(temporaryFolder);
outputStreamConsumer = inMemoryConsumer();
workingDir = temporaryFolder.newFolder("workingDir-" + System.currentTimeMillis());
repositoryUrl = gitRepo.projectRepositoryUrl();
git = new GitMaterial(repositoryUrl);
gitFooBranchBundle = GitTestRepo.testRepoAtBranch(GIT_FOO_BRANCH_BUNDLE, BRANCH, temporaryFolder);
}
use of com.thoughtworks.go.domain.materials.git.GitTestRepo in project gocd by gocd.
the class GitMaterialTest method shouldGetLatestModificationFromBranch.
@Test
public void shouldGetLatestModificationFromBranch() throws Exception {
GitTestRepo branchedTestRepo = GitTestRepo.testRepoAtBranch(GIT_FOO_BRANCH_BUNDLE, BRANCH, temporaryFolder);
GitMaterial branchedGit = new GitMaterial(branchedTestRepo.projectRepositoryUrl(), BRANCH);
List<Modification> modifications = branchedGit.latestModification(temporaryFolder.newFolder(), new TestSubprocessExecutionContext());
assertThat(modifications.size(), is(1));
assertThat(modifications.get(0).getComment(), Matchers.is("Started foo branch"));
}
use of com.thoughtworks.go.domain.materials.git.GitTestRepo in project gocd by gocd.
the class BuildCauseProducerServiceConfigRepoIntegrationTest method shouldReloadPipelineConfigurationAndUpdateNewMaterialWhenManuallyTriggered.
@Test
public void shouldReloadPipelineConfigurationAndUpdateNewMaterialWhenManuallyTriggered() throws Exception {
GitTestRepo otherGitRepo = new GitTestRepo(temporaryFolder);
pipelineConfig = PipelineConfigMother.createPipelineConfigWithStages("pipe1", "build", "test");
pipelineConfig.materialConfigs().clear();
materialConfig = hgRepo.createMaterialConfig("dest1");
materialConfig.setAutoUpdate(true);
pipelineConfig.materialConfigs().add(materialConfig);
// new material is added
GitMaterial gitMaterial = otherGitRepo.createMaterial("dest2");
gitMaterial.setAutoUpdate(true);
MaterialConfig otherMaterialConfig = gitMaterial.config();
otherMaterialConfig.setAutoUpdate(true);
pipelineConfig.materialConfigs().add(otherMaterialConfig);
List<Modification> mod = configTestRepo.addPipelineToRepositoryAndPush(fileName, pipelineConfig);
final HashMap<String, String> revisions = new HashMap<>();
final HashMap<String, String> environmentVariables = new HashMap<>();
buildCauseProducer.manualProduceBuildCauseAndSave(PIPELINE_NAME, Username.ANONYMOUS, new ScheduleOptions(revisions, environmentVariables, new HashMap<>()), new ServerHealthStateOperationResult());
cachedGoConfig.throwExceptionIfExists();
Map<String, BuildCause> afterLoad = scheduleHelper.waitForAnyScheduled(20);
assertThat(afterLoad.keySet(), hasItem(PIPELINE_NAME));
BuildCause cause = afterLoad.get(PIPELINE_NAME);
assertThat(cause.getBuildCauseMessage(), containsString("Forced by anonymous"));
PipelineConfig pipelineConfigAfterSchedule = goConfigService.pipelineConfigNamed(pipelineConfig.name());
RepoConfigOrigin configOriginAfterSchedule = (RepoConfigOrigin) pipelineConfigAfterSchedule.getOrigin();
String lastPushedRevision = mod.get(0).getRevision();
assertThat("revisionOfPipelineConfigOriginShouldMatchLastPushedCommit", configOriginAfterSchedule.getRevision(), is(lastPushedRevision));
assertThat(pipelineConfig.materialConfigs(), hasItem(otherMaterialConfig));
assertThat("buildCauseRevisionShouldMatchLastPushedCommit", cause.getMaterialRevisions().latestRevision(), is(lastPushedRevision));
// update of commited material happened during manual trigger
MaterialRevisions modificationsInDb = materialRepository.findLatestModification(gitMaterial);
assertThat(modificationsInDb.latestRevision(), is(otherGitRepo.latestModification().get(0).getRevision()));
}
use of com.thoughtworks.go.domain.materials.git.GitTestRepo in project gocd by gocd.
the class ScheduledPipelineLoaderIntegrationTest method shouldLoadShallowCloneFlagForGitMaterialsBaseOnTheirOwnPipelineConfig.
@Test
public void shouldLoadShallowCloneFlagForGitMaterialsBaseOnTheirOwnPipelineConfig() throws IOException {
GitTestRepo testRepo = new GitTestRepo(temporaryFolder);
PipelineConfig shallowPipeline = PipelineConfigMother.pipelineConfig("shallowPipeline", new StageConfig(new CaseInsensitiveString("stage"), new JobConfigs(new JobConfig("job-one"))));
shallowPipeline.materialConfigs().clear();
shallowPipeline.addMaterialConfig(new GitMaterialConfig(testRepo.projectRepositoryUrl(), null, true));
configHelper.addPipeline(shallowPipeline);
PipelineConfig fullPipeline = PipelineConfigMother.pipelineConfig("fullPipeline", new StageConfig(new CaseInsensitiveString("stage"), new JobConfigs(new JobConfig("job-one"))));
fullPipeline.materialConfigs().clear();
fullPipeline.addMaterialConfig(new GitMaterialConfig(testRepo.projectRepositoryUrl(), null, false));
configHelper.addPipeline(fullPipeline);
Pipeline shallowPipelineInstance = createAndLoadModifyOneFilePipeline(shallowPipeline);
MaterialRevisions shallowRevisions = shallowPipelineInstance.getBuildCause().getMaterialRevisions();
assertThat(((GitMaterial) shallowRevisions.getRevisions().get(0).getMaterial()).isShallowClone(), is(true));
Pipeline fullPipelineInstance = createAndLoadModifyOneFilePipeline(fullPipeline);
MaterialRevisions fullRevisions = fullPipelineInstance.getBuildCause().getMaterialRevisions();
assertThat(((GitMaterial) fullRevisions.getRevisions().get(0).getMaterial()).isShallowClone(), is(false));
}
use of com.thoughtworks.go.domain.materials.git.GitTestRepo 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));
}
Aggregations