use of com.google.copybara.exception.EmptyChangeException in project copybara by google.
the class GitDestinationTest method emptyRebaseEmptyDescription.
@Test
public void emptyRebaseEmptyDescription() throws Exception {
fetch = primaryBranch;
push = primaryBranch;
GitRepository destRepo = repo().withWorkTree(workdir);
writeFile(workdir, "foo", "");
destRepo.add().files("foo").run();
destRepo.simpleCommand("commit", "-m", "baseline");
GitRevision baseline = destRepo.resolveReference("HEAD");
writeFile(workdir, "foo", "updated");
destRepo.add().files("foo").run();
destRepo.simpleCommand("commit", "-m", "primary head");
writeFile(workdir, "foo", "updated");
destinationFiles = Glob.createGlob(ImmutableList.of("foo"));
TransformResult result = TransformResults.of(workdir, new DummyRevision("origin_ref")).withBaseline(baseline.getSha1()).withSummary("Empty");
EmptyChangeException e = assertThrows(EmptyChangeException.class, () -> {
ImmutableList<DestinationEffect> destinationResult = newWriter().write(result, destinationFiles, console);
});
assertThat(e).hasMessageThat().contains("Empty change after rebase");
}
use of com.google.copybara.exception.EmptyChangeException in project copybara by google.
the class GitDestinationTest method emptyRebaseTest.
@Test
public void emptyRebaseTest() throws Exception {
fetch = primaryBranch;
push = primaryBranch;
GitRepository destRepo = repo().withWorkTree(workdir);
writeFile(workdir, "foo", "");
destRepo.add().files("foo").run();
destRepo.simpleCommand("commit", "-m", "baseline");
GitRevision baseline = destRepo.resolveReference("HEAD");
writeFile(workdir, "foo", "updated");
destRepo.add().files("foo").run();
destRepo.simpleCommand("commit", "-m", "main head");
writeFile(workdir, "foo", "updated");
destinationFiles = Glob.createGlob(ImmutableList.of("foo"));
EmptyChangeException e = assertThrows(EmptyChangeException.class, () -> processWithBaseline(newWriter(), destinationFiles, new DummyRevision("origin_ref"), baseline.getSha1()));
assertThat(e).hasMessageThat().contains("Empty change after rebase");
}
use of com.google.copybara.exception.EmptyChangeException in project copybara by google.
the class GitHubPrOriginTest method testLimitByBranch.
@Test
public void testLimitByBranch() throws Exception {
// This should work since it returns a PR for main.
MockPullRequest.create(gitUtil).setState("open").setPrNumber(125).addLabels("bar: yes").mock();
checkResolve(githubPrOrigin("url = 'https://github.com/google/example'", "branch = 'main'"), "125", 125);
MockPullRequest.create(gitUtil).setState("open").setPrNumber(126).addLabels("bar: yes").mock();
EmptyChangeException e = assertThrows(EmptyChangeException.class, () -> checkResolve(githubPrOrigin("url = 'https://github.com/google/example'", "branch = 'other'"), "126", 126));
assertThat(e).hasMessageThat().contains("because its base branch is 'main', but the workflow is configured to only migrate" + " changes for branch 'other'");
}
use of com.google.copybara.exception.EmptyChangeException in project copybara by google.
the class GitHubPrOriginTest method testGitResolveRequiredLabelsNotRetryable.
@Test
public void testGitResolveRequiredLabelsNotRetryable() throws Exception {
MockPullRequest.create(gitUtil).setState("open").setPrNumber(125).mock();
EmptyChangeException thrown = assertThrows(EmptyChangeException.class, () -> checkResolve(githubPrOrigin("url = 'https://github.com/google/example'", "required_labels = ['foo: yes']"), "125", 125));
assertThat(thrown).hasMessageThat().contains("Cannot migrate http://github.com/google/example/pull/125 because it is missing the" + " following labels: [foo: yes]");
}
use of com.google.copybara.exception.EmptyChangeException in project copybara by google.
the class GitHubPrOriginTest method testAlreadyClosed_default.
@Test
public void testAlreadyClosed_default() throws Exception {
MockPullRequest.create(gitUtil).setState("closed").setPrNumber(125).addLabels("foo: yes").mock();
EmptyChangeException thrown = assertThrows(EmptyChangeException.class, () -> checkResolve(githubPrOrigin("url = 'https://github.com/google/example'"), "125", 125));
assertThat(thrown).hasMessageThat().contains("Pull Request 125 is closed");
}
Aggregations