Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/linux-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@ jobs:
test:
strategy:
matrix:
go-version: [1.16.x, 1.17.x, 1.18.x]
go-version: [1.23.x, 1.24.x, 1.25.x]
platform:
- ubuntu-latest
runs-on: ${{ matrix.platform }}
steps:
- name: Install Go
uses: actions/setup-go@v1
uses: actions/setup-go@v6
with:
go-version: ${{ matrix.go-version }}
- name: Checkout code
uses: actions/checkout@v1
uses: actions/checkout@v6
- name: Lint
run: make lint
- name: Install dependencies
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/windows-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@ jobs:
test:
strategy:
matrix:
go-version: [1.16.x, 1.17.x, 1.18.x]
go-version: [1.23.x, 1.24.x, 1.25.x]
platform:
- windows-latest
runs-on: ${{ matrix.platform }}
steps:
- name: Install Go
uses: actions/setup-go@v1
uses: actions/setup-go@v6
with:
go-version: ${{ matrix.go-version }}
- name: Checkout code
uses: actions/checkout@v1
uses: actions/checkout@v6
- name: Install dependencies
shell: powershell
run: |
Expand Down
21 changes: 12 additions & 9 deletions .golangci.yml → .golangci.yaml
Original file line number Diff line number Diff line change
@@ -1,24 +1,27 @@
version: 2

linters:
disable-all: true
enable:
- deadcode
- dupl
- gofmt
- goimports
- gosimple
- govet
- ineffassign
- nakedret
- revive
- structcheck
- unused
- varcheck
- staticcheck

formatters:
enable:
- gofmt
- goimports

linters-settings:
dupl:
threshold: 400

formatters-settings:
gofmt:
simplify: true
goimports:
local-prefixes: helm.sh/helm/v3
dupl:
threshold: 400
local-prefixes: github.com/Masterminds/vcs
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
GOLANGCI_LINT_VERSION?=1.45.0
GOLANGCI_LINT_SHA256?=ca06a2b170f41a9e1e34d40ca88b15b8fed2d7e37310f0c08b7fc244c34292a9
GOLANGCI_LINT_VERSION?=2.6.2
GOLANGCI_LINT_SHA256?=499c864b5fd9841c4fa8e80b5e2be30f73f085cf186f1b111ff81a2783b7de12
GOLANGCI_LINT=/usr/local/bin/golangci-lint

$(GOLANGCI_LINT):
Expand Down
61 changes: 7 additions & 54 deletions bzr_test.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
package vcs

import (
"io/ioutil"
"os"
"path/filepath"
"testing"
"time"

//"log"
"os"
"testing"
)

// Canary test to ensure BzrRepo implements the Repo interface.
Expand All @@ -22,16 +20,7 @@ func TestBzr(t *testing.T) {
t.Skip("Skipping bzr tests")
}

tempDir, err := ioutil.TempDir("", "go-vcs-bzr-tests")
if err != nil {
t.Error(err)
}
defer func() {
err = os.RemoveAll(tempDir)
if err != nil {
t.Error(err)
}
}()
tempDir := t.TempDir()

