Skip to content

Commit 71666b3

Browse files
hsudhofcopybara-github
authored andcommitted
Include HEAD upon git.destination NOOP
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
1 parent 57f4f33 commit 71666b3

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

java/com/google/copybara/git/GitRepository.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -788,8 +788,10 @@ public void commit(@Nullable String author, boolean amend, @Nullable ZonedDateTi
788788
String message)
789789
throws RepoException, ValidationException {
790790
if (isEmptyStaging() && !amend) {
791-
throw new EmptyChangeException("Migration of the revision resulted in an empty change. "
792-
+ "Is the change already migrated?");
791+
throw new EmptyChangeException(
792+
String.format(
793+
"Migration of the revision resulted in an empty change from baseline '%s'.\n"
794+
+ "Is the change already migrated?", parseRef("HEAD")));
793795
}
794796

795797
ImmutableList.Builder<String> params = ImmutableList.<String>builder().add("commit");

javatests/com/google/copybara/WorkflowTest.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1573,7 +1573,7 @@ public void testDryRunWithLocalGitPath() throws Exception {
15731573
+ ")\n";
15741574

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

15781578
options.setWorkdirToRealTempDir();
15791579
// Pass custom HOME directory so that we run an hermetic test and we
@@ -1605,6 +1605,9 @@ public void testDryRunWithLocalGitPath() throws Exception {
16051605
assertThat(e)
16061606
.hasMessageThat()
16071607
.contains("Migration of the revision resulted in an empty change");
1608+
assertThat(e)
1609+
.hasMessageThat()
1610+
.contains(destination.parseRef("HEAD"));
16081611
}
16091612

16101613
private void checkChangeRequest_sot_ahead_sot()

0 commit comments

Comments
 (0)