Skip to content

Commit

Permalink
Include HEAD upon git.destination NOOP
Browse files Browse the repository at this point in the history
Add the current head revision to the output when encountering a noop.
This should make it easier to understand what the resulting state is.

PiperOrigin-RevId: 299945189
Change-Id: Idb9f5f824f04c325c720e20ad61e80377c6ca963
  • Loading branch information
hsudhof authored and copybara-github committed Mar 9, 2020
1 parent 57f4f33 commit 71666b3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
6 changes: 4 additions & 2 deletions java/com/google/copybara/git/GitRepository.java
Original file line number Diff line number Diff line change
Expand Up @@ -788,8 +788,10 @@ public void commit(@Nullable String author, boolean amend, @Nullable ZonedDateTi
String message)
throws RepoException, ValidationException {
if (isEmptyStaging() && !amend) {
throw new EmptyChangeException("Migration of the revision resulted in an empty change. "
+ "Is the change already migrated?");
throw new EmptyChangeException(
String.format(
"Migration of the revision resulted in an empty change from baseline '%s'.\n"
+ "Is the change already migrated?", parseRef("HEAD")));
}

ImmutableList.Builder<String> params = ImmutableList.<String>builder().add("commit");
Expand Down
5 changes: 4 additions & 1 deletion javatests/com/google/copybara/WorkflowTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -1573,7 +1573,7 @@ public void testDryRunWithLocalGitPath() throws Exception {
+ ")\n";

addGitFile(originPath, origin, "foo.txt", "not important");
commit(origin, "baseline");
commit(origin, "baseline\n\nOrigin-Label: 1234567");

options.setWorkdirToRealTempDir();
// Pass custom HOME directory so that we run an hermetic test and we
Expand Down Expand Up @@ -1605,6 +1605,9 @@ public void testDryRunWithLocalGitPath() throws Exception {
assertThat(e)
.hasMessageThat()
.contains("Migration of the revision resulted in an empty change");
assertThat(e)
.hasMessageThat()
.contains(destination.parseRef("HEAD"));
}

private void checkChangeRequest_sot_ahead_sot()
Expand Down

0 comments on commit 71666b3

Please sign in to comment.