Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CR-7821 #212

Merged
merged 3 commits into from
Nov 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions pkg/git/repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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, "-") {
Expand Down Expand Up @@ -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
}

Expand Down Expand Up @@ -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
}

Expand Down
12 changes: 6 additions & 6 deletions pkg/git/repository_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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",
Expand Down