Skip to content
Snippets Groups Projects
Commit f7be01e3 authored by Christoph Witzko's avatar Christoph Witzko
Browse files

style: add .golangci-lint.yaml

parent 78784600
No related branches found
No related tags found
No related merge requests found
linters:
enable:
- errorlint
- forbidigo
- gochecknoinits
- gocritic
- goconst
- gocyclo
- gofumpt
- goimports
- misspell
- revive
- unconvert
- unparam
- wastedassign
linters-settings:
gocyclo:
min-complexity: 12
gofumpt:
extra-rules: true
govet:
enable-all: true
disable:
- fieldalignment
......@@ -52,18 +52,19 @@ func (repo *Repository) Init(config map[string]string) error {
config["auth_username"] = "git"
}
if config["auth"] == "basic" {
switch config["auth"] {
case "basic":
repo.auth = &http.BasicAuth{
Username: config["auth_username"],
Password: config["auth_password"],
}
} else if config["auth"] == "ssh" {
case "ssh":
auth, err := ssh.NewPublicKeysFromFile(config["auth_username"], config["auth_private_key"], config["auth_password"])
if err != nil {
return err
}
repo.auth = auth
} else {
default:
repo.auth = nil
}
......@@ -137,15 +138,15 @@ func (repo *Repository) GetReleases(rawRe string) ([]*semrel.Release, error) {
if rawRe != "" && !re.MatchString(tag) {
return nil
}
version, err := semver.NewVersion(tag)
if err != nil {
version, semverErr := semver.NewVersion(tag)
if semverErr != nil {
return nil
}
// resolve annotated tags
sha := reference.Hash()
if tagObj, err := repo.repo.TagObject(sha); err == nil {
if com, err := tagObj.Commit(); err == nil {
if tagObj, tagErr := repo.repo.TagObject(sha); tagErr == nil {
if com, commitErr := tagObj.Commit(); commitErr == nil {
sha = com.Hash
}
}
......
......@@ -2,7 +2,7 @@ package provider
import (
"fmt"
"io/ioutil"
"os"
"strings"
"testing"
"time"
......@@ -53,8 +53,9 @@ func newRepository(t *testing.T) {
require.NotNil(repo.auth)
}
//gocyclo:ignore
func setupRepo() (string, error) {
dir, err := ioutil.TempDir("", "provider-git")
dir, err := os.MkdirTemp("", "provider-git")
if err != nil {
return "", err
}
......@@ -83,19 +84,19 @@ func setupRepo() (string, error) {
versionCount := 0
betaCount := 1
for i := 0; i < 100; i++ {
commit, err := w.Commit(fmt.Sprintf("feat: commit %d", i), &git.CommitOptions{Author: author})
if err != nil {
commit, commitErr := w.Commit(fmt.Sprintf("feat: commit %d", i), &git.CommitOptions{Author: author, AllowEmptyCommits: true})
if commitErr != nil {
return "", err
}
if i%10 == 0 {
if _, err := repo.CreateTag(fmt.Sprintf("v1.%d.0", versionCount), commit, nil); err != nil {
return "", err
if _, tagErr := repo.CreateTag(fmt.Sprintf("v1.%d.0", versionCount), commit, nil); tagErr != nil {
return "", tagErr
}
versionCount++
}
if i%5 == 0 {
if _, err := repo.CreateTag(fmt.Sprintf("v2.0.0-beta.%d", betaCount), commit, nil); err != nil {
return "", err
if _, tagErr := repo.CreateTag(fmt.Sprintf("v2.0.0-beta.%d", betaCount), commit, nil); tagErr != nil {
return "", tagErr
}
betaCount++
}
......@@ -109,7 +110,7 @@ func setupRepo() (string, error) {
return "", err
}
if _, err = w.Commit("fix: error", &git.CommitOptions{Author: author}); err != nil {
if _, err = w.Commit("fix: error", &git.CommitOptions{Author: author, AllowEmptyCommits: true}); err != nil {
return "", err
}
if err = w.Checkout(&git.CheckoutOptions{Branch: plumbing.NewBranchReferenceName("master")}); err != nil {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment