Cleanup from go reportcard
diff --git a/cfg/lock_test.go b/cfg/lock_test.go index 81edcd0..b6bb31e 100644 --- a/cfg/lock_test.go +++ b/cfg/lock_test.go
@@ -107,6 +107,6 @@ } if !strings.Contains(string(out), expectSubpkgYaml) { - t.Errorf("Expected %q\nto contain\n%q") + t.Errorf("Expected %q\n to contain\n%q", string(out), expectSubpkgYaml) } }
diff --git a/dependency/resolver.go b/dependency/resolver.go index b79da2c..e237564 100644 --- a/dependency/resolver.go +++ b/dependency/resolver.go
@@ -609,7 +609,7 @@ } if len(r.hadError) > 0 { - // Errors occured so we return. + // Errors occurred so we return. return []string{}, errors.New("Error resolving imports") }
diff --git a/mirrors/mirrors.go b/mirrors/mirrors.go index ec9bfcd..d42f50e 100644 --- a/mirrors/mirrors.go +++ b/mirrors/mirrors.go
@@ -20,7 +20,7 @@ Repo, Vcs string } -// Get retrieves informtion about an mirror. It returns. +// Get retrieves information about an mirror. It returns. // - bool if found // - new repo location // - vcs type
diff --git a/repo/vcs.go b/repo/vcs.go index 508cf8b..57ae33c 100644 --- a/repo/vcs.go +++ b/repo/vcs.go
@@ -185,64 +185,64 @@ _, err = v.DetectVcsFromFS(cwd) if empty == false && err == v.ErrCannotDetectVCS { return fmt.Errorf("Cache directory missing VCS information for %s", dep.Name) + } + + repo, err := dep.GetRepo(cwd) + if err != nil { + return err + } + + ver := dep.Reference + // References in Git can begin with a ^ which is similar to semver. + // If there is a ^ prefix we assume it's a semver constraint rather than + // part of the git/VCS commit id. + if repo.IsReference(ver) && !strings.HasPrefix(ver, "^") { + msg.Info("--> Setting version for %s to %s.\n", dep.Name, ver) } else { - repo, err := dep.GetRepo(cwd) + + // Create the constraint first to make sure it's valid before + // working on the repo. + constraint, err := semver.NewConstraint(ver) + + // Make sure the constriant is valid. At this point it's not a valid + // reference so if it's not a valid constrint we can exit early. + if err != nil { + msg.Warn("The reference '%s' is not valid\n", ver) + return err + } + + // Get the tags and branches (in that order) + refs, err := getAllVcsRefs(repo) if err != nil { return err } - ver := dep.Reference - // References in Git can begin with a ^ which is similar to semver. - // If there is a ^ prefix we assume it's a semver constraint rather than - // part of the git/VCS commit id. - if repo.IsReference(ver) && !strings.HasPrefix(ver, "^") { - msg.Info("--> Setting version for %s to %s.\n", dep.Name, ver) + // Convert and filter the list to semver.Version instances + semvers := getSemVers(refs) + + // Sort semver list + sort.Sort(sort.Reverse(semver.Collection(semvers))) + found := false + for _, v := range semvers { + if constraint.Check(v) { + found = true + // If the constrint passes get the original reference + ver = v.Original() + break + } + } + if found { + msg.Info("--> Detected semantic version. Setting version for %s to %s.", dep.Name, ver) } else { - - // Create the constraint first to make sure it's valid before - // working on the repo. - constraint, err := semver.NewConstraint(ver) - - // Make sure the constriant is valid. At this point it's not a valid - // reference so if it's not a valid constrint we can exit early. - if err != nil { - msg.Warn("The reference '%s' is not valid\n", ver) - return err - } - - // Get the tags and branches (in that order) - refs, err := getAllVcsRefs(repo) - if err != nil { - return err - } - - // Convert and filter the list to semver.Version instances - semvers := getSemVers(refs) - - // Sort semver list - sort.Sort(sort.Reverse(semver.Collection(semvers))) - found := false - for _, v := range semvers { - if constraint.Check(v) { - found = true - // If the constrint passes get the original reference - ver = v.Original() - break - } - } - if found { - msg.Info("--> Detected semantic version. Setting version for %s to %s.", dep.Name, ver) - } else { - msg.Warn("--> Unable to find semantic version for constraint %s %s", dep.Name, ver) - } + msg.Warn("--> Unable to find semantic version for constraint %s %s", dep.Name, ver) } - if err := repo.UpdateVersion(ver); err != nil { - return err - } - dep.Pin, err = repo.Version() - if err != nil { - return err - } + } + if err := repo.UpdateVersion(ver); err != nil { + return err + } + dep.Pin, err = repo.Version() + if err != nil { + return err } return nil
diff --git a/util/util.go b/util/util.go index f0854d2..1226b0b 100644 --- a/util/util.go +++ b/util/util.go
@@ -110,7 +110,7 @@ func checkRemotePackageCache(pkg string) (string, bool) { for k, v := range remotePackageCache { - if pkg == k || strings.HasPrefix(pkg, k + "/") { + if pkg == k || strings.HasPrefix(pkg, k+"/") { return v, true } } @@ -290,7 +290,7 @@ out, err := exec.Command(goExecutable, "env", "GOROOT").Output() if goRoot = strings.TrimSpace(string(out)); len(goRoot) == 0 || err != nil { return nil, fmt.Errorf("Please set the $GOROOT environment " + - "variable to use this command\n") + "variable to use this command\n") } buildContext.GOROOT = goRoot }