mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2026-04-15 01:41:56 +00:00
Enable some linters (#3129)
Mostly those that did not require much work. From #2960 --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
@@ -232,8 +232,7 @@ func Test_helper(t *testing.T) {
|
||||
from.Sender.Login = github.String("octocat")
|
||||
from.Sender.AvatarURL = github.String("https://avatars1.githubusercontent.com/u/583231")
|
||||
|
||||
_, pipeline, err := parseDeployHook(from)
|
||||
g.Assert(err).IsNil()
|
||||
_, pipeline := parseDeployHook(from)
|
||||
g.Assert(pipeline.Event).Equal(model.EventDeploy)
|
||||
g.Assert(pipeline.Branch).Equal("main")
|
||||
g.Assert(pipeline.Ref).Equal("refs/heads/main")
|
||||
@@ -255,8 +254,7 @@ func Test_helper(t *testing.T) {
|
||||
from.HeadCommit.ID = github.String("f72fc19")
|
||||
from.Ref = github.String("refs/heads/main")
|
||||
|
||||
_, pipeline, err := parsePushHook(from)
|
||||
g.Assert(err).IsNil()
|
||||
_, pipeline := parsePushHook(from)
|
||||
g.Assert(pipeline.Event).Equal(model.EventPush)
|
||||
g.Assert(pipeline.Branch).Equal("main")
|
||||
g.Assert(pipeline.Ref).Equal("refs/heads/main")
|
||||
@@ -273,8 +271,7 @@ func Test_helper(t *testing.T) {
|
||||
from := &github.PushEvent{}
|
||||
from.Ref = github.String("refs/tags/v1.0.0")
|
||||
|
||||
_, pipeline, err := parsePushHook(from)
|
||||
g.Assert(err).IsNil()
|
||||
_, pipeline := parsePushHook(from)
|
||||
g.Assert(pipeline.Event).Equal(model.EventTag)
|
||||
g.Assert(pipeline.Ref).Equal("refs/tags/v1.0.0")
|
||||
})
|
||||
@@ -284,8 +281,7 @@ func Test_helper(t *testing.T) {
|
||||
from.Ref = github.String("refs/tags/v1.0.0")
|
||||
from.BaseRef = github.String("refs/heads/main")
|
||||
|
||||
_, pipeline, err := parsePushHook(from)
|
||||
g.Assert(err).IsNil()
|
||||
_, pipeline := parsePushHook(from)
|
||||
g.Assert(pipeline.Event).Equal(model.EventTag)
|
||||
g.Assert(pipeline.Branch).Equal("main")
|
||||
})
|
||||
@@ -295,8 +291,7 @@ func Test_helper(t *testing.T) {
|
||||
from.Ref = github.String("refs/tags/v1.0.0")
|
||||
from.BaseRef = github.String("refs/refs/main")
|
||||
|
||||
_, pipeline, err := parsePushHook(from)
|
||||
g.Assert(err).IsNil()
|
||||
_, pipeline := parsePushHook(from)
|
||||
g.Assert(pipeline.Event).Equal(model.EventTag)
|
||||
g.Assert(pipeline.Branch).Equal("refs/tags/v1.0.0")
|
||||
})
|
||||
|
||||
@@ -61,11 +61,11 @@ func parseHook(r *http.Request, merge bool) (*github.PullRequest, *model.Repo, *
|
||||
|
||||
switch hook := payload.(type) {
|
||||
case *github.PushEvent:
|
||||
repo, pipeline, err := parsePushHook(hook)
|
||||
return nil, repo, pipeline, err
|
||||
repo, pipeline := parsePushHook(hook)
|
||||
return nil, repo, pipeline, nil
|
||||
case *github.DeploymentEvent:
|
||||
repo, pipeline, err := parseDeployHook(hook)
|
||||
return nil, repo, pipeline, err
|
||||
repo, pipeline := parseDeployHook(hook)
|
||||
return nil, repo, pipeline, nil
|
||||
case *github.PullRequestEvent:
|
||||
return parsePullHook(hook, merge)
|
||||
default:
|
||||
@@ -75,9 +75,9 @@ func parseHook(r *http.Request, merge bool) (*github.PullRequest, *model.Repo, *
|
||||
|
||||
// parsePushHook parses a push hook and returns the Repo and Pipeline details.
|
||||
// If the commit type is unsupported nil values are returned.
|
||||
func parsePushHook(hook *github.PushEvent) (*model.Repo, *model.Pipeline, error) {
|
||||
func parsePushHook(hook *github.PushEvent) (*model.Repo, *model.Pipeline) {
|
||||
if hook.Deleted != nil && *hook.Deleted {
|
||||
return nil, nil, nil
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
pipeline := &model.Pipeline{
|
||||
@@ -110,12 +110,12 @@ func parsePushHook(hook *github.PushEvent) (*model.Repo, *model.Pipeline, error)
|
||||
}
|
||||
}
|
||||
|
||||
return convertRepoHook(hook.GetRepo()), pipeline, nil
|
||||
return convertRepoHook(hook.GetRepo()), pipeline
|
||||
}
|
||||
|
||||
// parseDeployHook parses a deployment and returns the Repo and Pipeline details.
|
||||
// If the commit type is unsupported nil values are returned.
|
||||
func parseDeployHook(hook *github.DeploymentEvent) (*model.Repo, *model.Pipeline, error) {
|
||||
func parseDeployHook(hook *github.DeploymentEvent) (*model.Repo, *model.Pipeline) {
|
||||
pipeline := &model.Pipeline{
|
||||
Event: model.EventDeploy,
|
||||
Commit: hook.GetDeployment().GetSHA(),
|
||||
@@ -138,7 +138,7 @@ func parseDeployHook(hook *github.DeploymentEvent) (*model.Repo, *model.Pipeline
|
||||
pipeline.Ref = fmt.Sprintf("refs/heads/%s", pipeline.Branch)
|
||||
}
|
||||
|
||||
return convertRepo(hook.GetRepo()), pipeline, nil
|
||||
return convertRepo(hook.GetRepo()), pipeline
|
||||
}
|
||||
|
||||
// parsePullHook parses a pull request hook and returns the Repo and Pipeline
|
||||
|
||||
Reference in New Issue
Block a user