Skip to content
This repository was archived by the owner on Apr 20, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -215,9 +215,10 @@ public CompletableFuture<Tag> createAnnotatedTag(
"name", taggerName,
"email", taggerEmail,
"date", Instant.now().toString()));
return createTagReference(tag, sha)
.thenCompose(
reference -> github.post(tagPath, github.json().toJsonUnchecked(body), Tag.class));
return github.post(tagPath, github.json().toJsonUnchecked(body), Tag.class)
.thenCompose(tagCreated ->
createTagReference(tag, tagCreated.sha())
.thenApply(reference -> tagCreated));
}

/**
Expand Down
28 changes: 15 additions & 13 deletions src/test/java/com/spotify/github/v3/clients/GitDataClientTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -182,19 +182,6 @@ public void createTagReference() throws Exception {

@Test
public void createAnnotateTag() throws Exception {
final CompletableFuture<Reference> reference =
completedFuture(json.fromJson(getFixture("tag.json"), Reference.class));
when(github.post(
"/repos/someowner/somerepo/git/refs",
github
.json()
.toJsonUnchecked(
of(
"ref", "refs/tags/0.0.1",
"sha", "5926dd300de5fee31d445c57be223f00e128a634")),
Reference.class))
.thenReturn(reference);

final String now = Instant.now().toString();
final ImmutableMap<String, Object> body =
of(
Expand All @@ -211,6 +198,21 @@ public void createAnnotateTag() throws Exception {
completedFuture(json.fromJson(getFixture("release-tag.json"), Tag.class));
when(github.post(eq("/repos/someowner/somerepo/git/tags"), any(), eq(Tag.class)))
.thenReturn(fixture);

// Ref to the annotate tag should reference the SHA of the tag, not the SHA of the commit.
final CompletableFuture<Reference> reference =
completedFuture(json.fromJson(getFixture("tag.json"), Reference.class));
when(github.post(
"/repos/someowner/somerepo/git/refs",
github
.json()
.toJsonUnchecked(
of(
"ref", "refs/tags/0.0.1",
"sha", "827210625b551200e7d3dc608935b1454523eaa8")),
Reference.class))
.thenReturn(reference);

Tag tag =
gitDataClient
.createAnnotatedTag(
Expand Down