repo, err := NewBzrRepo("https://launchpad.net/govcstestbzrrepo", tempDir+"/govcstestbzrrepo")
if err != nil {
Expand Down Expand Up @@ -206,16 +195,7 @@ func TestBzr(t *testing.T) {
t.Error("Bzr didn't return expected ErrRevisionUnavailable")
}

tempDir2, err := ioutil.TempDir("", "go-vcs-bzr-tests-export")
if err != nil {
t.Fatalf("Error creating temp directory: %s", err)
}
defer func() {
err = os.RemoveAll(tempDir2)
if err != nil {
t.Error(err)
}
}()
tempDir2 := t.TempDir()

exportDir := filepath.Join(tempDir2, "src")

Expand Down Expand Up @@ -246,16 +226,7 @@ func TestBzrCheckLocal(t *testing.T) {

// Verify repo.CheckLocal fails for non-Bzr directories.
// TestBzr is already checking on a valid repo
tempDir, err := ioutil.TempDir("", "go-vcs-bzr-tests")
if err != nil {
t.Error(err)
}
defer func() {
err = os.RemoveAll(tempDir)
if err != nil {
t.Error(err)
}
}()
tempDir := t.TempDir()

repo, _ := NewBzrRepo("", tempDir)
if repo.CheckLocal() {
Expand All @@ -275,16 +246,7 @@ func TestBzrPing(t *testing.T) {
t.Skip("Skipping bzr tests")
}

tempDir, err := ioutil.TempDir("", "go-vcs-bzr-tests")
if err != nil {
t.Error(err)
}
defer func() {
err = os.RemoveAll(tempDir)
if err != nil {
t.Error(err)
}
}()
tempDir := t.TempDir()

repo, err := NewBzrRepo("https://launchpad.net/govcstestbzrrepo", tempDir)
if err != nil {
Expand Down Expand Up @@ -312,17 +274,8 @@ func TestBzrInit(t *testing.T) {
t.Skip("Skipping bzr tests")
}

tempDir, err := ioutil.TempDir("", "go-vcs-bzr-tests")
tempDir := t.TempDir()
repoDir := tempDir + "/repo"
if err != nil {
t.Error(err)
}
defer func() {
err = os.RemoveAll(tempDir)
if err != nil {
t.Error(err)
}
}()

repo, err := NewBzrRepo(repoDir, repoDir)
if err != nil {
Expand Down
8 changes: 4 additions & 4 deletions errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,18 @@ import (

var (
// ErrWrongVCS is returned when an action is tried on the wrong VCS.
ErrWrongVCS = errors.New("Wrong VCS detected")
ErrWrongVCS = errors.New("wrong VCS detected")

// ErrCannotDetectVCS is returned when VCS cannot be detected from URI string.
ErrCannotDetectVCS = errors.New("Cannot detect VCS")
ErrCannotDetectVCS = errors.New("cannot detect VCS")

// ErrWrongRemote occurs when the passed in remote does not match the VCS
// configured endpoint.
ErrWrongRemote = errors.New("The Remote does not match the VCS endpoint")
ErrWrongRemote = errors.New("the remote does not match the VCS endpoint")

// ErrRevisionUnavailable happens when commit revision information is
// unavailable.
ErrRevisionUnavailable = errors.New("Revision unavailable")
ErrRevisionUnavailable = errors.New("revision unavailable")
)

// RemoteError is returned when an operation fails against a remote repo
Expand Down
11 changes: 4 additions & 7 deletions git.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package vcs
import (
"bytes"
"encoding/xml"
"io/ioutil"
"os"
"os/exec"
"path/filepath"
Expand Down Expand Up @@ -377,10 +376,9 @@ func EscapePathSeparator(path string) string {
// See: https://blogs.msdn.microsoft.com/twistylittlepassagesallalike/2011/04/23/everyone-quotes-command-line-arguments-the-wrong-way/
// e.g., C:\foo\bar\ -> C:\\\foo\\\bar\\\
// used with --prefix, like this: --prefix=C:\foo\bar\ -> --prefix=C:\\\foo\\\bar\\\
return strings.Replace(path,
return strings.ReplaceAll(path,
string(os.PathSeparator),
string(os.PathSeparator)+string(os.PathSeparator)+string(os.PathSeparator),
-1)
string(os.PathSeparator)+string(os.PathSeparator)+string(os.PathSeparator))
default:
return path
}
Expand Down Expand Up @@ -412,8 +410,7 @@ func (s *GitRepo) ExportDir(dir string) error {
}

// and now, the horror of submodules
handleSubmodules(s, dir)

out, err = handleSubmodules(s, dir)
s.log(out)
if err != nil {
return NewLocalError("Error while exporting submodule sources", err, string(out))
Expand All @@ -425,7 +422,7 @@ func (s *GitRepo) ExportDir(dir string) error {
// isDetachedHead will detect if git repo is in "detached head" state.
func isDetachedHead(dir string) (bool, error) {
p := filepath.Join(dir, ".git", "HEAD")
contents, err := ioutil.ReadFile(p)
contents, err := os.ReadFile(p)
if err != nil {
return false, err
}
Expand Down
Loading
Loading