refactor: remove github.com/pkg/errors dependency (#1077)
* refactor: split out common/git * refactor: move git options to separate func * refactor: remove github.com/pkg/errors dependency * fix(golangci-lint): forbid github.com/pkg/errors * style: fix typo * style: fix typo Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
This commit is contained in:
@@ -3,7 +3,8 @@ package model
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/nektos/act/pkg/common"
|
||||
"github.com/nektos/act/pkg/common/git"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
@@ -85,8 +86,8 @@ func withDefaultBranch(b string, event map[string]interface{}) map[string]interf
|
||||
return event
|
||||
}
|
||||
|
||||
var findGitRef = common.FindGitRef
|
||||
var findGitRevision = common.FindGitRevision
|
||||
var findGitRef = git.FindGitRef
|
||||
var findGitRevision = git.FindGitRevision
|
||||
|
||||
func (ghc *GithubContext) SetRefAndSha(defaultBranch string, repoPath string) {
|
||||
// https://docs.github.com/en/actions/learn-github-actions/events-that-trigger-workflows
|
||||
|
@@ -10,7 +10,6 @@ import (
|
||||
"regexp"
|
||||
"sort"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
@@ -130,16 +129,16 @@ func NewWorkflowPlanner(path string, noWorkflowRecurse bool) (WorkflowPlanner, e
|
||||
log.Debugf("Reading workflow '%s'", f.Name())
|
||||
workflow, err := ReadWorkflow(f)
|
||||
if err != nil {
|
||||
f.Close()
|
||||
_ = f.Close()
|
||||
if err == io.EOF {
|
||||
return nil, errors.WithMessagef(err, "unable to read workflow, %s file is empty", wf.workflowFileInfo.Name())
|
||||
return nil, fmt.Errorf("unable to read workflow '%s': file is empty: %w", wf.workflowFileInfo.Name(), err)
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
_, err = f.Seek(0, 0)
|
||||
if err != nil {
|
||||
f.Close()
|
||||
return nil, errors.WithMessagef(err, "error occurring when resetting io pointer, %s", wf.workflowFileInfo.Name())
|
||||
_ = f.Close()
|
||||
return nil, fmt.Errorf("error occurring when resetting io pointer in '%s': %w", wf.workflowFileInfo.Name(), err)
|
||||
}
|
||||
|
||||
workflow.File = wf.workflowFileInfo.Name()
|
||||
@@ -155,7 +154,7 @@ func NewWorkflowPlanner(path string, noWorkflowRecurse bool) (WorkflowPlanner, e
|
||||
}
|
||||
|
||||
wp.workflows = append(wp.workflows, workflow)
|
||||
f.Close()
|
||||
_ = f.Close()
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -22,8 +22,8 @@ func TestPlanner(t *testing.T) {
|
||||
{"invalid-job-name/invalid-2.yml", "workflow is not valid. 'invalid-job-name-2': Job name '1234invalid-JOB-Name-v123-docker_hub' is invalid. Names must start with a letter or '_' and contain only alphanumeric characters, '-', or '_'", false},
|
||||
{"invalid-job-name/valid-1.yml", "", false},
|
||||
{"invalid-job-name/valid-2.yml", "", false},
|
||||
{"empty-workflow", "unable to read workflow, push.yml file is empty: EOF", false},
|
||||
{"nested", "unable to read workflow, fail.yml file is empty: EOF", false},
|
||||
{"empty-workflow", "unable to read workflow 'push.yml': file is empty: EOF", false},
|
||||
{"nested", "unable to read workflow 'fail.yml': file is empty: EOF", false},
|
||||
{"nested", "", true},
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user