@@ -83,8 +83,8 @@ func (repo *GitHubRepository) GetInfo() (*provider.RepositoryInfo, error) {
8383 }, nil
8484}
8585
86- func (repo * GitHubRepository ) getCommitsFromGithub (fromSha , toSha string , opts * github.ListOptions ) ([]* github.RepositoryCommit , * github.Response , error ) {
87- if ! repo . compareCommits {
86+ func (repo * GitHubRepository ) getCommitsFromGithub (compareCommits bool , fromSha , toSha string , opts * github.ListOptions ) ([]* github.RepositoryCommit , * github.Response , error ) {
87+ if ! compareCommits {
8888 return repo .client .Repositories .ListCommits (context .Background (), repo .owner , repo .repo , & github.CommitsListOptions {
8989 SHA : toSha ,
9090 ListOptions : * opts ,
@@ -98,17 +98,23 @@ func (repo *GitHubRepository) getCommitsFromGithub(fromSha, toSha string, opts *
9898}
9999
100100func (repo * GitHubRepository ) GetCommits (fromSha , toSha string ) ([]* semrel.RawCommit , error ) {
101+ compareCommits := repo .compareCommits
102+ if compareCommits && fromSha == "" {
103+ // we want all commits for the first release, hence disable compareCommits
104+ compareCommits = false
105+ }
101106 allCommits := make ([]* semrel.RawCommit , 0 )
102107 opts := & github.ListOptions {PerPage : 100 }
103108 done := false
104109 for {
105- commits , resp , err := repo .getCommitsFromGithub (fromSha , toSha , opts )
110+ commits , resp , err := repo .getCommitsFromGithub (compareCommits , fromSha , toSha , opts )
106111 if err != nil {
107112 return nil , err
108113 }
109114 for _ , commit := range commits {
110115 sha := commit .GetSHA ()
111- if sha == fromSha {
116+ // compare commits already returns the relevant commits and no extra filtering is needed
117+ if ! compareCommits && sha == fromSha {
112118 done = true
113119 break
114120 }
@@ -122,7 +128,6 @@ func (repo *GitHubRepository) GetCommits(fromSha, toSha string) ([]*semrel.RawCo
122128 }
123129 opts .Page = resp .NextPage
124130 }
125-
126131 return allCommits , nil
127132}
128133
0 commit comments