@@ -83,8 +83,8 @@ func (repo *GitHubRepository) GetInfo() (*provider.RepositoryInfo, error) {
83
83
}, nil
84
84
}
85
85
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 {
88
88
return repo .client .Repositories .ListCommits (context .Background (), repo .owner , repo .repo , & github.CommitsListOptions {
89
89
SHA : toSha ,
90
90
ListOptions : * opts ,
@@ -98,17 +98,23 @@ func (repo *GitHubRepository) getCommitsFromGithub(fromSha, toSha string, opts *
98
98
}
99
99
100
100
func (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
+ }
101
106
allCommits := make ([]* semrel.RawCommit , 0 )
102
107
opts := & github.ListOptions {PerPage : 100 }
103
108
done := false
104
109
for {
105
- commits , resp , err := repo .getCommitsFromGithub (fromSha , toSha , opts )
110
+ commits , resp , err := repo .getCommitsFromGithub (compareCommits , fromSha , toSha , opts )
106
111
if err != nil {
107
112
return nil , err
108
113
}
109
114
for _ , commit := range commits {
110
115
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 {
112
118
done = true
113
119
break
114
120
}
@@ -122,7 +128,6 @@ func (repo *GitHubRepository) GetCommits(fromSha, toSha string) ([]*semrel.RawCo
122
128
}
123
129
opts .Page = resp .NextPage
124
130
}
125
-
126
131
return allCommits , nil
127
132
}
128
133
0 commit comments