diff --git a/go.mod b/go.mod index a192948d..6ba1906c 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/opencontrol/compliance-masonry go 1.15 require ( - github.com/Masterminds/vcs v1.13.1 + github.com/Masterminds/vcs v1.13.3 github.com/blang/semver v1.1.1-0.20200524153540-4487282d7812 github.com/davecgh/go-spew v1.1.1 // indirect github.com/fatih/set v0.2.1 diff --git a/go.sum b/go.sum index 35368526..f006146e 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,5 @@ -github.com/Masterminds/vcs v1.13.1 h1:NL3G1X7/7xduQtA2sJLpVpfHTNBALVNSjob6KEjPXNQ= -github.com/Masterminds/vcs v1.13.1/go.mod h1:N09YCmOQr6RLxC6UNHzuVwAdodYbbnycGHSmwVJjcKA= +github.com/Masterminds/vcs v1.13.3 h1:IIA2aBdXvfbIM+yl/eTnL4hb1XwdpvuQLglAix1gweE= +github.com/Masterminds/vcs v1.13.3/go.mod h1:TiE7xuEjl1N4j016moRd6vezp6e6Lz23gypeXfzXeW8= github.com/blang/semver v1.1.1-0.20200524153540-4487282d7812 h1:jzZsi1BktKy646RZj+YB+tteqtyOsyqYOZ6M7YjdwbM= github.com/blang/semver v1.1.1-0.20200524153540-4487282d7812/go.mod h1:u4Z/LRonWXLVIJgtpeY3+xwWiIhiJ9ilXrKVGnfHe/c= github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= diff --git a/vendor/github.com/Masterminds/vcs/.golangci.yml b/vendor/github.com/Masterminds/vcs/.golangci.yml new file mode 100644 index 00000000..bd2463cf --- /dev/null +++ b/vendor/github.com/Masterminds/vcs/.golangci.yml @@ -0,0 +1,24 @@ +linters: + disable-all: true + enable: + - deadcode + - dupl + - gofmt + - goimports + - gosimple + - govet + - ineffassign + - nakedret + - revive + - structcheck + - unused + - varcheck + - staticcheck + +linters-settings: + gofmt: + simplify: true + goimports: + local-prefixes: helm.sh/helm/v3 + dupl: + threshold: 400 diff --git a/vendor/github.com/Masterminds/vcs/.travis.yml b/vendor/github.com/Masterminds/vcs/.travis.yml deleted file mode 100644 index 16e81fc8..00000000 --- a/vendor/github.com/Masterminds/vcs/.travis.yml +++ /dev/null @@ -1,44 +0,0 @@ -language: go -dist: xenial - -go: - - 1.6.x - - 1.7.x - - 1.8.x - - 1.9.x - - 1.10.x - - 1.11.x - - 1.12.x - - master - -before_script: - - git version - - svn --version - # Need a more up to date verion of mercurial to handle TLS with - # bitbucket properly. Also need python greater than 2.7.9. - - pyenv versions && pyenv rehash && pyenv versions - - pyenv global 2.7.15 - - openssl ciphers -v | awk '{print $2}' | sort | uniq - - sudo pip install mercurial --upgrade - # The below is a complete hack to have hg use the pyenv version of python - - sudo sed -i '1s/.*/\#\!\/usr\/bin\/env\ python/' /usr/local/bin/hg - - hg --version - - -# Setting sudo access to false will let Travis CI use containers rather than -# VMs to run the tests. For more details see: -# - http://docs.travis-ci.com/user/workers/container-based-infrastructure/ -# - http://docs.travis-ci.com/user/workers/standard-infrastructure/ -sudo: false - -script: - - make setup - - make test - -notifications: - webhooks: - urls: - - https://webhooks.gitter.im/e/06e3328629952dabe3e0 - on_success: change # options: [always|never|change] default: always - on_failure: always # options: [always|never|change] default: always - on_start: never # options: [always|never|change] default: always diff --git a/vendor/github.com/Masterminds/vcs/CHANGELOG.md b/vendor/github.com/Masterminds/vcs/CHANGELOG.md index 3a4a5e22..aa797657 100644 --- a/vendor/github.com/Masterminds/vcs/CHANGELOG.md +++ b/vendor/github.com/Masterminds/vcs/CHANGELOG.md @@ -1,5 +1,20 @@ # Changelog +## 1.13.3 (2022-03-31) + +### Fixed + +- Case sensitive use of the module name + +## 1.13.2 (2022-03-30) + +### Fixed + +- Fix for CVE-2022-21235 +- #103: Fixed CI testing. This included moving to GitHub Actions, updating the + the Git submodule handling, and skipping bzr tests on Windows (bzr has + discontinued and the installer now installs a broken environment) + ## 1.13.1 (2019-07-09) ### Fixed diff --git a/vendor/github.com/Masterminds/vcs/Makefile b/vendor/github.com/Masterminds/vcs/Makefile index 5d722c2f..13123bbf 100644 --- a/vendor/github.com/Masterminds/vcs/Makefile +++ b/vendor/github.com/Masterminds/vcs/Makefile @@ -1,41 +1,19 @@ -.PHONY: setup -setup: - go get -u gopkg.in/alecthomas/gometalinter.v1 - gometalinter.v1 --install +GOLANGCI_LINT_VERSION?=1.45.0 +GOLANGCI_LINT_SHA256?=ca06a2b170f41a9e1e34d40ca88b15b8fed2d7e37310f0c08b7fc244c34292a9 +GOLANGCI_LINT=/usr/local/bin/golangci-lint + +$(GOLANGCI_LINT): + curl -sSLO https://github.com/golangci/golangci-lint/releases/download/v${GOLANGCI_LINT_VERSION}/golangci-lint-${GOLANGCI_LINT_VERSION}-linux-amd64.tar.gz + shasum -a 256 golangci-lint-${GOLANGCI_LINT_VERSION}-linux-amd64.tar.gz | grep "^${GOLANGCI_LINT_SHA256} " > /dev/null + tar -xf golangci-lint-${GOLANGCI_LINT_VERSION}-linux-amd64.tar.gz + sudo mv golangci-lint-${GOLANGCI_LINT_VERSION}-linux-amd64/golangci-lint /usr/local/bin/golangci-lint + rm -rf golangci-lint-${GOLANGCI_LINT_VERSION}-linux-amd64* .PHONY: test -test: validate lint +test: @echo "==> Running tests" go test -v -.PHONY: validate -validate: -# misspell finds the work adresář (used in bzr.go) as a mispelling of -# address. It finds adres. An issue has been filed at -# https://github.com/client9/misspell/issues/99. In the meantime adding -# adres to the ignore list. - @echo "==> Running static validations" - @gometalinter.v1 \ - --disable-all \ - --linter "misspell:misspell -i adres -j 1 {path}/*.go:PATH:LINE:COL:MESSAGE" \ - --enable deadcode \ - --severity deadcode:error \ - --enable gofmt \ - --enable gosimple \ - --enable ineffassign \ - --enable misspell \ - --enable vet \ - --tests \ - --vendor \ - --deadline 60s \ - ./... || exit_code=1 - .PHONY: lint -lint: - @echo "==> Running linters" - @gometalinter.v1 \ - --disable-all \ - --enable golint \ - --vendor \ - --deadline 60s \ - ./... || : +lint: $(GOLANGCI_LINT) + @$(GOLANGCI_LINT) run diff --git a/vendor/github.com/Masterminds/vcs/README.md b/vendor/github.com/Masterminds/vcs/README.md index a1126851..0e411999 100644 --- a/vendor/github.com/Masterminds/vcs/README.md +++ b/vendor/github.com/Masterminds/vcs/README.md @@ -3,9 +3,10 @@ Manage repos in varying version control systems with ease through a common interface. -[![Build Status](https://travis-ci.org/Masterminds/vcs.svg)](https://travis-ci.org/Masterminds/vcs) [![GoDoc](https://godoc.org/github.com/Masterminds/vcs?status.png)](https://godoc.org/github.com/Masterminds/vcs) [![Go Report Card](https://goreportcard.com/badge/github.com/Masterminds/vcs)](https://goreportcard.com/report/github.com/Masterminds/vcs) -[![Build status](https://ci.appveyor.com/api/projects/status/vg3cjc561q2trobm?svg=true&passingText=windows%20build%20passing&failingText=windows%20build%20failing)](https://ci.appveyor.com/project/mattfarina/vcs) +[![Linux Tests](https://github.com/Masterminds/vcs/actions/workflows/linux-tests.yaml/badge.svg)](https://github.com/Masterminds/vcs/actions/workflows/linux-tests.yaml) [![Go Report Card](https://goreportcard.com/badge/github.com/Masterminds/vcs)](https://goreportcard.com/report/github.com/Masterminds/vcs) +[![Windows Tests](https://github.com/Masterminds/vcs/actions/workflows/windows-tests.yaml/badge.svg)](https://github.com/Masterminds/vcs/actions/workflows/windows-tests.yaml) [![Docs](https://img.shields.io/static/v1?label=docs&message=reference&color=blue)](https://pkg.go.dev/github.com/Masterminds/vcs) +**Note: Module names are case sensitive. Please be sure to use `github.com/Masterminds/vcs` with the capital M.** ## Quick Usage diff --git a/vendor/github.com/Masterminds/vcs/appveyor.yml b/vendor/github.com/Masterminds/vcs/appveyor.yml deleted file mode 100644 index c0c9170f..00000000 --- a/vendor/github.com/Masterminds/vcs/appveyor.yml +++ /dev/null @@ -1,26 +0,0 @@ - -version: build-{build}.{branch} - -clone_folder: C:\gopath\src\github.com\Masterminds\vcs -shallow_clone: true - -environment: - GOPATH: C:\gopath - -platform: - - x64 - -install: - - go version - - go env - - choco install -y bzr - - set PATH=C:\Program Files (x86)\Bazaar;%PATH% - - bzr --version - -build_script: - - go install -v ./... - -test_script: - - go test -v - -deploy: off diff --git a/vendor/github.com/Masterminds/vcs/bzr.go b/vendor/github.com/Masterminds/vcs/bzr.go index 8343d3ce..9803d20c 100644 --- a/vendor/github.com/Masterminds/vcs/bzr.go +++ b/vendor/github.com/Masterminds/vcs/bzr.go @@ -80,7 +80,7 @@ func (s *BzrRepo) Get() error { } } - out, err := s.run("bzr", "branch", s.Remote(), s.LocalPath()) + out, err := s.run("bzr", "branch", "--", s.Remote(), s.LocalPath()) if err != nil { return NewRemoteError("Unable to get repository", err, string(out)) } @@ -90,7 +90,7 @@ func (s *BzrRepo) Get() error { // Init initializes a bazaar repository at local location. func (s *BzrRepo) Init() error { - out, err := s.run("bzr", "init", s.LocalPath()) + out, err := s.run("bzr", "init", "--", s.LocalPath()) // There are some windows cases where bazaar cannot create the parent // directory if it does not already exist, to the location it's trying @@ -104,7 +104,7 @@ func (s *BzrRepo) Init() error { return NewLocalError("Unable to initialize repository", err, "") } - out, err = s.run("bzr", "init", s.LocalPath()) + out, err = s.run("bzr", "init", "--", s.LocalPath()) if err != nil { return NewLocalError("Unable to initialize repository", err, string(out)) } @@ -310,13 +310,13 @@ func (s *BzrRepo) Ping() bool { // This is the same command that Go itself uses but it's not fast (or fast // enough by my standards). A faster method would be useful. - _, err = s.run("bzr", "info", s.Remote()) + _, err = s.run("bzr", "info", "--", s.Remote()) return err == nil } // ExportDir exports the current revision to the passed in directory. func (s *BzrRepo) ExportDir(dir string) error { - out, err := s.RunFromDir("bzr", "export", dir) + out, err := s.RunFromDir("bzr", "export", "--", dir) s.log(out) if err != nil { return NewLocalError("Unable to export source", err, string(out)) diff --git a/vendor/github.com/Masterminds/vcs/git.go b/vendor/github.com/Masterminds/vcs/git.go index 82483507..2da0274b 100644 --- a/vendor/github.com/Masterminds/vcs/git.go +++ b/vendor/github.com/Masterminds/vcs/git.go @@ -71,7 +71,7 @@ func (s GitRepo) Vcs() Type { // Get is used to perform an initial clone of a repository. func (s *GitRepo) Get() error { - out, err := s.run("git", "clone", "--recursive", s.Remote(), s.LocalPath()) + out, err := s.run("git", "clone", "--recursive", "--", s.Remote(), s.LocalPath()) // There are some windows cases where Git cannot create the parent directory, // if it does not already exist, to the location it's trying to create the @@ -85,7 +85,7 @@ func (s *GitRepo) Get() error { return NewLocalError("Unable to create directory", err, "") } - out, err = s.run("git", "clone", s.Remote(), s.LocalPath()) + out, err = s.run("git", "clone", "--recursive", "--", s.Remote(), s.LocalPath()) if err != nil { return NewRemoteError("Unable to get repository", err, string(out)) } @@ -101,7 +101,7 @@ func (s *GitRepo) Get() error { // Init initializes a git repository at local location. func (s *GitRepo) Init() error { - out, err := s.run("git", "init", s.LocalPath()) + out, err := s.run("git", "init", "--", s.LocalPath()) // There are some windows cases where Git cannot create the parent directory, // if it does not already exist, to the location it's trying to create the @@ -115,7 +115,7 @@ func (s *GitRepo) Init() error { return NewLocalError("Unable to initialize repository", err, "") } - out, err = s.run("git", "init", s.LocalPath()) + out, err = s.run("git", "init", "--", s.LocalPath()) if err != nil { return NewLocalError("Unable to initialize repository", err, string(out)) } @@ -132,7 +132,7 @@ func (s *GitRepo) Init() error { // Update performs an Git fetch and pull to an existing checkout. func (s *GitRepo) Update() error { // Perform a fetch to make sure everything is up to date. - out, err := s.RunFromDir("git", "fetch", "--tags", s.RemoteLocation) + out, err := s.RunFromDir("git", "fetch", "--tags", "--", s.RemoteLocation) if err != nil { return NewRemoteError("Unable to update repository", err, string(out)) } @@ -412,8 +412,8 @@ func (s *GitRepo) ExportDir(dir string) error { } // and now, the horror of submodules - path = EscapePathSeparator(dir + "$path" + string(os.PathSeparator)) - out, err = s.RunFromDir("git", "submodule", "foreach", "--recursive", "git checkout-index -f -a --prefix="+path) + handleSubmodules(s, dir) + s.log(out) if err != nil { return NewLocalError("Error while exporting submodule sources", err, string(out)) diff --git a/vendor/github.com/Masterminds/vcs/git_unix.go b/vendor/github.com/Masterminds/vcs/git_unix.go new file mode 100644 index 00000000..16f38015 --- /dev/null +++ b/vendor/github.com/Masterminds/vcs/git_unix.go @@ -0,0 +1,13 @@ +//go:build !windows +// +build !windows + +package vcs + +import "os" + +func handleSubmodules(g *GitRepo, dir string) ([]byte, error) { + // Generate path + path := EscapePathSeparator(dir + "$path" + string(os.PathSeparator)) + + return g.RunFromDir("git", "submodule", "foreach", "--recursive", "git checkout-index -f -a --prefix="+path) +} diff --git a/vendor/github.com/Masterminds/vcs/git_windows.go b/vendor/github.com/Masterminds/vcs/git_windows.go new file mode 100644 index 00000000..2df3684e --- /dev/null +++ b/vendor/github.com/Masterminds/vcs/git_windows.go @@ -0,0 +1,47 @@ +//go:build windows +// +build windows + +package vcs + +import ( + "os" + "path/filepath" + "strings" +) + +func handleSubmodules(g *GitRepo, dir string) ([]byte, error) { + // Get the submodule directories + out, err := g.RunFromDir("git", "submodule", "foreach", "--quiet", "--recursive", "echo $sm_path") + if err != nil { + return out, err + } + cleanOut := strings.TrimSpace(string(out)) + pths := strings.Split(strings.ReplaceAll(cleanOut, "\r\n", "\n"), "\n") + + // Create the new directories. Directories are sometimes not created under + // Windows + for _, pth := range pths { + fpth := filepath.Join(dir + pth) + os.MkdirAll(fpth, 0755) + } + + // checkout-index for each submodule. Using $path or $sm_path while iterating + // over the submodules does not work in Windows when called from Go. + var cOut []byte + for _, pth := range pths { + // Get the path to the submodule in the exported location + fpth := EscapePathSeparator(filepath.Join(dir, pth) + string(os.PathSeparator)) + + // Call checkout-index directly in the submodule rather than in the + // parent project. This stils git submodule foreach that has trouble + // on Windows within Go where $sm_path isn't being handled properly + c := g.CmdFromDir("git", "checkout-index", "-f", "-a", "--prefix="+fpth) + c.Dir = filepath.Join(c.Dir, pth) + out, err := c.CombinedOutput() + cOut = append(cOut, out...) + if err != nil { + return cOut, err + } + } + return cOut, nil +} diff --git a/vendor/github.com/Masterminds/vcs/glide.yaml b/vendor/github.com/Masterminds/vcs/glide.yaml deleted file mode 100644 index b96e0bd3..00000000 --- a/vendor/github.com/Masterminds/vcs/glide.yaml +++ /dev/null @@ -1,8 +0,0 @@ -package: github.com/Masterminds/vcs -homepage: https://github.com/Masterminds/vcs -license: MIT -owners: -- name: Matt Farina - email: matt@mattfarina.com - homepage: https://www.mattfarina.com/ -import: [] diff --git a/vendor/github.com/Masterminds/vcs/go.mod b/vendor/github.com/Masterminds/vcs/go.mod new file mode 100644 index 00000000..97696ab8 --- /dev/null +++ b/vendor/github.com/Masterminds/vcs/go.mod @@ -0,0 +1,3 @@ +module github.com/Masterminds/vcs + +go 1.17 diff --git a/vendor/github.com/Masterminds/vcs/hg.go b/vendor/github.com/Masterminds/vcs/hg.go index ee3e0d93..11e012c5 100644 --- a/vendor/github.com/Masterminds/vcs/hg.go +++ b/vendor/github.com/Masterminds/vcs/hg.go @@ -72,7 +72,7 @@ func (s HgRepo) Vcs() Type { // Get is used to perform an initial clone of a repository. func (s *HgRepo) Get() error { - out, err := s.run("hg", "clone", s.Remote(), s.LocalPath()) + out, err := s.run("hg", "clone", "--", s.Remote(), s.LocalPath()) if err != nil { return NewRemoteError("Unable to get repository", err, string(out)) } @@ -81,7 +81,7 @@ func (s *HgRepo) Get() error { // Init will initialize a mercurial repository at local location. func (s *HgRepo) Init() error { - out, err := s.run("hg", "init", s.LocalPath()) + out, err := s.run("hg", "init", "--", s.LocalPath()) if err != nil { return NewLocalError("Unable to initialize repository", err, string(out)) } @@ -100,7 +100,7 @@ func (s *HgRepo) UpdateVersion(version string) error { return NewLocalError("Unable to update checked out version", err, string(out)) } if len(strings.TrimSpace(version)) > 0 { - out, err = s.RunFromDir("hg", "update", version) + out, err = s.RunFromDir("hg", "update", "--", version) } else { out, err = s.RunFromDir("hg", "update") } @@ -310,14 +310,14 @@ func (s *HgRepo) TagsFromCommit(id string) ([]string, error) { // Ping returns if remote location is accessible. func (s *HgRepo) Ping() bool { - _, err := s.run("hg", "identify", s.Remote()) + _, err := s.run("hg", "identify", "--", s.Remote()) return err == nil } // ExportDir exports the current revision to the passed in directory. func (s *HgRepo) ExportDir(dir string) error { - out, err := s.RunFromDir("hg", "archive", dir) + out, err := s.RunFromDir("hg", "archive", "--", dir) s.log(out) if err != nil { return NewLocalError("Unable to export source", err, string(out)) diff --git a/vendor/github.com/Masterminds/vcs/svn.go b/vendor/github.com/Masterminds/vcs/svn.go index 913f90a8..0c382c9c 100644 --- a/vendor/github.com/Masterminds/vcs/svn.go +++ b/vendor/github.com/Masterminds/vcs/svn.go @@ -37,7 +37,7 @@ func NewSvnRepo(remote, local string) (*SvnRepo, error) { if err == nil && r.CheckLocal() { // An SVN repo was found so test that the URL there matches // the repo passed in here. - out, err := exec.Command("svn", "info", local).CombinedOutput() + out, err := exec.Command("svn", "info", "--", local).CombinedOutput() if err != nil { return nil, NewLocalError("Unable to retrieve local repo information", err, string(out)) } @@ -80,7 +80,7 @@ func (s *SvnRepo) Get() error { } else if runtime.GOOS == "windows" && filepath.VolumeName(remote) != "" { remote = "file:///" + remote } - out, err := s.run("svn", "checkout", remote, s.LocalPath()) + out, err := s.run("svn", "checkout", "--", remote, s.LocalPath()) if err != nil { return NewRemoteError("Unable to get repository", err, string(out)) } @@ -341,14 +341,14 @@ func (s *SvnRepo) TagsFromCommit(id string) ([]string, error) { // Ping returns if remote location is accessible. func (s *SvnRepo) Ping() bool { - _, err := s.run("svn", "--non-interactive", "info", s.Remote()) + _, err := s.run("svn", "--non-interactive", "info", "--", s.Remote()) return err == nil } // ExportDir exports the current revision to the passed in directory. func (s *SvnRepo) ExportDir(dir string) error { - out, err := s.RunFromDir("svn", "export", ".", dir) + out, err := s.RunFromDir("svn", "export", "--", ".", dir) s.log(out) if err != nil { return NewLocalError("Unable to export source", err, string(out)) diff --git a/vendor/github.com/Masterminds/vcs/vcs_remote_lookup.go b/vendor/github.com/Masterminds/vcs/vcs_remote_lookup.go index 35c2cd8e..3fc973ec 100644 --- a/vendor/github.com/Masterminds/vcs/vcs_remote_lookup.go +++ b/vendor/github.com/Masterminds/vcs/vcs_remote_lookup.go @@ -1,7 +1,6 @@ package vcs import ( - "encoding/json" "encoding/xml" "fmt" "io" @@ -31,9 +30,9 @@ var vcsList = []*vcsInfo{ pattern: `^(github\.com[/|:][A-Za-z0-9_.\-]+/[A-Za-z0-9_.\-]+)(/[A-Za-z0-9_.\-]+)*$`, }, { - host: "bitbucket.org", - pattern: `^(bitbucket\.org/(?P[A-Za-z0-9_.\-]+/[A-Za-z0-9_.\-]+))(/[A-Za-z0-9_.\-]+)*$`, - addCheck: checkBitbucket, + host: "bitbucket.org", + pattern: `^(bitbucket\.org/(?P[A-Za-z0-9_.\-]+/[A-Za-z0-9_.\-]+))(/[A-Za-z0-9_.\-]+)*$`, + vcs: Git, }, { host: "launchpad.net", @@ -60,6 +59,21 @@ var vcsList = []*vcsInfo{ vcs: Git, pattern: `^(git\.openstack\.org/[A-Za-z0-9_.\-]+/[A-Za-z0-9_.\-]+)$`, }, + { + host: "hg.code.sf.net", + pattern: `^(hg.code.sf.net/p/[A-Za-z0-9_.\-]+/[A-Za-z0-9_.\-]+)*$`, + vcs: Hg, + }, + { + host: "git.code.sf.net", + pattern: `^(git.code.sf.net/p/[A-Za-z0-9_.\-]+/[A-Za-z0-9_.\-]+)*$`, + vcs: Git, + }, + { + host: "svn.code.sf.net", + pattern: `^(svn.code.sf.net/p/[A-Za-z0-9_.\-]+/[A-Za-z0-9_.\-]+)*$`, + vcs: Svn, + }, // If none of the previous detect the type they will fall to this looking for the type in a generic sense // by the extension to the path. { @@ -224,40 +238,6 @@ func detectVcsFromURL(vcsURL string) (Type, error) { return "", ErrCannotDetectVCS } -// Figure out the type for Bitbucket by the passed in information -// or via the public API. -func checkBitbucket(i map[string]string, ul *url.URL) (Type, error) { - - // Fast path for ssh urls where we may not even be able to - // anonymously get details from the API. - if ul.User != nil { - un := ul.User.Username() - if un == "git" { - return Git, nil - } else if un == "hg" { - return Hg, nil - } - } - - // The part of the response we care about. - var response struct { - SCM Type `json:"scm"` - } - - u := expand(i, "https://api.bitbucket.org/2.0/repositories/{name}?fields=scm") - data, err := get(u) - if err != nil { - return "", err - } - - if err := json.Unmarshal(data, &response); err != nil { - return "", fmt.Errorf("Decoding error %s: %v", u, err) - } - - return response.SCM, nil - -} - // Expect a type key on i with the exact type detected from the regex. func checkURL(i map[string]string, u *url.URL) (Type, error) { return Type(i["type"]), nil @@ -284,13 +264,6 @@ func get(url string) ([]byte, error) { return b, nil } -func expand(match map[string]string, s string) string { - for k, v := range match { - s = strings.Replace(s, "{"+k+"}", v, -1) - } - return s -} - func parseImportFromBody(ur *url.URL, r io.ReadCloser) (tp Type, u string, err error) { d := xml.NewDecoder(r) d.CharsetReader = charsetReader diff --git a/vendor/modules.txt b/vendor/modules.txt index 442c912d..3fb8b871 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -1,4 +1,4 @@ -# github.com/Masterminds/vcs v1.13.1 +# github.com/Masterminds/vcs v1.13.3 ## explicit github.com/Masterminds/vcs # github.com/blang/semver v1.1.1-0.20200524153540-4487282d7812