Skip to content

Commit 1e73e62

Browse files
fix: revert "Compare commits from the latest release."
This reverts commit ff03a15.
1 parent ff03a15 commit 1e73e62

File tree

2 files changed

+5
-11
lines changed

2 files changed

+5
-11
lines changed

pkg/provider/github.go

+2-4
Original file line numberDiff line numberDiff line change
@@ -81,15 +81,13 @@ func (repo *GitHubRepository) GetCommits(fromSha, toSha string) ([]*semrel.RawCo
8181
SHA: toSha,
8282
ListOptions: github.ListOptions{PerPage: 100},
8383
}
84-
8584
done := false
8685
for {
87-
commits, resp, err := repo.client.Repositories.CompareCommits(context.Background(), repo.owner, repo.repo, fromSha, toSha)
86+
commits, resp, err := repo.client.Repositories.ListCommits(context.Background(), repo.owner, repo.repo, opts)
8887
if err != nil {
8988
return nil, err
9089
}
91-
92-
for _, commit := range commits.Commits {
90+
for _, commit := range commits {
9391
sha := commit.GetSHA()
9492
if sha == fromSha {
9593
done = true

pkg/provider/github_test.go

+3-7
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import (
66
"net/http"
77
"net/http/httptest"
88
"net/url"
9-
"strings"
109
"testing"
1110

1211
"github.com/go-semantic-release/semantic-release/v2/pkg/provider"
@@ -101,19 +100,16 @@ func githubHandler(w http.ResponseWriter, r *http.Request) {
101100
json.NewEncoder(w).Encode(GITHUB_REPO)
102101
return
103102
}
104-
if r.Method == "GET" && strings.HasPrefix(r.URL.Path, "/repos/owner/test-repo/compare/") {
105-
106-
li := strings.LastIndex(r.URL.Path, "/")
107-
arr := strings.Split(r.URL.Path[li+1:], "...")
108-
toSha := arr[1]
103+
if r.Method == "GET" && r.URL.Path == "/repos/owner/test-repo/commits" {
104+
toSha := r.URL.Query().Get("sha")
109105
skip := 0
110106
for i, commit := range GITHUB_COMMITS {
111107
if commit.GetSHA() == toSha {
112108
skip = i
113109
break
114110
}
115111
}
116-
json.NewEncoder(w).Encode(github.CommitsComparison{Commits: GITHUB_COMMITS[skip:]})
112+
json.NewEncoder(w).Encode(GITHUB_COMMITS[skip:])
117113
return
118114
}
119115
if r.Method == "GET" && r.URL.Path == "/repos/owner/test-repo/git/matching-refs/tags" {

0 commit comments

Comments
 (0)