-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #103 from Masterminds/fixes
Updates
- Loading branch information
Showing
18 changed files
with
239 additions
and
182 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
on: | ||
pull_request: | ||
push: | ||
branches: | ||
- master | ||
|
||
name: Linux Tests | ||
jobs: | ||
test: | ||
strategy: | ||
matrix: | ||
go-version: [1.16.x, 1.17.x, 1.18.x] | ||
platform: | ||
- ubuntu-latest | ||
runs-on: ${{ matrix.platform }} | ||
steps: | ||
- name: Install Go | ||
uses: actions/setup-go@v1 | ||
with: | ||
go-version: ${{ matrix.go-version }} | ||
- name: Checkout code | ||
uses: actions/checkout@v1 | ||
- name: Lint | ||
run: make lint | ||
- name: Install dependencies | ||
run: sudo apt install subversion mercurial bzr | ||
- name: Test | ||
run: make test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
on: | ||
pull_request: | ||
push: | ||
branches: | ||
- master | ||
|
||
name: Windows Tests | ||
jobs: | ||
test: | ||
strategy: | ||
matrix: | ||
go-version: [1.16.x, 1.17.x, 1.18.x] | ||
platform: | ||
- windows-latest | ||
runs-on: ${{ matrix.platform }} | ||
steps: | ||
- name: Install Go | ||
uses: actions/setup-go@v1 | ||
with: | ||
go-version: ${{ matrix.go-version }} | ||
- name: Checkout code | ||
uses: actions/checkout@v1 | ||
- name: Install dependencies | ||
run: choco install svn hg | ||
- name: Test | ||
run: go test -v | ||
env: | ||
# Skipping bzr tests on Windows as bzr does not install properly there. | ||
# bzr development stopped in 2017 (when last change landed). The official | ||
# windows installer is still bzr 2.5. The installer does not setup working | ||
# cacerts. This needs to be manually modified to get working. Skipping | ||
# tests in this environment as there are environment problems. | ||
SKIP_BZR: "true" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module github.com/masterminds/vcs | ||
|
||
go 1.17 |
Oops, something went wrong.