Skip to content
This repository was archived by the owner on Sep 9, 2020. It is now read-only.

Commit ebf6207

Browse files
committed
ensure: cleanup
1 parent 8711fc0 commit ebf6207

File tree

1 file changed

+20
-20
lines changed

1 file changed

+20
-20
lines changed

cmd/dep/ensure.go

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -769,11 +769,11 @@ func (e pkgtreeErrs) Error() string {
769769
}
770770

771771
func validateUpdateArgs(ctx *dep.Ctx, args []string, p *dep.Project, sm gps.SourceManager, params *gps.SolveParameters) error {
772-
// Channel for receiving all the valid arguments
773-
validArgsCh := make(chan string, len(args))
772+
// Channel for receiving all the valid arguments.
773+
argsCh := make(chan string, len(args))
774774

775-
// Channel for receiving all the validation errors
776-
errArgsValidationCh := make(chan error, len(args))
775+
// Channel for receiving all the validation errors.
776+
errCh := make(chan error, len(args))
777777

778778
var wg sync.WaitGroup
779779

@@ -785,57 +785,57 @@ func validateUpdateArgs(ctx *dep.Ctx, args []string, p *dep.Project, sm gps.Sour
785785
go func(arg string) {
786786
defer wg.Done()
787787

788-
// Ensure the provided path has a deducible project root
788+
// Ensure the provided path has a deducible project root.
789789
pc, path, err := getProjectConstraint(arg, sm)
790790
if err != nil {
791791
// TODO(sdboyer) ensure these errors are contextualized in a sensible way for -update
792-
errArgsValidationCh <- err
792+
errCh <- err
793793
return
794794
}
795795
if path != string(pc.Ident.ProjectRoot) {
796796
// TODO(sdboyer): does this really merit an abortive error?
797-
errArgsValidationCh <- errors.Errorf("%s is not a project root, try %s instead", path, pc.Ident.ProjectRoot)
797+
errCh <- errors.Errorf("%s is not a project root, try %s instead", path, pc.Ident.ProjectRoot)
798798
return
799799
}
800800

801801
if !p.Lock.HasProjectWithRoot(pc.Ident.ProjectRoot) {
802-
errArgsValidationCh <- errors.Errorf("%s is not present in %s, cannot -update it", pc.Ident.ProjectRoot, dep.LockName)
802+
errCh <- errors.Errorf("%s is not present in %s, cannot -update it", pc.Ident.ProjectRoot, dep.LockName)
803803
return
804804
}
805805

806806
if pc.Ident.Source != "" {
807-
errArgsValidationCh <- errors.Errorf("cannot specify alternate sources on -update (%s)", pc.Ident.Source)
807+
errCh <- errors.Errorf("cannot specify alternate sources on -update (%s)", pc.Ident.Source)
808808
return
809809
}
810810

811811
if !gps.IsAny(pc.Constraint) {
812812
// TODO(sdboyer) constraints should be allowed to allow solves that
813-
// target particular versions while remaining within declared constraints
814-
errArgsValidationCh <- errors.Errorf("version constraint %s passed for %s, but -update follows constraints declared in %s, not CLI arguments", pc.Constraint, pc.Ident.ProjectRoot, dep.ManifestName)
813+
// target particular versions while remaining within declared constraints.
814+
errCh <- errors.Errorf("version constraint %s passed for %s, but -update follows constraints declared in %s, not CLI arguments", pc.Constraint, pc.Ident.ProjectRoot, dep.ManifestName)
815815
return
816816
}
817817

818-
// Valid argument
819-
validArgsCh <- arg
818+
// Valid argument.
819+
argsCh <- arg
820820
}(arg)
821821
}
822822

823823
wg.Wait()
824-
close(errArgsValidationCh)
825-
close(validArgsCh)
824+
close(errCh)
825+
close(argsCh)
826826

827-
// Log all the errors
828-
if len(errArgsValidationCh) > 0 {
827+
// Log all the errors.
828+
if len(errCh) > 0 {
829829
ctx.Err.Printf("Invalid arguments passed to ensure -update:\n\n")
830-
for err := range errArgsValidationCh {
830+
for err := range errCh {
831831
ctx.Err.Println(" ✗", err.Error())
832832
}
833833
ctx.Err.Println()
834834
return errUpdateArgsValidation
835835
}
836836

837-
// Add all the valid arguments to solve params
838-
for arg := range validArgsCh {
837+
// Add all the valid arguments to solve params.
838+
for arg := range argsCh {
839839
params.ToChange = append(params.ToChange, gps.ProjectRoot(arg))
840840
}
841841

0 commit comments

Comments
 (0)