Skip to content

Commit 3edb1de

Browse files
committed
style: simplify embedded field selectors to fix QF1008 lint
Use opt.Args/opt.Envs instead of opt.CommandOptions.Args/opt.CommandOptions.Envs since CommandOptions is an embedded field.
1 parent 78b219b commit 3edb1de

11 files changed

Lines changed: 97 additions & 97 deletions

repo.go

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,12 @@ func Init(ctx context.Context, path string, opts ...InitOptions) error {
7575
}
7676

7777
args := []string{"init"}
78-
args = append(args, opt.CommandOptions.Args...)
78+
args = append(args, opt.Args...)
7979
if opt.Bare {
8080
args = append(args, "--bare")
8181
}
8282
args = append(args, "--end-of-options")
83-
_, err = gitRun(ctx, path, args, opt.CommandOptions.Envs)
83+
_, err = gitRun(ctx, path, args, opt.Envs)
8484
return err
8585
}
8686

@@ -133,7 +133,7 @@ func Clone(ctx context.Context, url, dst string, opts ...CloneOptions) error {
133133
}
134134

135135
args := []string{"clone"}
136-
args = append(args, opt.CommandOptions.Args...)
136+
args = append(args, opt.Args...)
137137
if opt.Mirror {
138138
args = append(args, "--mirror")
139139
}
@@ -151,7 +151,7 @@ func Clone(ctx context.Context, url, dst string, opts ...CloneOptions) error {
151151
}
152152

153153
args = append(args, "--end-of-options", url, dst)
154-
_, err = gitRun(ctx, "", args, opt.CommandOptions.Envs)
154+
_, err = gitRun(ctx, "", args, opt.Envs)
155155
return err
156156
}
157157

@@ -173,12 +173,12 @@ func (r *Repository) Fetch(ctx context.Context, opts ...FetchOptions) error {
173173
}
174174

175175
args := []string{"fetch"}
176-
args = append(args, opt.CommandOptions.Args...)
176+
args = append(args, opt.Args...)
177177
if opt.Prune {
178178
args = append(args, "--prune")
179179
}
180180

181-
_, err := gitRun(ctx, r.path, args, opt.CommandOptions.Envs)
181+
_, err := gitRun(ctx, r.path, args, opt.Envs)
182182
return err
183183
}
184184

@@ -206,7 +206,7 @@ func (r *Repository) Pull(ctx context.Context, opts ...PullOptions) error {
206206
}
207207

208208
args := []string{"pull"}
209-
args = append(args, opt.CommandOptions.Args...)
209+
args = append(args, opt.Args...)
210210
if opt.Rebase {
211211
args = append(args, "--rebase")
212212
}
@@ -220,7 +220,7 @@ func (r *Repository) Pull(ctx context.Context, opts ...PullOptions) error {
220220
}
221221
}
222222

223-
_, err := gitRun(ctx, r.path, args, opt.CommandOptions.Envs)
223+
_, err := gitRun(ctx, r.path, args, opt.Envs)
224224
return err
225225
}
226226

@@ -240,9 +240,9 @@ func (r *Repository) Push(ctx context.Context, remote, branch string, opts ...Pu
240240
}
241241

242242
args := []string{"push"}
243-
args = append(args, opt.CommandOptions.Args...)
243+
args = append(args, opt.Args...)
244244
args = append(args, "--end-of-options", remote, branch)
245-
_, err := gitRun(ctx, r.path, args, opt.CommandOptions.Envs)
245+
_, err := gitRun(ctx, r.path, args, opt.Envs)
246246
return err
247247
}
248248

@@ -264,7 +264,7 @@ func (r *Repository) Checkout(ctx context.Context, branch string, opts ...Checko
264264
}
265265

