77package git
88
99import (
10+ "context"
1011 "sort"
1112 "strings"
1213
@@ -17,9 +18,9 @@ import (
1718// IsObjectExist returns true if the given object exists in the repository.
1819// FIXME: Inconsistent behavior with nogogit edition
1920// Unlike the implementation of IsObjectExist in nogogit edition, it does not support short hashes here.
20- // For example, IsObjectExist("153f451") will return false, but it will return true in nogogit edition.
21+ // For example, IsObjectExist(ctx, "153f451") will return false, but it will return true in nogogit edition.
2122// To fix this, the solution could be adding support for short hashes in gogit edition if it's really needed.
22- func (repo * Repository ) IsObjectExist (name string ) bool {
23+ func (repo * Repository ) IsObjectExist (ctx context. Context , name string ) bool {
2324 if name == "" {
2425 return false
2526 }
@@ -33,7 +34,7 @@ func (repo *Repository) IsObjectExist(name string) bool {
3334// Unlike the implementation of IsObjectExist in nogogit edition, it does not support blob hashes here.
3435// For example, IsObjectExist([existing_blob_hash]) will return false, but it will return true in nogogit edition.
3536// To fix this, the solution could be refusing to support blob hashes in nogogit edition since a blob hash is not a reference.
36- func (repo * Repository ) IsReferenceExist (name string ) bool {
37+ func (repo * Repository ) IsReferenceExist (ctx context. Context , name string ) bool {
3738 if name == "" {
3839 return false
3940 }
@@ -44,7 +45,7 @@ func (repo *Repository) IsReferenceExist(name string) bool {
4445}
4546
4647// IsBranchExist returns true if given branch exists in current repository.
47- func (repo * Repository ) IsBranchExist (name string ) bool {
48+ func (repo * Repository ) IsBranchExist (ctx context. Context , name string ) bool {
4849 if name == "" {
4950 return false
5051 }
@@ -60,7 +61,7 @@ func (repo *Repository) IsBranchExist(name string) bool {
6061// Branches are returned with sort of `-committerdate` as the nogogit
6162// implementation. This requires full fetch, sort and then the
6263// skip/limit applies later as gogit returns in undefined order.
63- func (repo * Repository ) GetBranchNames (skip , limit int ) ([]string , int , error ) {
64+ func (repo * Repository ) GetBranchNames (ctx context. Context , skip , limit int ) ([]string , int , error ) {
6465 type BranchData struct {
6566 name string
6667 committerDate int64
@@ -136,7 +137,7 @@ func (repo *Repository) WalkReferences(arg ObjectType, skip, limit int, walkfn f
136137}
137138
138139// GetRefsBySha returns all references filtered with prefix that belong to a sha commit hash
139- func (repo * Repository ) GetRefsBySha (sha , prefix string ) ([]string , error ) {
140+ func (repo * Repository ) GetRefsBySha (ctx context. Context , sha , prefix string ) ([]string , error ) {
140141 var revList []string
141142 iter , err := repo .gogitRepo .References ()
142143 if err != nil {
0 commit comments