Skip to content

Commit

Permalink
fix: revert "Compare commits from the latest release."
Browse files Browse the repository at this point in the history
This reverts commit ff03a15.
  • Loading branch information
christophwitzko committed Mar 16, 2021
1 parent ff03a15 commit 1e73e62
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 11 deletions.
6 changes: 2 additions & 4 deletions pkg/provider/github.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 3 additions & 7 deletions pkg/provider/github_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"net/http"
"net/http/httptest"
"net/url"
"strings"
"testing"

"github.com/go-semantic-release/semantic-release/v2/pkg/provider"
Expand Down Expand Up @@ -101,19 +100,16 @@ 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 {
skip = i
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" {
Expand Down

0 comments on commit 1e73e62

Please sign in to comment.