use of com.google.copybara.testing.DummyRevision in project copybara by google.
the class GitDestinationTest method canOverrideUrl.
@Test
public void canOverrideUrl() throws Exception {
Path newDestination = Files.createTempDirectory("canOverrideUrl");
git("init", "--bare", newDestination.toString());
fetch = primaryBranch;
push = primaryBranch;
options.gitDestination.url = "file://" + newDestination.toAbsolutePath();
Files.write(workdir.resolve("test.txt"), "some content".getBytes(UTF_8));
process(firstCommitWriter(), new DummyRevision("first_commit"));
GitTesting.assertCommitterLineMatches(repoForPath(newDestination), primaryBranch, "Bara Kopi <.*> [-+ 0-9]+");
// No branches were created in the config file url.
assertThat(repo().simpleCommand("branch").getStdout()).isEqualTo("");
}
use of com.google.copybara.testing.DummyRevision in project copybara by google.
the class GitDestinationTest method testGitIgnoreIncluded.
@Test
public void testGitIgnoreIncluded() throws Exception {
fetch = primaryBranch;
push = primaryBranch;
Files.write(workdir.resolve("test.txt"), "some content".getBytes(UTF_8));
Files.write(workdir.resolve(".gitignore"), ".gitignore\n".getBytes(UTF_8));
DummyRevision ref = new DummyRevision("origin_ref");
process(firstCommitWriter(), ref);
assertThatCheckout(repo(), primaryBranch).containsFile("test.txt", "some content").containsFile(".gitignore", ".gitignore\n").containsNoMoreFiles();
}
use of com.google.copybara.testing.DummyRevision in project copybara by google.
the class GitDestinationTest method testChangeDescriptionEmpty.
@Test
public void testChangeDescriptionEmpty() throws Exception {
fetch = primaryBranch;
push = primaryBranch;
Path scratchTree = Files.createTempDirectory("GitDestinationTest-testLocalRepo");
Files.write(scratchTree.resolve("foo"), "foo\n".getBytes(UTF_8));
repo().withWorkTree(scratchTree).add().force().files("foo").run();
repo().withWorkTree(scratchTree).simpleCommand("commit", "-a", "-m", "change");
DummyRevision originRef = new DummyRevision("origin_ref");
WriterContext writerContext = new WriterContext("GitDestinationTest", "test", true, new DummyRevision("origin_ref1"), Glob.ALL_FILES.roots());
Writer<GitRevision> writer = destination().newWriter(writerContext);
ValidationException e = assertThrows(ValidationException.class, () -> writer.write(TransformResults.of(workdir, originRef).withSummary(" "), Glob.createGlob(ImmutableList.of("**"), ImmutableList.of("test.txt")), console));
assertThat(e).hasMessageThat().contains("Change description is empty");
}
use of com.google.copybara.testing.DummyRevision in project copybara by google.
the class GitDestinationTest method setUpForTestingTag.
private WriterContext setUpForTestingTag() throws Exception {
fetch = primaryBranch;
push = primaryBranch;
Files.write(workdir.resolve("test.txt"), "some content".getBytes(UTF_8));
options.setForce(true);
WriterContext writerContext = new WriterContext("piper_to_github", "TEST", false, new DummyRevision("test"), Glob.ALL_FILES.roots());
evalDestination().newWriter(writerContext).write(TransformResults.of(workdir, new DummyRevision("ref1")), destinationFiles, console);
Files.write(workdir.resolve("test.txt"), "some content 2".getBytes(UTF_8));
// push tag without tagMsg
evalDestinationWithTag(null).newWriter(writerContext).write(TransformResults.of(workdir, new DummyRevision("ref2")), destinationFiles, console);
Files.write(workdir.resolve("test.txt"), "some content 3".getBytes(UTF_8));
return writerContext;
}
use of com.google.copybara.testing.DummyRevision in project copybara by google.
the class GitHubDestinationTest method testPrToUpdateIngoredForInitHistory.
@Test
public void testPrToUpdateIngoredForInitHistory() throws Exception {
options.workflowOptions.initHistory = true;
addFiles(remote, primaryBranch, "first change", ImmutableMap.<String, String>builder().put("foo.txt", "foo").buildOrThrow());
WriterContext writerContext = new WriterContext("piper_to_github", "test", false, new DummyRevision("origin_ref1"), Glob.ALL_FILES.roots());
writeFile(this.workdir, "test.txt", "some content");
Writer<GitRevision> writer = destinationWithExistingPrBranch("other", "True").newWriter(writerContext);
DummyRevision ref = new DummyRevision("origin_ref1");
TransformResult result = TransformResults.of(workdir, ref);
Changes changes = new Changes(ImmutableList.of(new Change<>(ref, new Author("foo", "foo@foo.com"), "message", ZonedDateTime.now(ZoneOffset.UTC), ImmutableListMultimap.of("my_label", "12345")), new Change<>(ref, new Author("foo", "foo@foo.com"), "message", ZonedDateTime.now(ZoneOffset.UTC), ImmutableListMultimap.of("my_label", "6789"))), ImmutableList.of());
result = result.withChanges(changes);
ImmutableList<DestinationEffect> destinationResult = writer.write(result, destinationFiles, console);
assertThat(destinationResult).hasSize(1);
assertThat(destinationResult.get(0).getErrors()).isEmpty();
assertThat(destinationResult.get(0).getType()).isEqualTo(Type.CREATED);
assertThat(destinationResult.get(0).getDestinationRef().getType()).isEqualTo("commit");
assertThat(destinationResult.get(0).getDestinationRef().getId()).matches("[0-9a-f]{40}");
// This is a migration of two changes (use the same ref because mocks)
verifyNoInteractions(gitUtil.httpTransport());
GitTesting.assertThatCheckout(remote, primaryBranch).containsFile("test.txt", "some content").containsNoMoreFiles();
assertThat(remote.simpleCommand("show-ref").getStdout()).doesNotContain("other");
}
Aggregations