266266
args := []string{"checkout"}
267-
args = append(args, opt.CommandOptions.Args...)
267+
args = append(args, opt.Args...)
268268
if opt.BaseBranch != "" {
269269
args = append(args, "-b")
270270
}
@@ -273,7 +273,7 @@ func (r *Repository) Checkout(ctx context.Context, branch string, opts ...Checko
273273
args = append(args, opt.BaseBranch)
274274
}
275275

276-
_, err := gitRun(ctx, r.path, args, opt.CommandOptions.Envs)
276+
_, err := gitRun(ctx, r.path, args, opt.Envs)
277277
return err
278278
}
279279

@@ -298,10 +298,10 @@ func (r *Repository) Reset(ctx context.Context, rev string, opts ...ResetOptions
298298
if opt.Hard {
299299
args = append(args, "--hard")
300300
}
301-
args = append(args, opt.CommandOptions.Args...)
301+
args = append(args, opt.Args...)
302302
args = append(args, "--end-of-options", rev)
303303

304-
_, err := gitRun(ctx, r.path, args, opt.CommandOptions.Envs)
304+
_, err := gitRun(ctx, r.path, args, opt.Envs)
305305
return err
306306
}
307307

@@ -323,9 +323,9 @@ func (r *Repository) Move(ctx context.Context, src, dst string, opts ...MoveOpti
323323
}
324324

325325
args := []string{"mv"}
326-
args = append(args, opt.CommandOptions.Args...)
326+
args = append(args, opt.Args...)
327327
args = append(args, "--end-of-options", src, dst)
328-
_, err := gitRun(ctx, r.path, args, opt.CommandOptions.Envs)
328+
_, err := gitRun(ctx, r.path, args, opt.Envs)
329329
return err
330330
}
331331

@@ -349,15 +349,15 @@ func (r *Repository) Add(ctx context.Context, opts ...AddOptions) error {
349349
}
350350

351351
args := []string{"add"}
352-
args = append(args, opt.CommandOptions.Args...)
352+
args = append(args, opt.Args...)
353353
if opt.All {
354354
args = append(args, "--all")
355355
}
356356
if len(opt.Pathspecs) > 0 {
357357
args = append(args, "--")
358358
args = append(args, opt.Pathspecs...)
359359
}
360-
_, err := gitRun(ctx, r.path, args, opt.CommandOptions.Envs)
360+
_, err := gitRun(ctx, r.path, args, opt.Envs)
361361
return err
362362
}
363363

@@ -380,7 +380,7 @@ func (r *Repository) Commit(ctx context.Context, committer *Signature, message s
380380
}
381381

382382
envs := committerEnvs(committer)
383-
envs = append(envs, opt.CommandOptions.Envs...)
383+
envs = append(envs, opt.Envs...)
384384

