Skip to content

Commit 2d9cf84

Browse files
committed
replace /git/refs/tags/ to /git/ref/tags/
1 parent ec086af commit 2d9cf84

2 files changed

Lines changed: 5 additions & 10 deletions

File tree

pkg/cmd/release/shared/fetch.go

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ type fetchResult struct {
136136
}
137137

138138
func FetchRefSHA(ctx context.Context, httpClient *http.Client, repo ghrepo.Interface, tagName string) (string, error) {
139-
path := fmt.Sprintf("repos/%s/%s/git/refs/tags/%s", repo.RepoOwner(), repo.RepoName(), tagName)
139+
path := fmt.Sprintf("repos/%s/%s/git/ref/tags/%s", repo.RepoOwner(), repo.RepoName(), tagName)
140140
req, err := http.NewRequestWithContext(ctx, "GET", ghinstance.RESTPrefix(repo.RepoHost())+path, nil)
141141
if err != nil {
142142
return "", err
@@ -159,17 +159,12 @@ func FetchRefSHA(ctx context.Context, httpClient *http.Client, repo ghrepo.Inter
159159

160160
var ref struct {
161161
Object struct {
162-
SHA string `json:"sha,omitempty"`
162+
SHA string `json:"sha"`
163163
} `json:"object"`
164164
}
165165

166166
if err := json.NewDecoder(resp.Body).Decode(&ref); err != nil {
167-
return "", fmt.Errorf("failed to parse Git ref response: %w", err)
168-
}
169-
170-
// Check if SHA is empty after successful JSON parsing
171-
if ref.Object.SHA == "" {
172-
return "", ErrReleaseNotFound
167+
return "", fmt.Errorf("failed to parse ref response: %w", err)
173168
}
174169

175170
return ref.Object.SHA, nil
@@ -292,7 +287,7 @@ func StubFetchRelease(t *testing.T, reg *httpmock.Registry, owner, repoName, tag
292287
}
293288

294289
func StubFetchRefSHA(t *testing.T, reg *httpmock.Registry, owner, repoName, tagName, sha string) {
295-
path := fmt.Sprintf("repos/%s/%s/git/refs/tags/%s", owner, repoName, tagName)
290+
path := fmt.Sprintf("repos/%s/%s/git/ref/tags/%s", owner, repoName, tagName)
296291
reg.Register(
297292
httpmock.REST("GET", path),
298293
httpmock.StringResponse(fmt.Sprintf(`{"object": {"sha": "%s"}}`, sha)),

pkg/cmd/release/shared/fetch_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ func TestFetchRefSHA(t *testing.T) {
7979
repo, err := ghrepo.FromFullName("owner/repo")
8080
require.NoError(t, err)
8181

82-
path := "repos/owner/repo/git/refs/tags/" + tt.tagName
82+
path := "repos/owner/repo/git/ref/tags/" + tt.tagName
8383
if tt.responseStatus == 404 {
8484
fakeHTTP.Register(httpmock.REST("GET", path), httpmock.StatusStringResponse(404, "Not Found"))
8585
} else {

0 commit comments

Comments
 (0)