Displaying refs for fetch tasks
Fetch tasks string representation is currently showing a unique id
alongside the project the fetch is for.
Whilst this is useful it does not tell which refs are actually being
fetched.
Add the refs to the string representation of the fetch tasks allows to
have a better understanding of what is going on when looking at a
show-queue or when logging the tasks themselves.
Change-Id: I53f9e5da54d01ccbda772cf2c49b3b87b3628ca7
diff --git a/src/main/java/com/googlesource/gerrit/plugins/replication/pull/FetchOne.java b/src/main/java/com/googlesource/gerrit/plugins/replication/pull/FetchOne.java
index 3fe64e4..5421b21 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/replication/pull/FetchOne.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/replication/pull/FetchOne.java
@@ -177,7 +177,7 @@
@Override
public String toString() {
- String print = "[" + taskIdHex + "] fetch " + uri;
+ String print = "[" + taskIdHex + "] fetch " + uri + " [" + String.join(",", delta) + "]";
if (retryCount > 0) {
print = "(retry " + retryCount + ") " + print;
diff --git a/src/test/java/com/googlesource/gerrit/plugins/replication/pull/FetchOneTest.java b/src/test/java/com/googlesource/gerrit/plugins/replication/pull/FetchOneTest.java
index 3980f93..817876d 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/replication/pull/FetchOneTest.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/replication/pull/FetchOneTest.java
@@ -110,15 +110,27 @@
@Test
public void shouldIncludeTheTaskIndexInItsStringRepresentation() {
- String expected = "[" + objectUnderTest.getTaskIdHex() + "] fetch " + URI_PATTERN;
+ objectUnderTest.addRefs(Set.of("refs/heads/foo", "refs/heads/bar"));
+ String expected =
+ "["
+ + objectUnderTest.getTaskIdHex()
+ + "] fetch "
+ + URI_PATTERN
+ + " [refs/heads/bar,refs/heads/foo]";
assertThat(objectUnderTest.toString()).isEqualTo(expected);
}
@Test
public void shouldIncludeTheRetryCountInItsStringRepresentationWhenATaskIsRetried() {
+ objectUnderTest.addRefs(Set.of("refs/heads/bar", "refs/heads/foo"));
objectUnderTest.setToRetry();
- String expected = "(retry 1) [" + objectUnderTest.getTaskIdHex() + "] fetch " + URI_PATTERN;
+ String expected =
+ "(retry 1) ["
+ + objectUnderTest.getTaskIdHex()
+ + "] fetch "
+ + URI_PATTERN
+ + " [refs/heads/bar,refs/heads/foo]";
assertThat(objectUnderTest.toString()).isEqualTo(expected);
}