From 1e73e62d52437147ca2bb1edbc8c240094500907 Mon Sep 17 00:00:00 2001 From: Christoph Witzko Date: Tue, 16 Mar 2021 10:53:26 +0100 Subject: [PATCH] fix: revert "Compare commits from the latest release." This reverts commit ff03a15b6b02f34219be4cdf369b16739448ae87. --- pkg/provider/github.go | 6 ++---- pkg/provider/github_test.go | 10 +++------- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/pkg/provider/github.go b/pkg/provider/github.go index a458ec1..1944675 100644 --- a/pkg/provider/github.go +++ b/pkg/provider/github.go @@ -81,15 +81,13 @@ func (repo *GitHubRepository) GetCommits(fromSha, toSha string) ([]*semrel.RawCo SHA: toSha, ListOptions: github.ListOptions{PerPage: 100}, } - done := false for { - commits, resp, err := repo.client.Repositories.CompareCommits(context.Background(), repo.owner, repo.repo, fromSha, toSha) + commits, resp, err := repo.client.Repositories.ListCommits(context.Background(), repo.owner, repo.repo, opts) if err != nil { return nil, err } - - for _, commit := range commits.Commits { + for _, commit := range commits { sha := commit.GetSHA() if sha == fromSha { done = true diff --git a/pkg/provider/github_test.go b/pkg/provider/github_test.go index c18060c..3c638e4 100644 --- a/pkg/provider/github_test.go +++ b/pkg/provider/github_test.go @@ -6,7 +6,6 @@ import ( "net/http" "net/http/httptest" "net/url" - "strings" "testing" "github.com/go-semantic-release/semantic-release/v2/pkg/provider" @@ -101,11 +100,8 @@ func githubHandler(w http.ResponseWriter, r *http.Request) { json.NewEncoder(w).Encode(GITHUB_REPO) return } - if r.Method == "GET" && strings.HasPrefix(r.URL.Path, "/repos/owner/test-repo/compare/") { - - li := strings.LastIndex(r.URL.Path, "/") - arr := strings.Split(r.URL.Path[li+1:], "...") - toSha := arr[1] + if r.Method == "GET" && r.URL.Path == "/repos/owner/test-repo/commits" { + toSha := r.URL.Query().Get("sha") skip := 0 for i, commit := range GITHUB_COMMITS { if commit.GetSHA() == toSha { @@ -113,7 +109,7 @@ func githubHandler(w http.ResponseWriter, r *http.Request) { break } } - json.NewEncoder(w).Encode(github.CommitsComparison{Commits: GITHUB_COMMITS[skip:]}) + json.NewEncoder(w).Encode(GITHUB_COMMITS[skip:]) return } if r.Method == "GET" && r.URL.Path == "/repos/owner/test-repo/git/matching-refs/tags" {