internal: fix linter errors
Fix errors reported by default golangci-lint linters
This commit is contained in:
parent
8ef3c1d9b3
commit
3a7ba2694d
|
@ -280,9 +280,9 @@ func (s *Steps) UnmarshalJSON(b []byte) error {
|
|||
|
||||
case "run":
|
||||
var s RunStep
|
||||
switch stepSpec.(type) {
|
||||
switch stepSpec := stepSpec.(type) {
|
||||
case string:
|
||||
s.Command = stepSpec.(string)
|
||||
s.Command = stepSpec
|
||||
default:
|
||||
if err := json.Unmarshal(stepSpecRaw, &s); err != nil {
|
||||
return err
|
||||
|
|
|
@ -177,12 +177,12 @@ func (db *DB) Do(f func(tx *Tx) error) error {
|
|||
}
|
||||
defer func() {
|
||||
if p := recover(); p != nil {
|
||||
tx.Rollback()
|
||||
_ = tx.Rollback()
|
||||
panic(p)
|
||||
}
|
||||
}()
|
||||
if err = f(tx); err != nil {
|
||||
tx.Rollback()
|
||||
_ = tx.Rollback()
|
||||
return err
|
||||
}
|
||||
return tx.Commit()
|
||||
|
|
|
@ -159,6 +159,11 @@ func (h *GitSmartHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||
ctx := r.Context()
|
||||
|
||||
repoPath, reqType, err := MatchPath(r.URL.Path)
|
||||
if err != nil {
|
||||
http.Error(w, err.Error(), http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
|
||||
repoAbsPath, exists, err := h.repoAbsPathFunc(h.reposDir, repoPath)
|
||||
if err != nil {
|
||||
if err == ErrWrongRepoPath {
|
||||
|
@ -207,7 +212,7 @@ func (h *GitSmartHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||
}
|
||||
|
||||
w.Header().Set("Content-Type", "application/x-git-"+serviceName+"-advertisement")
|
||||
w.Write(res)
|
||||
_, _ = w.Write(res)
|
||||
|
||||
case RequestTypeUploadPack:
|
||||
w.Header().Set("Content-Type", "application/x-git-upload-pack-result")
|
||||
|
|
|
@ -171,7 +171,6 @@ func unescape(s string) (string, bool, error) {
|
|||
if nc > splitLength && nc%splitLength == 2 && s[len(s)-2:] == ".f" {
|
||||
hasFileMarker = true
|
||||
s = s[:len(s)-2]
|
||||
nc -= 2
|
||||
}
|
||||
|
||||
if n == 0 && ns == 0 {
|
||||
|
|
|
@ -104,8 +104,8 @@ func (p *Process) Kill() {
|
|||
if p.Cmd == nil {
|
||||
panic(fmt.Errorf("p: %s, cmd is empty", p.uid))
|
||||
}
|
||||
p.Cmd.Cmd.Process.Signal(os.Kill)
|
||||
p.Cmd.Wait()
|
||||
_ = p.Cmd.Cmd.Process.Signal(os.Kill)
|
||||
_ = p.Cmd.Wait()
|
||||
p.Cmd = nil
|
||||
}
|
||||
|
||||
|
@ -115,8 +115,8 @@ func (p *Process) Stop() {
|
|||
panic(fmt.Errorf("p: %s, cmd is empty", p.uid))
|
||||
}
|
||||
p.Cmd.Continue()
|
||||
p.Cmd.Cmd.Process.Signal(os.Interrupt)
|
||||
p.Cmd.Wait()
|
||||
_ = p.Cmd.Cmd.Process.Signal(os.Interrupt)
|
||||
_ = p.Cmd.Wait()
|
||||
p.Cmd = nil
|
||||
}
|
||||
|
||||
|
|
|
@ -184,7 +184,3 @@ func writeNewHardLink(fpath string, target string) error {
|
|||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func isSymlink(fi os.FileInfo) bool {
|
||||
return fi.Mode()&os.ModeSymlink != 0
|
||||
}
|
||||
|
|
|
@ -50,7 +50,6 @@ func ParseGitURL(u string) (*url.URL, error) {
|
|||
}
|
||||
|
||||
type Git struct {
|
||||
cmd *exec.Cmd
|
||||
GitDir string
|
||||
Env []string
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ import (
|
|||
func EncodeSha1Hex(str string) string {
|
||||
h := sha1.New()
|
||||
// TODO(sgotti) must handle write errors
|
||||
h.Write([]byte(str))
|
||||
_, _ = h.Write([]byte(str))
|
||||
return hex.EncodeToString(h.Sum(nil))
|
||||
}
|
||||
|
||||
|
@ -32,6 +32,6 @@ func EncodeSha1Hex(str string) string {
|
|||
func EncodeSha256Hex(str string) string {
|
||||
h := sha256.New()
|
||||
// TODO(sgotti) must handle write errors
|
||||
h.Write([]byte(str))
|
||||
_, _ = h.Write([]byte(str))
|
||||
return hex.EncodeToString(h.Sum(nil))
|
||||
}
|
||||
|
|
|
@ -51,8 +51,8 @@ func CompareStringSliceNoOrder(a []string, b []string) bool {
|
|||
a = append([]string(nil), a...)
|
||||
b = append([]string(nil), b...)
|
||||
|
||||
sort.Sort(sort.StringSlice(a))
|
||||
sort.Sort(sort.StringSlice(b))
|
||||
sort.Strings(a)
|
||||
sort.Strings(b)
|
||||
|
||||
for i, v := range a {
|
||||
if v != b[i] {
|
||||
|
|
Loading…
Reference in New Issue