use of com.google.copybara.hg.HgRepository in project copybara by google.
the class WorkflowTest method testHgOriginNoFlags.
@Test
public void testHgOriginNoFlags() throws Exception {
Path originPath = Files.createTempDirectory("origin");
HgRepository origin = new HgRepository(originPath, true, DEFAULT_TIMEOUT).init();
Path destinationPath = Files.createTempDirectory("destination");
GitRepository destRepo = GitRepository.newBareRepo(destinationPath, getGitEnv(), true, DEFAULT_TIMEOUT, /*noVerify=*/
false).init();
String primaryBranch = destRepo.getPrimaryBranch();
String config = "core.workflow(" + " name = 'default'," + " origin = hg.origin( url = 'file://" + origin.getHgDir() + "', ref = 'default'),\n" + " destination = git.destination(" + " url = 'file://" + destRepo.getGitDir() + "',\n" + " fetch = '" + primaryBranch + "',\n" + " push = '" + primaryBranch + "',\n" + " ),\n" + " authoring = " + authoring + "," + " mode = '" + WorkflowMode.ITERATIVE + "'," + ")\n";
Files.write(originPath.resolve("foo.txt"), "testing foo".getBytes(UTF_8));
origin.hg(originPath, "add", "foo.txt");
origin.hg(originPath, "commit", "-m", "add foo");
options.gitDestination.committerName = "Foo";
options.gitDestination.committerEmail = "foo@foo.com";
options.setWorkdirToRealTempDir();
options.setHomeDir(Files.createTempDirectory("home").toString());
options.workflowOptions.initHistory = true;
Migration workflow = loadConfig(config).getMigration("default");
workflow.run(workdir, ImmutableList.of());
ImmutableList<GitLogEntry> destCommits = destRepo.log("HEAD").run();
assertThat(destCommits).hasSize(1);
assertThat(destCommits.get(0).getBody()).contains("add foo");
Files.write(originPath.resolve("bar.txt"), "testing bar".getBytes(UTF_8));
origin.hg(originPath, "add", "bar.txt");
origin.hg(originPath, "commit", "-m", "add bar");
options.workflowOptions.initHistory = false;
workflow.run(workdir, ImmutableList.of());
destCommits = destRepo.log("HEAD").run();
assertThat(destCommits).hasSize(2);
assertThat(destCommits.get(0).getBody()).contains("add bar");
assertThat(destCommits.get(1).getBody()).contains("add foo");
}
Aggregations