From 9d373cbeb54538eb259d58e5e5cf8460124925e8 Mon Sep 17 00:00:00 2001 From: elad-codefresh Date: Mon, 29 Nov 2021 09:44:07 +0200 Subject: [PATCH 1/3] CreateIfNotExist public --- pkg/git/repository.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/git/repository.go b/pkg/git/repository.go index de80a9d1..8c21053d 100644 --- a/pkg/git/repository.go +++ b/pkg/git/repository.go @@ -53,10 +53,10 @@ type ( Auth Auth FS fs.FS Progress io.Writer + CreateIfNotExist bool url string revision string path string - createIfNotExist bool } PushOptions struct { From 9eddca3728f5c9f7682ae200546541c4d8bfa84b Mon Sep 17 00:00:00 2001 From: elad-codefresh Date: Mon, 29 Nov 2021 09:44:07 +0200 Subject: [PATCH 2/3] cap --- pkg/git/repository.go | 4 ++-- pkg/git/repository_test.go | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/pkg/git/repository.go b/pkg/git/repository.go index 8c21053d..252112a7 100644 --- a/pkg/git/repository.go +++ b/pkg/git/repository.go @@ -121,7 +121,7 @@ var ( func AddFlags(cmd *cobra.Command, opts *AddFlagsOptions) *CloneOptions { co := &CloneOptions{ FS: fs.Create(opts.FS), - createIfNotExist: opts.CreateIfNotExist, + CreateIfNotExist: opts.CreateIfNotExist, } if opts.Prefix != "" && !strings.HasSuffix(opts.Prefix, "-") { @@ -182,7 +182,7 @@ func (o *CloneOptions) GetRepo(ctx context.Context) (Repository, fs.FS, error) { if err != nil { switch err { case transport.ErrRepositoryNotFound: - if !o.createIfNotExist { + if !o.CreateIfNotExist { return nil, nil, err } diff --git a/pkg/git/repository_test.go b/pkg/git/repository_test.go index e9531d5b..a5db5882 100644 --- a/pkg/git/repository_test.go +++ b/pkg/git/repository_test.go @@ -491,10 +491,10 @@ func TestGetRepo(t *testing.T) { assert.Error(t, transport.ErrRepositoryNotFound, e) }, }, - "Should fail when createIfNotExist is true and create fails": { + "Should fail when CreateIfNotExist is true and create fails": { opts: &CloneOptions{ Repo: "https://github.com/owner/name", - createIfNotExist: true, + CreateIfNotExist: true, }, wantErr: "some error", cloneFn: func(_ context.Context, opts *CloneOptions) (*repo, error) { @@ -526,10 +526,10 @@ func TestGetRepo(t *testing.T) { assert.EqualError(t, e, "failed to initialize repository: some error") }, }, - "Should create and init repo when createIfNotExist is true": { + "Should create and init repo when CreateIfNotExist is true": { opts: &CloneOptions{ Repo: "https://github.com/owner/name", - createIfNotExist: true, + CreateIfNotExist: true, FS: fs.Create(memfs.New()), }, wantErr: "some error", From 844edfa81968fee1a6cef53d4996df4434f716c9 Mon Sep 17 00:00:00 2001 From: elad-codefresh Date: Mon, 29 Nov 2021 11:02:49 +0200 Subject: [PATCH 3/3] C --- pkg/git/repository.go | 2 +- pkg/git/repository_test.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/git/repository.go b/pkg/git/repository.go index 252112a7..01d3aefc 100644 --- a/pkg/git/repository.go +++ b/pkg/git/repository.go @@ -330,7 +330,7 @@ var clone = func(ctx context.Context, opts *CloneOptions) (*repo, error) { log.G(ctx).WithField("url", opts.url).Debug("cloning git repo") - if opts.createIfNotExist { + if opts.CreateIfNotExist { curPushRetries = 1 // no retries } diff --git a/pkg/git/repository_test.go b/pkg/git/repository_test.go index a5db5882..fcfe2ef7 100644 --- a/pkg/git/repository_test.go +++ b/pkg/git/repository_test.go @@ -369,10 +369,10 @@ func Test_clone(t *testing.T) { retErr: transport.ErrRepositoryNotFound, wantErr: true, }, - "Should not retry if createIfNotExist is true": { + "Should not retry if CreateIfNotExist is true": { opts: &CloneOptions{ Repo: "https://github.com/owner/name", - createIfNotExist: true, + CreateIfNotExist: true, }, expectedOpts: &gg.CloneOptions{ URL: "https://github.com/owner/name.git",