use of com.google.copybara.Destination in project copybara by google.
the class FolderDestinationTest method write.
private void write() throws ValidationException, RepoException, IOException {
WriterContext writerContext = new WriterContext("FolderDestinationTest", "test", false, new DummyRevision("origin_ref"), Glob.ALL_FILES.roots());
skylark.<Destination<Revision>>eval("dest", "dest = folder.destination()").newWriter(writerContext).write(TransformResults.of(workdir, new DummyRevision("origin_ref")), Glob.createGlob(ImmutableList.of("**"), excludedPathsForDeletion), options.general.console());
}
use of com.google.copybara.Destination in project copybara by google.
the class SubmodulesInDestinationTest method writeWithSubmoduleInDestination.
private void writeWithSubmoduleInDestination() throws Exception {
fetch = primaryBranch;
push = primaryBranch;
Path scratchTree = Files.createTempDirectory("SubmodulesInDestinationTest-scratchTree");
GitRepository scratchRepo = repo().withWorkTree(scratchTree);
scratchRepo.simpleCommand("submodule", "add", "file://" + submodule.getGitDir(), "submodule");
scratchRepo.simpleCommand("commit", "-m", "commit submodule");
Files.write(workdir.resolve("test42"), new byte[] { 42 });
WriterContext writerContext = new WriterContext("SubmodulesInDestinationTest", "Test", false, new DummyRevision("test"), Glob.ALL_FILES.roots());
Destination.Writer<GitRevision> writer = destination().newWriter(writerContext);
ImmutableList<DestinationEffect> result = writer.write(TransformResults.of(workdir, new DummyRevision("ref1")), destinationFiles, console);
assertThat(result).hasSize(1);
assertThat(result.get(0).getErrors()).isEmpty();
assertThat(result.get(0).getType()).isEqualTo(Type.CREATED);
assertThat(result.get(0).getDestinationRef().getType()).isEqualTo("commit");
assertThat(result.get(0).getDestinationRef().getId()).matches("[0-9a-f]{40}");
}
use of com.google.copybara.Destination in project copybara by google.
the class SubmodulesInDestinationTest method submoduleInSubdirectoryWithSiblingFiles.
@Test
public void submoduleInSubdirectoryWithSiblingFiles() throws Exception {
destinationFiles = Glob.createGlob(ImmutableList.of("foo/a", "foo/c"));
fetch = primaryBranch;
push = primaryBranch;
Path scratchTree = Files.createTempDirectory("SubmodulesInDestinationTest-scratchTree");
GitRepository scratchRepo = repo().withWorkTree(scratchTree);
Files.createDirectories(scratchTree.resolve("foo"));
Files.write(scratchTree.resolve("foo/a"), new byte[] { 1 });
scratchRepo.add().files("foo/a").run();
scratchRepo.simpleCommand("submodule", "add", "file://" + submodule.getGitDir(), "foo/b");
scratchRepo.simpleCommand("commit", "-m", "commit submodule and foo/a");
// Create a commit that removes foo/a and adds foo/c
Files.createDirectories(workdir.resolve("foo"));
Files.write(workdir.resolve("foo/c"), new byte[] { 1 });
WriterContext writerContext = new WriterContext("SubmodulesInDestinationTest", "Test", false, new DummyRevision("test"), Glob.ALL_FILES.roots());
Destination.Writer<GitRevision> writer = destination().newWriter(writerContext);
ImmutableList<DestinationEffect> result = writer.write(TransformResults.of(workdir, new DummyRevision("ref1")), destinationFiles, console);
assertThat(result).hasSize(1);
assertThat(result.get(0).getErrors()).isEmpty();
assertThat(result.get(0).getType()).isEqualTo(Type.CREATED);
assertThat(result.get(0).getDestinationRef().getType()).isEqualTo("commit");
assertThat(result.get(0).getDestinationRef().getId()).matches("[0-9a-f]{40}");
GitTesting.assertThatCheckout(repo(), primaryBranch).containsFiles("foo/c", "foo/b").containsNoFiles("foo/a");
}
Aggregations