diff --git a/gerrit-reviewdb/src/main/java/com/google/gerrit/reviewdb/client/RefNames.java b/gerrit-reviewdb/src/main/java/com/google/gerrit/reviewdb/client/RefNames.java index e51cc9e0a8..d6ba008f90 100644 --- a/gerrit-reviewdb/src/main/java/com/google/gerrit/reviewdb/client/RefNames.java +++ b/gerrit-reviewdb/src/main/java/com/google/gerrit/reviewdb/client/RefNames.java @@ -92,28 +92,13 @@ public class RefNames { public static String refsDraftComments(Account.Id accountId, Change.Id changeId) { - StringBuilder r = buildRefsDraftCommentsPrefix(accountId); + StringBuilder r = buildRefsPrefix(REFS_DRAFT_COMMENTS, accountId); r.append(changeId.get()); return r.toString(); } public static String refsDraftCommentsPrefix(Account.Id accountId) { - return buildRefsDraftCommentsPrefix(accountId).toString(); - } - - public static StringBuilder buildRefsDraftCommentsPrefix( - Account.Id accountId) { - StringBuilder r = new StringBuilder(); - r.append(REFS_DRAFT_COMMENTS); - int n = accountId.get() % 100; - if (n < 10) { - r.append('0'); - } - r.append(n); - r.append('/'); - r.append(accountId.get()); - r.append('-'); - return r; + return buildRefsPrefix(REFS_DRAFT_COMMENTS, accountId).toString(); } public static String refsStarredChanges(Account.Id accountId, diff --git a/gerrit-reviewdb/src/test/java/com/google/gerrit/reviewdb/client/RefNamesTest.java b/gerrit-reviewdb/src/test/java/com/google/gerrit/reviewdb/client/RefNamesTest.java index 477d46c541..844f893769 100644 --- a/gerrit-reviewdb/src/test/java/com/google/gerrit/reviewdb/client/RefNamesTest.java +++ b/gerrit-reviewdb/src/test/java/com/google/gerrit/reviewdb/client/RefNamesTest.java @@ -39,13 +39,13 @@ public class RefNamesTest { @Test public void refsDraftComments() throws Exception { assertThat(RefNames.refsDraftComments(accountId, changeId)) - .isEqualTo("refs/draft-comments/23/1011123-67473"); + .isEqualTo("refs/draft-comments/23/1011123/67473"); } @Test public void refsDraftCommentsPrefix() throws Exception { assertThat(RefNames.refsDraftCommentsPrefix(accountId)) - .isEqualTo("refs/draft-comments/23/1011123-"); + .isEqualTo("refs/draft-comments/23/1011123/"); } @Test diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/PatchLineCommentsUtil.java b/gerrit-server/src/main/java/com/google/gerrit/server/PatchLineCommentsUtil.java index 3e67b277d8..c4086e0b67 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/PatchLineCommentsUtil.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/PatchLineCommentsUtil.java @@ -371,7 +371,7 @@ public class PatchLineCommentsUtil { private Iterable getDraftRefs(final Change.Id changeId) throws OrmException { Set refNames = getRefNamesAllUsers(RefNames.REFS_DRAFT_COMMENTS); - final String suffix = "-" + changeId.get(); + final String suffix = "/" + changeId.get(); return Iterables.filter(refNames, new Predicate() { @Override public boolean apply(String input) {