@@ -23,52 +23,52 @@ import (
2323 "time"
2424
2525 "github.com/Masterminds/semver/v3"
26- "github.com/go-git/go-git/v5"
26+ extgogit "github.com/go-git/go-git/v5"
2727 "github.com/go-git/go-git/v5/plumbing"
2828
2929 "github.com/fluxcd/pkg/version"
3030
3131 sourcev1 "github.com/fluxcd/source-controller/api/v1beta1"
32- "github.com/fluxcd/source-controller/pkg/git/common "
32+ "github.com/fluxcd/source-controller/pkg/git"
3333)
3434
35- func CheckoutStrategyForRef (ref * sourcev1.GitRepositoryRef ) common .CheckoutStrategy {
35+ func CheckoutStrategyForRef (ref * sourcev1.GitRepositoryRef ) git .CheckoutStrategy {
3636 switch {
3737 case ref == nil :
38- return & CheckoutBranch {branch : common .DefaultBranch }
38+ return & CheckoutBranch {branch : git .DefaultBranch }
3939 case ref .SemVer != "" :
4040 return & CheckoutSemVer {semVer : ref .SemVer }
4141 case ref .Tag != "" :
4242 return & CheckoutTag {tag : ref .Tag }
4343 case ref .Commit != "" :
4444 strategy := & CheckoutCommit {branch : ref .Branch , commit : ref .Commit }
4545 if strategy .branch == "" {
46- strategy .branch = common .DefaultBranch
46+ strategy .branch = git .DefaultBranch
4747 }
4848 return strategy
4949 case ref .Branch != "" :
5050 return & CheckoutBranch {branch : ref .Branch }
5151 default :
52- return & CheckoutBranch {branch : common .DefaultBranch }
52+ return & CheckoutBranch {branch : git .DefaultBranch }
5353 }
5454}
5555
5656type CheckoutBranch struct {
5757 branch string
5858}
5959
60- func (c * CheckoutBranch ) Checkout (ctx context.Context , path , url string , auth * common .Auth ) (common .Commit , string , error ) {
61- repo , err := git .PlainCloneContext (ctx , path , false , & git .CloneOptions {
60+ func (c * CheckoutBranch ) Checkout (ctx context.Context , path , url string , auth * git .Auth ) (git .Commit , string , error ) {
61+ repo , err := extgogit .PlainCloneContext (ctx , path , false , & extgogit .CloneOptions {
6262 URL : url ,
6363 Auth : auth .AuthMethod ,
64- RemoteName : common .DefaultOrigin ,
64+ RemoteName : git .DefaultOrigin ,
6565 ReferenceName : plumbing .NewBranchReferenceName (c .branch ),
6666 SingleBranch : true ,
6767 NoCheckout : false ,
6868 Depth : 1 ,
6969 RecurseSubmodules : 0 ,
7070 Progress : nil ,
71- Tags : git .NoTags ,
71+ Tags : extgogit .NoTags ,
7272 })
7373 if err != nil {
7474 return nil , "" , fmt .Errorf ("unable to clone '%s', error: %w" , url , err )
@@ -88,18 +88,18 @@ type CheckoutTag struct {
8888 tag string
8989}
9090
91- func (c * CheckoutTag ) Checkout (ctx context.Context , path , url string , auth * common .Auth ) (common .Commit , string , error ) {
92- repo , err := git .PlainCloneContext (ctx , path , false , & git .CloneOptions {
91+ func (c * CheckoutTag ) Checkout (ctx context.Context , path , url string , auth * git .Auth ) (git .Commit , string , error ) {
92+ repo , err := extgogit .PlainCloneContext (ctx , path , false , & extgogit .CloneOptions {
9393 URL : url ,
9494 Auth : auth .AuthMethod ,
95- RemoteName : common .DefaultOrigin ,
95+ RemoteName : git .DefaultOrigin ,
9696 ReferenceName : plumbing .NewTagReferenceName (c .tag ),
9797 SingleBranch : true ,
9898 NoCheckout : false ,
9999 Depth : 1 ,
100100 RecurseSubmodules : 0 ,
101101 Progress : nil ,
102- Tags : git .NoTags ,
102+ Tags : extgogit .NoTags ,
103103 })
104104 if err != nil {
105105 return nil , "" , fmt .Errorf ("unable to clone '%s', error: %w" , url , err )
@@ -120,17 +120,17 @@ type CheckoutCommit struct {
120120 commit string
121121}
122122
123- func (c * CheckoutCommit ) Checkout (ctx context.Context , path , url string , auth * common .Auth ) (common .Commit , string , error ) {
124- repo , err := git .PlainCloneContext (ctx , path , false , & git .CloneOptions {
123+ func (c * CheckoutCommit ) Checkout (ctx context.Context , path , url string , auth * git .Auth ) (git .Commit , string , error ) {
124+ repo , err := extgogit .PlainCloneContext (ctx , path , false , & extgogit .CloneOptions {
125125 URL : url ,
126126 Auth : auth .AuthMethod ,
127- RemoteName : common .DefaultOrigin ,
127+ RemoteName : git .DefaultOrigin ,
128128 ReferenceName : plumbing .NewBranchReferenceName (c .branch ),
129129 SingleBranch : true ,
130130 NoCheckout : false ,
131131 RecurseSubmodules : 0 ,
132132 Progress : nil ,
133- Tags : git .NoTags ,
133+ Tags : extgogit .NoTags ,
134134 })
135135 if err != nil {
136136 return nil , "" , fmt .Errorf ("unable to clone '%s', error: %w" , url , err )
@@ -143,7 +143,7 @@ func (c *CheckoutCommit) Checkout(ctx context.Context, path, url string, auth *c
143143 if err != nil {
144144 return nil , "" , fmt .Errorf ("git commit '%s' not found: %w" , c .commit , err )
145145 }
146- err = w .Checkout (& git .CheckoutOptions {
146+ err = w .Checkout (& extgogit .CheckoutOptions {
147147 Hash : commit .Hash ,
148148 Force : true ,
149149 })
@@ -157,21 +157,21 @@ type CheckoutSemVer struct {
157157 semVer string
158158}
159159
160- func (c * CheckoutSemVer ) Checkout (ctx context.Context , path , url string , auth * common .Auth ) (common .Commit , string , error ) {
160+ func (c * CheckoutSemVer ) Checkout (ctx context.Context , path , url string , auth * git .Auth ) (git .Commit , string , error ) {
161161 verConstraint , err := semver .NewConstraint (c .semVer )
162162 if err != nil {
163163 return nil , "" , fmt .Errorf ("semver parse range error: %w" , err )
164164 }
165165
166- repo , err := git .PlainCloneContext (ctx , path , false , & git .CloneOptions {
166+ repo , err := extgogit .PlainCloneContext (ctx , path , false , & extgogit .CloneOptions {
167167 URL : url ,
168168 Auth : auth .AuthMethod ,
169- RemoteName : common .DefaultOrigin ,
169+ RemoteName : git .DefaultOrigin ,
170170 NoCheckout : false ,
171171 Depth : 1 ,
172172 RecurseSubmodules : 0 ,
173173 Progress : nil ,
174- Tags : git .AllTags ,
174+ Tags : extgogit .AllTags ,
175175 })
176176 if err != nil {
177177 return nil , "" , fmt .Errorf ("unable to clone '%s', error: %w" , url , err )
@@ -238,7 +238,7 @@ func (c *CheckoutSemVer) Checkout(ctx context.Context, path, url string, auth *c
238238 return nil , "" , fmt .Errorf ("git worktree error: %w" , err )
239239 }
240240
241- err = w .Checkout (& git .CheckoutOptions {
241+ err = w .Checkout (& extgogit .CheckoutOptions {
242242 Branch : plumbing .NewTagReferenceName (t ),
243243 })
244244 if err != nil {
0 commit comments