diff options
| -rw-r--r-- | beku_test.go | 12 | ||||
| -rw-r--r-- | go/vcs/http.go | 2 | ||||
| -rw-r--r-- | go/vcs/vcs.go | 26 | ||||
| -rw-r--r-- | go/vcs/vcs_test.go | 8 | ||||
| -rw-r--r-- | package.go | 4 |
5 files changed, 27 insertions, 25 deletions
diff --git a/beku_test.go b/beku_test.go index e3ac977..209f630 100644 --- a/beku_test.go +++ b/beku_test.go @@ -22,13 +22,13 @@ const ( testPkgNotExist = "github.com/shuLhan/notexist" ) -var ( // nolint: gochecknoglobals - testEnv *Env - testGitPkgCur *Package - testGitPkgNew *Package - testGitPkgInstall *Package +var ( + testEnv *Env //nolint: gochecknoglobals + testGitPkgCur *Package //nolint: gochecknoglobals + testGitPkgNew *Package //nolint: gochecknoglobals + testGitPkgInstall *Package //nolint: gochecknoglobals - testGitRepoSrcLocal = "/testdata/beku_test.git" + testGitRepoSrcLocal = "/testdata/beku_test.git" //nolint: gochecknoglobals ) func TestMain(m *testing.M) { diff --git a/go/vcs/http.go b/go/vcs/http.go index 9618818..857c886 100644 --- a/go/vcs/http.go +++ b/go/vcs/http.go @@ -15,7 +15,7 @@ import ( // httpClient is the default HTTP client, but a variable so it can be // changed by tests, without modifying http.DefaultClient. -var httpClient = http.DefaultClient +var httpClient = http.DefaultClient //nolint: gochecknoglobals // httpGET returns the data from an HTTP GET request for the given URL. func httpGET(url string) ([]byte, error) { diff --git a/go/vcs/vcs.go b/go/vcs/vcs.go index dc89c34..471f841 100644 --- a/go/vcs/vcs.go +++ b/go/vcs/vcs.go @@ -30,10 +30,10 @@ import ( ) // Verbose enables verbose operation logging. -var Verbose bool +var Verbose bool //nolint: gochecknoglobals // ShowCmd controls whether VCS commands are printed. -var ShowCmd bool +var ShowCmd bool //nolint: gochecknoglobals // A Cmd describes how to use a version control system // like Mercurial, Git, or Subversion. @@ -63,7 +63,7 @@ type TagCmd struct { } // vcsList lists the known version control systems -var vcsList = []*Cmd{ +var vcsList = []*Cmd{ //nolint: gochecknoglobals vcsHg, vcsGit, vcsSvn, @@ -82,7 +82,7 @@ func ByCmd(cmd string) *Cmd { } // vcsHg describes how to use Mercurial. -var vcsHg = &Cmd{ +var vcsHg = &Cmd{ //nolint: gochecknoglobals Name: "Mercurial", Cmd: "hg", @@ -108,7 +108,7 @@ var vcsHg = &Cmd{ } // vcsGit describes how to use Git. -var vcsGit = &Cmd{ +var vcsGit = &Cmd{ //nolint: gochecknoglobals Name: "Git", Cmd: "git", @@ -131,7 +131,7 @@ var vcsGit = &Cmd{ } // vcsBzr describes how to use Bazaar. -var vcsBzr = &Cmd{ +var vcsBzr = &Cmd{ //nolint: gochecknoglobals Name: "Bazaar", Cmd: "bzr", @@ -150,7 +150,7 @@ var vcsBzr = &Cmd{ } // vcsSvn describes how to use Subversion. -var vcsSvn = &Cmd{ +var vcsSvn = &Cmd{ //nolint: gochecknoglobals Name: "Subversion", Cmd: "svn", @@ -436,7 +436,7 @@ func RepoRootForImportPath(importPath string, verbose bool) (*RepoRoot, error) { return rr, err } -var errUnknownSite = errors.New("dynamic lookup required to find mapping") +var errUnknownSite = errors.New("dynamic lookup required to find mapping") //nolint: gochecknoglobals // RepoRootForImportPathStatic attempts to map importPath to a // RepoRoot using the commonly-used VCS hosting sites in vcsPaths @@ -601,7 +601,7 @@ type metaImport struct { } // errNoMatch is returned from matchGoImport when there's no applicable match. -var errNoMatch = errors.New("no import match") +var errNoMatch = errors.New("no import match") //nolint: gochecknoglobals // pathPrefix reports whether sub is a prefix of s, // only considering entire path components. @@ -647,7 +647,7 @@ func expand(match map[string]string, s string) string { } // vcsPaths lists the known vcs paths. -var vcsPaths = []*vcsPath{ +var vcsPaths = []*vcsPath{ //nolint: gochecknoglobals // Github { prefix: "github.com/", @@ -668,7 +668,7 @@ var vcsPaths = []*vcsPath{ // Launchpad { prefix: "launchpad.net/", - re: `^(?P<root>launchpad\.net/((?P<project>[A-Za-z0-9_.\-]+)(?P<series>/[A-Za-z0-9_.\-]+)?|~[A-Za-z0-9_.\-]+/(\+junk|[A-Za-z0-9_.\-]+)/[A-Za-z0-9_.\-]+))(/[A-Za-z0-9_.\-]+)*$`, + re: `^(?P<root>launchpad\.net/((?P<project>[A-Za-z0-9_.\-]+)(?P<series>/[A-Za-z0-9_.\-]+)?|~[A-Za-z0-9_.\-]+/(\+junk|[A-Za-z0-9_.\-]+)/[A-Za-z0-9_.\-]+))(/[A-Za-z0-9_.\-]+)*$`, //nolint:lll vcs: "bzr", repo: "https://{root}", check: launchpadVCS, @@ -685,12 +685,12 @@ var vcsPaths = []*vcsPath{ // General syntax for any server. { - re: `^(?P<root>(?P<repo>([a-z0-9.\-]+\.)+[a-z0-9.\-]+(:[0-9]+)?/[A-Za-z0-9_.\-/]*?)\.(?P<vcs>bzr|git|hg|svn))(/[A-Za-z0-9_.\-]+)*$`, + re: `^(?P<root>(?P<repo>([a-z0-9.\-]+\.)+[a-z0-9.\-]+(:[0-9]+)?/[A-Za-z0-9_.\-/]*?)\.(?P<vcs>bzr|git|hg|svn))(/[A-Za-z0-9_.\-]+)*$`, //nolint:lll ping: true, }, } -func init() { +func init() { //nolint: gochecknoinits // fill in cached regexps. // Doing this eagerly discovers invalid regexp syntax // without having to run a command that needs that regexp. diff --git a/go/vcs/vcs_test.go b/go/vcs/vcs_test.go index d18ff18..d17caad 100644 --- a/go/vcs/vcs_test.go +++ b/go/vcs/vcs_test.go @@ -52,7 +52,8 @@ func TestRepoRootForImportPath(t *testing.T) { } want := test.want if got.VCS.Name != want.VCS.Name || got.Repo != want.Repo { - t.Errorf("RepoRootForImportPath(%q) = VCS(%s) Repo(%s), want VCS(%s) Repo(%s)", test.path, got.VCS, got.Repo, want.VCS, want.Repo) + t.Errorf("RepoRootForImportPath(%q) = VCS(%s) Repo(%s), want VCS(%s) Repo(%s)", + test.path, got.VCS, got.Repo, want.VCS, want.Repo) } } } @@ -95,12 +96,13 @@ func TestFromDir(t *testing.T) { continue } if got.VCS.Name != want.VCS.Name || got.Root != want.Root { - t.Errorf("FromDir(%q, %q) = VCS(%s) Root(%s), want VCS(%s) Root(%s)", dir, tempDir, got.VCS, got.Root, want.VCS, want.Root) + t.Errorf("FromDir(%q, %q) = VCS(%s) Root(%s), want VCS(%s) Root(%s)", + dir, tempDir, got.VCS, got.Root, want.VCS, want.Root) } } } -var parseMetaGoImportsTests = []struct { +var parseMetaGoImportsTests = []struct { //nolint: gochecknoglobals in string out []metaImport }{ @@ -14,12 +14,12 @@ import ( "sort" "strings" + "golang.org/x/tools/go/vcs" + "github.com/shuLhan/share/lib/debug" "github.com/shuLhan/share/lib/git" "github.com/shuLhan/share/lib/ini" libio "github.com/shuLhan/share/lib/io" - - "github.com/shuLhan/beku/go/vcs" ) const ( |
