@@ -6,6 +6,7 @@ package git
6
6
7
7
import (
8
8
"bytes"
9
+ "context"
9
10
"io"
10
11
"os"
11
12
"strconv"
@@ -53,13 +54,13 @@ func (repo *Repository) GetTagCommit(name string) (*Commit, error) {
53
54
return repo .GetCommit (commitID )
54
55
}
55
56
56
- func (repo * Repository ) getCommitByPathWithID (id ObjectID , relpath string ) (* Commit , error ) {
57
+ func (repo * Repository ) getCommitByPathWithID (ctx context. Context , id ObjectID , relpath string ) (* Commit , error ) {
57
58
// File name starts with ':' must be escaped.
58
59
if relpath [0 ] == ':' {
59
60
relpath = `\` + relpath
60
61
}
61
62
62
- stdout , _ , runErr := NewCommand ("log" , "-1" , prettyLogFormat ).AddDynamicArguments (id .String ()).AddDashesAndList (relpath ).RunStdString (repo . Ctx , & RunOpts {Dir : repo .Path })
63
+ stdout , _ , runErr := NewCommand ("log" , "-1" , prettyLogFormat ).AddDynamicArguments (id .String ()).AddDashesAndList (relpath ).RunStdString (ctx , & RunOpts {Dir : repo .Path })
63
64
if runErr != nil {
64
65
return nil , runErr
65
66
}
@@ -375,16 +376,16 @@ func (repo *Repository) CommitsBetweenIDs(last, before string) ([]*Commit, error
375
376
}
376
377
377
378
// CommitsCountBetween return numbers of commits between two commits
378
- func (repo * Repository ) CommitsCountBetween (start , end string ) (int64 , error ) {
379
- count , err := CommitsCount (repo . Ctx , CommitsCountOptions {
379
+ func (repo * Repository ) CommitsCountBetween (ctx context. Context , start , end string ) (int64 , error ) {
380
+ count , err := CommitsCount (ctx , CommitsCountOptions {
380
381
RepoPath : repo .Path ,
381
382
Revision : []string {start + ".." + end },
382
383
})
383
384
384
385
if err != nil && strings .Contains (err .Error (), "no merge base" ) {
385
386
// future versions of git >= 2.28 are likely to return an error if before and last have become unrelated.
386
387
// previously it would return the results of git rev-list before last so let's try that...
387
- return CommitsCount (repo . Ctx , CommitsCountOptions {
388
+ return CommitsCount (ctx , CommitsCountOptions {
388
389
RepoPath : repo .Path ,
389
390
Revision : []string {start , end },
390
391
})
0 commit comments