use of com.google.copybara.git.GitIntegrateChanges.Strategy.FAKE_MERGE in project copybara by google.
the class GitDestinationIntegrateTest method testGerritFakeMergeNoChangeId.
@Test
public void testGerritFakeMergeNoChangeId() throws ValidationException, IOException, RepoException {
Path workTree = Files.createTempDirectory("test");
GitRepository repo = fakeHttpsRepo("example.com/gerrit").withWorkTree(workTree);
String label = new GerritIntegrateLabel(repo, options.general, "https://example.com/gerrit", 1020, 1, /*changeId=*/
null).toString();
assertThat(label).isEqualTo("gerrit https://example.com/gerrit 1020 Patch Set 1");
GitRevision firstChange = singleChange(workTree, repo, "ignore_me", "Feature1 change");
repo.simpleCommand("update-ref", "refs/changes/20/1020/1", firstChange.getSha1());
GitTestUtil.createFakeGerritNodeDbMeta(repo, 1020, CHANGE_ID);
GitDestination destination = destination(FAKE_MERGE);
GitLogEntry previous = createBaseDestinationChange(destination);
migrateOriginChange(destination, "Test change\n" + "\n" + GitModule.DEFAULT_INTEGRATE_LABEL + "=" + label + "\n", "some content");
// Make sure commit adds new text
String showResult = git("--git-dir", repoGitDir.toString(), "show", "master");
assertThat(showResult).contains("some content");
GitTesting.assertThatCheckout(repo(), "master").containsFile("test.txt", "some content").containsNoMoreFiles();
GitLogEntry merge = getLastMigratedChange("master");
assertThat(merge.getBody()).isEqualTo("Merge Gerrit change 1020 Patch Set 1\n" + "\n" + "DummyOrigin-RevId: test\n");
assertThat(Lists.transform(merge.getParents(), GitRevision::getSha1)).isEqualTo(Lists.newArrayList(previous.getCommit().getSha1(), firstChange.getSha1()));
assertThat(console.getMessages().stream().filter(e -> e.getType() == MessageType.WARNING).findAny()).isEqualTo(Optional.empty());
}
Aggregations