@@ -199,19 +199,19 @@ func getMergeCommit(ctx context.Context, pr *issues_model.PullRequest) (*git.Com
199
199
return nil , fmt .Errorf ("ReadFile(%s): %w" , headFile , err )
200
200
}
201
201
commitID := string (commitIDBytes )
202
- if len (commitID ) < 40 {
202
+ if len (commitID ) < git . SHAFullLength {
203
203
return nil , fmt .Errorf (`ReadFile(%s): invalid commit-ID "%s"` , headFile , commitID )
204
204
}
205
- cmd := commitID [:40 ] + ".." + pr .BaseBranch
205
+ cmd := commitID [:git . SHAFullLength ] + ".." + pr .BaseBranch
206
206
207
207
// Get the commit from BaseBranch where the pull request got merged
208
208
mergeCommit , _ , err := git .NewCommand (ctx , "rev-list" , "--ancestry-path" , "--merges" , "--reverse" ).AddDynamicArguments (cmd ).
209
209
RunStdString (& git.RunOpts {Dir : "" , Env : []string {"GIT_INDEX_FILE=" + indexTmpPath , "GIT_DIR=" + pr .BaseRepo .RepoPath ()}})
210
210
if err != nil {
211
211
return nil , fmt .Errorf ("git rev-list --ancestry-path --merges --reverse: %w" , err )
212
- } else if len (mergeCommit ) < 40 {
212
+ } else if len (mergeCommit ) < git . SHAFullLength {
213
213
// PR was maybe fast-forwarded, so just use last commit of PR
214
- mergeCommit = commitID [:40 ]
214
+ mergeCommit = commitID [:git . SHAFullLength ]
215
215
}
216
216
217
217
gitRepo , err := git .OpenRepository (ctx , pr .BaseRepo .RepoPath ())
@@ -220,9 +220,9 @@ func getMergeCommit(ctx context.Context, pr *issues_model.PullRequest) (*git.Com
220
220
}
221
221
defer gitRepo .Close ()
222
222
223
- commit , err := gitRepo .GetCommit (mergeCommit [:40 ])
223
+ commit , err := gitRepo .GetCommit (mergeCommit [:git . SHAFullLength ])
224
224
if err != nil {
225
- return nil , fmt .Errorf ("GetMergeCommit[%v]: %w" , mergeCommit [:40 ], err )
225
+ return nil , fmt .Errorf ("GetMergeCommit[%v]: %w" , mergeCommit [:git . SHAFullLength ], err )
226
226
}
227
227
228
228
return commit , nil
0 commit comments