385385
if opt.Author == nil {
386386
opt.Author = committer
@@ -389,7 +389,7 @@ func (r *Repository) Commit(ctx context.Context, committer *Signature, message s
389389
args := []string{"commit"}
390390
args = append(args, fmt.Sprintf("--author='%s <%s>'", opt.Author.Name, opt.Author.Email))
391391
args = append(args, "-m", message)
392-
args = append(args, opt.CommandOptions.Args...)
392+
args = append(args, opt.Args...)
393393

394394
_, err := gitRun(ctx, r.path, args, envs)
395395
// No stderr but exit status 1 means nothing to commit.
@@ -445,11 +445,11 @@ func (r *Repository) ShowNameStatus(ctx context.Context, rev string, opts ...Sho
445445
}()
446446

447447
args := []string{"show", "--name-status", "--pretty=format:''"}
448-
args = append(args, opt.CommandOptions.Args...)
448+
args = append(args, opt.Args...)
449449
args = append(args, "--end-of-options", rev)
450450

451451
stderr := new(bytes.Buffer)
452-
err := gitPipeline(ctx, r.path, args, opt.CommandOptions.Envs, w, stderr, nil)
452+
err := gitPipeline(ctx, r.path, args, opt.Envs, w, stderr, nil)
453453
_ = w.Close() // Close writer to exit parsing goroutine
454454
if err != nil {
455455
return nil, concatenateError(err, stderr.String())
@@ -476,10 +476,10 @@ func (r *Repository) RevParse(ctx context.Context, rev string, opts ...RevParseO
476476
}
477477

478478
args := []string{"rev-parse"}
479-
args = append(args, opt.CommandOptions.Args...)
479+
args = append(args, opt.Args...)
480480
args = append(args, rev)
481481

482-
commitID, err := gitRun(ctx, r.path, args, opt.CommandOptions.Envs)
482+
commitID, err := gitRun(ctx, r.path, args, opt.Envs)
483483
if err != nil {
484484
if strings.Contains(err.Error(), "exit status 128") {
485485
return "", ErrRevisionNotExist
@@ -517,9 +517,9 @@ func (r *Repository) CountObjects(ctx context.Context, opts ...CountObjectsOptio
517517
}
518518

519519
args := []string{"count-objects", "-v"}
520-
args = append(args, opt.CommandOptions.Args...)
520+
args = append(args, opt.Args...)
521521

522-
stdout, err := gitRun(ctx, r.path, args, opt.CommandOptions.Envs)
522+
stdout, err := gitRun(ctx, r.path, args, opt.Envs)
523523
if err != nil {
524524
return nil, err
525525
}
@@ -571,7 +571,7 @@ func (r *Repository) Fsck(ctx context.Context, opts ...FsckOptions) error {
571571
}
572572

573573
args := []string{"fsck"}
574-
args = append(args, opt.CommandOptions.Args...)
575-
_, err := gitRun(ctx, r.path, args, opt.CommandOptions.Envs)
574+
args = append(args, opt.Args...)
575+
_, err := gitRun(ctx, r.path, args, opt.Envs)
576576
return err
577577
}

repo_blame.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ func (r *Repository) Blame(ctx context.Context, rev, file string, opts ...BlameO
2525
}
2626

2727
args := []string{"blame"}
28-
args = append(args, opt.CommandOptions.Args...)
28+
args = append(args, opt.Args...)
2929
args = append(args, "-l", "-s", rev, "--", file)
3030

31-
stdout, err := gitRun(ctx, r.path, args, opt.CommandOptions.Envs)
31+
stdout, err := gitRun(ctx, r.path, args, opt.Envs)
3232
if err != nil {
3333
return nil, err
3434
}

repo_commit.go

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,10 @@ func (r *Repository) CatFileCommit(ctx context.Context, rev string, opts ...CatF
9595
}
9696

9797
args := []string{"cat-file"}
98-
args = append(args, opt.CommandOptions.Args...)
98+
args = append(args, opt.Args...)
9999
args = append(args, "commit", commitID)
100100

101-
stdout, err := gitRun(ctx, r.path, args, opt.CommandOptions.Envs)
101+
stdout, err := gitRun(ctx, r.path, args, opt.Envs)
102102
if err != nil {
103103
return nil, err
104104
}
@@ -130,10 +130,10 @@ func (r *Repository) CatFileType(ctx context.Context, rev string, opts ...CatFil
130130
}
131131

132132
args := []string{"cat-file"}
133-
args = append(args, opt.CommandOptions.Args...)
133+
args = append(args, opt.Args...)
134134
args = append(args, "-t", rev)
135135

136-
typ, err := gitRun(ctx, r.path, args, opt.CommandOptions.Envs)
136+
typ, err := gitRun(ctx, r.path, args, opt.Envs)
137137
if err != nil {
138138
return "", err
139139
}
@@ -194,7 +194,7 @@ func (r *Repository) Log(ctx context.Context, rev string, opts ...LogOptions) ([
194194
}
195195

196196
args := []string{"log"}
197-
args = append(args, opt.CommandOptions.Args...)
197+
args = append(args, opt.Args...)
198198
args = append(args, "--pretty="+LogFormatHashOnly)
199199
if opt.MaxCount > 0 {
200200
args = append(args, "--max-count="+strconv.Itoa(opt.MaxCount))
@@ -216,7 +216,7 @@ func (r *Repository) Log(ctx context.Context, rev string, opts ...LogOptions) ([
216216
args = append(args, escapePath(opt.Path))
217217
}
218218

219-
stdout, err := gitRun(ctx, r.path, args, opt.CommandOptions.Envs)
219+
stdout, err := gitRun(ctx, r.path, args, opt.Envs)
220220
if err != nil {
221221
return nil, err
222222
}
@@ -359,7 +359,7 @@ func (r *Repository) DiffNameOnly(ctx context.Context, base, head string, opts .
359359
}
360360

361361
args := []string{"diff"}
362-
args = append(args, opt.CommandOptions.Args...)
362+
args = append(args, opt.Args...)
363363
args = append(args, "--name-only", "--end-of-options")
364364
if opt.NeedsMergeBase {
365365
args = append(args, base+"..."+head)
@@ -371,7 +371,7 @@ func (r *Repository) DiffNameOnly(ctx context.Context, base, head string, opts .
371371
args = append(args, escapePath(opt.Path))
372372
}
373373

374-
stdout, err := gitRun(ctx, r.path, args, opt.CommandOptions.Envs)
374+
stdout, err := gitRun(ctx, r.path, args, opt.Envs)
375375
if err != nil {
376376
return nil, err
377377
}
@@ -411,15 +411,15 @@ func (r *Repository) RevListCount(ctx context.Context, refspecs []string, opts .
411411
}
412412

413413
args := []string{"rev-list"}
414-
args = append(args, opt.CommandOptions.Args...)
414+
args = append(args, opt.Args...)
415415
args = append(args, "--count", "--end-of-options")
416416
args = append(args, refspecs...)
417417
args = append(args, "--")
418418
if opt.Path != "" {
419419
args = append(args, escapePath(opt.Path))
420420
}
421421

422-
stdout, err := gitRun(ctx, r.path, args, opt.CommandOptions.Envs)
422+
stdout, err := gitRun(ctx, r.path, args, opt.Envs)
423423
if err != nil {
424424
return 0, err
425425
}
@@ -450,15 +450,15 @@ func (r *Repository) RevList(ctx context.Context, refspecs []string, opts ...Rev
450450
}
451451

452452
args := []string{"rev-list"}
453-
args = append(args, opt.CommandOptions.Args...)
453+
args = append(args, opt.Args...)
454454
args = append(args, "--end-of-options")
455455
args = append(args, refspecs...)
456456
args = append(args, "--")
457457
if opt.Path != "" {
458458
args = append(args, escapePath(opt.Path))
459459
}
460460

461-
stdout, err := gitRun(ctx, r.path, args, opt.CommandOptions.Envs)
461+
stdout, err := gitRun(ctx, r.path, args, opt.Envs)
462462
if err != nil {
463463
return nil, err
464464
}
@@ -482,13 +482,13 @@ func (r *Repository) LatestCommitTime(ctx context.Context, opts ...LatestCommitT
482482
}
483483

484484
args := []string{"for-each-ref"}
485-
args = append(args, opt.CommandOptions.Args...)
485+
args = append(args, opt.Args...)
486486
args = append(args, "--count=1", "--sort=-committerdate", "--format=%(committerdate:iso8601)")
487487
if opt.Branch != "" {
488488
args = append(args, RefsHeads+opt.Branch)
489489
}
490490

491-
stdout, err := gitRun(ctx, r.path, args, opt.CommandOptions.Envs)
491+
stdout, err := gitRun(ctx, r.path, args, opt.Envs)
492492
if err != nil {
493493
return time.Time{}, err
494494
}

0 commit comments

Comments
 (0)