diff --git a/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/rest/project/TagsIT.java b/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/rest/project/TagsIT.java index c6cf647a6d..eb129d4bc7 100644 --- a/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/rest/project/TagsIT.java +++ b/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/rest/project/TagsIT.java @@ -16,6 +16,7 @@ package com.google.gerrit.acceptance.rest.project; import static com.google.common.truth.Truth.assertThat; +import com.google.common.collect.Iterables; import com.google.gerrit.acceptance.AbstractDaemonTest; import com.google.gerrit.acceptance.PushOneCommit; import com.google.gerrit.acceptance.RestResponse; @@ -24,6 +25,11 @@ import com.google.gerrit.extensions.common.TagInfo; import com.google.gson.reflect.TypeToken; import org.apache.http.HttpStatus; +import org.eclipse.jgit.api.PushCommand; +import org.eclipse.jgit.lib.Constants; +import org.eclipse.jgit.transport.PushResult; +import org.eclipse.jgit.transport.RefSpec; +import org.eclipse.jgit.transport.RemoteRefUpdate.Status; import org.junit.Test; import java.util.List; @@ -62,16 +68,30 @@ public class TagsIT extends AbstractDaemonTest { PushOneCommit.Result r2 = push2.to(git, "refs/for/master%submit"); r2.assertOkStatus(); + String tag3Ref = Constants.R_TAGS + "vLatest"; + PushCommand pushCmd = git.push(); + pushCmd.setRefSpecs(new RefSpec(tag2.name + ":" + tag3Ref)); + Iterable r = pushCmd.call(); + assertThat(Iterables.getOnlyElement(r).getRemoteUpdate(tag3Ref).getStatus()) + .isEqualTo(Status.OK); + List result = toTagInfoList(adminSession.get("/projects/" + project.get() + "/tags")); - assertThat(result).hasSize(2); + assertThat(result).hasSize(3); TagInfo t = result.get(0); - assertThat(t.ref).isEqualTo("refs/tags/" + tag1.name); + assertThat(t.ref).isEqualTo(Constants.R_TAGS + tag1.name); assertThat(t.revision).isEqualTo(r1.getCommitId().getName()); t = result.get(1); - assertThat(t.ref).isEqualTo("refs/tags/" + tag2.name); + assertThat(t.ref).isEqualTo(Constants.R_TAGS + tag2.name); + assertThat(t.object).isEqualTo(r2.getCommitId().getName()); + assertThat(t.message).isEqualTo(tag2.message); + assertThat(t.tagger.name).isEqualTo(tag2.tagger.getName()); + assertThat(t.tagger.email).isEqualTo(tag2.tagger.getEmailAddress()); + + t = result.get(2); + assertThat(t.ref).isEqualTo(tag3Ref); assertThat(t.object).isEqualTo(r2.getCommitId().getName()); assertThat(t.message).isEqualTo(tag2.message); assertThat(t.tagger.name).isEqualTo(tag2.tagger.getName()); diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/project/ListTags.java b/gerrit-server/src/main/java/com/google/gerrit/server/project/ListTags.java index b01e563e1e..3b1232b7d7 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/project/ListTags.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/project/ListTags.java @@ -135,7 +135,7 @@ public class ListTags implements RestReadView { RevTag tag = (RevTag)object; // Annotated or signed tag return new TagInfo( - Constants.R_TAGS + tag.getTagName(), + ref.getName(), tag.getName(), tag.getObject().getName(), tag.getFullMessage().trim(),