@@ -18,6 +18,7 @@ import (
18
18
"cmd/go/internal/load"
19
19
"cmd/go/internal/search"
20
20
"cmd/go/internal/str"
21
+ "cmd/go/internal/vcs"
21
22
"cmd/go/internal/web"
22
23
"cmd/go/internal/work"
23
24
@@ -406,7 +407,7 @@ func download(arg string, parent *load.Package, stk *load.ImportStack, mode int)
406
407
// to make the first copy of or update a copy of the given package.
407
408
func downloadPackage (p * load.Package ) error {
408
409
var (
409
- vcs * vcsCmd
410
+ vcsCmd * vcs. Cmd
410
411
repo , rootPath string
411
412
err error
412
413
blindRepo bool // set if the repo has unusual configuration
@@ -435,27 +436,27 @@ func downloadPackage(p *load.Package) error {
435
436
436
437
if p .Internal .Build .SrcRoot != "" {
437
438
// Directory exists. Look for checkout along path to src.
438
- vcs , rootPath , err = vcsFromDir (p .Dir , p .Internal .Build .SrcRoot )
439
+ vcsCmd , rootPath , err = vcs . FromDir (p .Dir , p .Internal .Build .SrcRoot )
439
440
if err != nil {
440
441
return err
441
442
}
442
443
repo = "<local>" // should be unused; make distinctive
443
444
444
445
// Double-check where it came from.
445
- if * getU && vcs . remoteRepo != nil {
446
+ if * getU && vcsCmd . RemoteRepo != nil {
446
447
dir := filepath .Join (p .Internal .Build .SrcRoot , filepath .FromSlash (rootPath ))
447
- remote , err := vcs . remoteRepo ( vcs , dir )
448
+ remote , err := vcsCmd . RemoteRepo ( vcsCmd , dir )
448
449
if err != nil {
449
450
// Proceed anyway. The package is present; we likely just don't understand
450
451
// the repo configuration (e.g. unusual remote protocol).
451
452
blindRepo = true
452
453
}
453
454
repo = remote
454
455
if ! * getF && err == nil {
455
- if rr , err := RepoRootForImportPath (importPrefix , IgnoreMod , security ); err == nil {
456
+ if rr , err := vcs . RepoRootForImportPath (importPrefix , vcs . IgnoreMod , security ); err == nil {
456
457
repo := rr .Repo
457
- if rr .vcs . resolveRepo != nil {
458
- resolved , err := rr .vcs . resolveRepo (rr .vcs , dir , repo )
458
+ if rr .VCS . ResolveRepo != nil {
459
+ resolved , err := rr .VCS . ResolveRepo (rr .VCS , dir , repo )
459
460
if err == nil {
460
461
repo = resolved
461
462
}
@@ -469,13 +470,13 @@ func downloadPackage(p *load.Package) error {
469
470
} else {
470
471
// Analyze the import path to determine the version control system,
471
472
// repository, and the import path for the root of the repository.
472
- rr , err := RepoRootForImportPath (importPrefix , IgnoreMod , security )
473
+ rr , err := vcs . RepoRootForImportPath (importPrefix , vcs . IgnoreMod , security )
473
474
if err != nil {
474
475
return err
475
476
}
476
- vcs , repo , rootPath = rr .vcs , rr .Repo , rr .Root
477
+ vcsCmd , repo , rootPath = rr .VCS , rr .Repo , rr .Root
477
478
}
478
- if ! blindRepo && ! vcs . isSecure (repo ) && security != web .Insecure {
479
+ if ! blindRepo && ! vcsCmd . IsSecure (repo ) && security != web .Insecure {
479
480
return fmt .Errorf ("cannot download, %v uses insecure protocol" , repo )
480
481
}
481
482
@@ -498,7 +499,7 @@ func downloadPackage(p *load.Package) error {
498
499
}
499
500
root := filepath .Join (p .Internal .Build .SrcRoot , filepath .FromSlash (rootPath ))
500
501
501
- if err := checkNestedVCS ( vcs , root , p .Internal .Build .SrcRoot ); err != nil {
502
+ if err := vcs . CheckNested ( vcsCmd , root , p .Internal .Build .SrcRoot ); err != nil {
502
503
return err
503
504
}
504
505
@@ -514,7 +515,7 @@ func downloadPackage(p *load.Package) error {
514
515
515
516
// Check that this is an appropriate place for the repo to be checked out.
516
517
// The target directory must either not exist or have a repo checked out already.
517
- meta := filepath .Join (root , "." + vcs . cmd )
518
+ meta := filepath .Join (root , "." + vcsCmd . Cmd )
518
519
if _ , err := os .Stat (meta ); err != nil {
519
520
// Metadata file or directory does not exist. Prepare to checkout new copy.
520
521
// Some version control tools require the target directory not to exist.
@@ -535,12 +536,12 @@ func downloadPackage(p *load.Package) error {
535
536
fmt .Fprintf (os .Stderr , "created GOPATH=%s; see 'go help gopath'\n " , p .Internal .Build .Root )
536
537
}
537
538
538
- if err = vcs . create (root , repo ); err != nil {
539
+ if err = vcsCmd . Create (root , repo ); err != nil {
539
540
return err
540
541
}
541
542
} else {
542
543
// Metadata directory does exist; download incremental updates.
543
- if err = vcs . download (root ); err != nil {
544
+ if err = vcsCmd . Download (root ); err != nil {
544
545
return err
545
546
}
546
547
}
@@ -549,20 +550,20 @@ func downloadPackage(p *load.Package) error {
549
550
// Do not show tag sync in -n; it's noise more than anything,
550
551
// and since we're not running commands, no tag will be found.
551
552
// But avoid printing nothing.
552
- fmt .Fprintf (os .Stderr , "# cd %s; %s sync/update\n " , root , vcs . cmd )
553
+ fmt .Fprintf (os .Stderr , "# cd %s; %s sync/update\n " , root , vcsCmd . Cmd )
553
554
return nil
554
555
}
555
556
556
557
// Select and sync to appropriate version of the repository.
557
- tags , err := vcs . tags (root )
558
+ tags , err := vcsCmd . Tags (root )
558
559
if err != nil {
559
560
return err
560
561
}
561
562
vers := runtime .Version ()
562
563
if i := strings .Index (vers , " " ); i >= 0 {
563
564
vers = vers [:i ]
564
565
}
565
- if err := vcs . tagSync (root , selectTag (vers , tags )); err != nil {
566
+ if err := vcsCmd . TagSync (root , selectTag (vers , tags )); err != nil {
566
567
return err
567
568
}
568
569
0 commit comments