Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
provider-git
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
GitHub Mirror
go-semantic-release
provider-git
Commits
f7be01e3
Commit
f7be01e3
authored
2 years ago
by
Christoph Witzko
Browse files
Options
Downloads
Patches
Plain Diff
style: add .golangci-lint.yaml
parent
78784600
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
.golangci.yaml
+25
-0
25 additions, 0 deletions
.golangci.yaml
pkg/provider/git.go
+8
-7
8 additions, 7 deletions
pkg/provider/git.go
pkg/provider/git_test.go
+10
-9
10 additions, 9 deletions
pkg/provider/git_test.go
with
43 additions
and
16 deletions
.golangci.yaml
0 → 100644
+
25
−
0
View file @
f7be01e3
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
This diff is collapsed.
Click to expand it.
pkg/provider/git.go
+
8
−
7
View file @
f7be01e3
...
...
@@ -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
,
e
rr
:=
semver
.
NewVersion
(
tag
)
if
e
rr
!=
nil
{
version
,
semverE
rr
:=
semver
.
NewVersion
(
tag
)
if
semverE
rr
!=
nil
{
return
nil
}
// resolve annotated tags
sha
:=
reference
.
Hash
()
if
tagObj
,
e
rr
:=
repo
.
repo
.
TagObject
(
sha
);
e
rr
==
nil
{
if
com
,
e
rr
:=
tagObj
.
Commit
();
e
rr
==
nil
{
if
tagObj
,
tagE
rr
:=
repo
.
repo
.
TagObject
(
sha
);
tagE
rr
==
nil
{
if
com
,
commitE
rr
:=
tagObj
.
Commit
();
commitE
rr
==
nil
{
sha
=
com
.
Hash
}
}
...
...
This diff is collapsed.
Click to expand it.
pkg/provider/git_test.go
+
10
−
9
View file @
f7be01e3
...
...
@@ -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
.
Temp
Dir
(
""
,
"provider-git"
)
dir
,
err
:=
os
.
Mkdir
Temp
(
""
,
"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
,
e
rr
:=
w
.
Commit
(
fmt
.
Sprintf
(
"feat: commit %d"
,
i
),
&
git
.
CommitOptions
{
Author
:
author
})
if
e
rr
!=
nil
{
commit
,
commitE
rr
:=
w
.
Commit
(
fmt
.
Sprintf
(
"feat: commit %d"
,
i
),
&
git
.
CommitOptions
{
Author
:
author
,
AllowEmptyCommits
:
true
})
if
commitE
rr
!=
nil
{
return
""
,
err
}
if
i
%
10
==
0
{
if
_
,
e
rr
:=
repo
.
CreateTag
(
fmt
.
Sprintf
(
"v1.%d.0"
,
versionCount
),
commit
,
nil
);
e
rr
!=
nil
{
return
""
,
e
rr
if
_
,
tagE
rr
:=
repo
.
CreateTag
(
fmt
.
Sprintf
(
"v1.%d.0"
,
versionCount
),
commit
,
nil
);
tagE
rr
!=
nil
{
return
""
,
tagE
rr
}
versionCount
++
}
if
i
%
5
==
0
{
if
_
,
e
rr
:=
repo
.
CreateTag
(
fmt
.
Sprintf
(
"v2.0.0-beta.%d"
,
betaCount
),
commit
,
nil
);
e
rr
!=
nil
{
return
""
,
e
rr
if
_
,
tagE
rr
:=
repo
.
CreateTag
(
fmt
.
Sprintf
(
"v2.0.0-beta.%d"
,
betaCount
),
commit
,
nil
);
tagE
rr
!=
nil
{
return
""
,
tagE
rr
}
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
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment