From 887a683af97b570a0fb117068c980f3086133ae4 Mon Sep 17 00:00:00 2001 From: silverwind Date: Sun, 9 Jul 2023 13:58:06 +0200 Subject: Update tool dependencies, lock govulncheck and actionlint (#25655) - Update all tool dependencies - Lock `govulncheck` and `actionlint` to their latest tags --------- Co-authored-by: 6543 Co-authored-by: 6543 <6543@obermui.de> Co-authored-by: wxiaoguang --- modules/git/batch_reader.go | 20 ++++++++------------ modules/git/commit.go | 2 +- modules/git/git.go | 2 +- modules/git/repo_base_nogogit.go | 2 +- modules/git/repo_index.go | 2 +- modules/git/signature_nogogit.go | 13 +++++++------ 6 files changed, 19 insertions(+), 22 deletions(-) (limited to 'modules/git') diff --git a/modules/git/batch_reader.go b/modules/git/batch_reader.go index 75539c0d0a..891e8a2384 100644 --- a/modules/git/batch_reader.go +++ b/modules/git/batch_reader.go @@ -148,27 +148,25 @@ func CatFileBatch(ctx context.Context, repoPath string) (WriteCloserError, *bufi func ReadBatchLine(rd *bufio.Reader) (sha []byte, typ string, size int64, err error) { typ, err = rd.ReadString('\n') if err != nil { - return + return sha, typ, size, err } if len(typ) == 1 { typ, err = rd.ReadString('\n') if err != nil { - return + return sha, typ, size, err } } idx := strings.IndexByte(typ, ' ') if idx < 0 { log.Debug("missing space typ: %s", typ) - err = ErrNotExist{ID: string(sha)} - return + return sha, typ, size, ErrNotExist{ID: string(sha)} } sha = []byte(typ[:idx]) typ = typ[idx+1:] idx = strings.IndexByte(typ, ' ') if idx < 0 { - err = ErrNotExist{ID: string(sha)} - return + return sha, typ, size, ErrNotExist{ID: string(sha)} } sizeStr := typ[idx+1 : len(typ)-1] @@ -285,14 +283,12 @@ func ParseTreeLine(rd *bufio.Reader, modeBuf, fnameBuf, shaBuf []byte) (mode, fn // Read the Mode & fname readBytes, err = rd.ReadSlice('\x00') if err != nil { - return + return mode, fname, sha, n, err } idx := bytes.IndexByte(readBytes, ' ') if idx < 0 { log.Debug("missing space in readBytes ParseTreeLine: %s", readBytes) - - err = &ErrNotExist{} - return + return mode, fname, sha, n, &ErrNotExist{} } n += idx + 1 @@ -319,7 +315,7 @@ func ParseTreeLine(rd *bufio.Reader, modeBuf, fnameBuf, shaBuf []byte) (mode, fn } n += len(fnameBuf) if err != nil { - return + return mode, fname, sha, n, err } fnameBuf = fnameBuf[:len(fnameBuf)-1] fname = fnameBuf @@ -331,7 +327,7 @@ func ParseTreeLine(rd *bufio.Reader, modeBuf, fnameBuf, shaBuf []byte) (mode, fn read, err = rd.Read(shaBuf[idx:20]) n += read if err != nil { - return + return mode, fname, sha, n, err } idx += read } diff --git a/modules/git/commit.go b/modules/git/commit.go index ff654f394d..729e3b4672 100644 --- a/modules/git/commit.go +++ b/modules/git/commit.go @@ -435,7 +435,7 @@ func (c *Commit) GetBranchName() (string, error) { // LoadBranchName load branch name for commit func (c *Commit) LoadBranchName() (err error) { if len(c.Branch) != 0 { - return + return nil } c.Branch, err = c.GetBranchName() diff --git a/modules/git/git.go b/modules/git/git.go index c9d174e118..12d2f94e51 100644 --- a/modules/git/git.go +++ b/modules/git/git.go @@ -171,7 +171,7 @@ func InitFull(ctx context.Context) (err error) { } if err = InitSimple(ctx); err != nil { - return + return err } // when git works with gnupg (commit signing), there should be a stable home for gnupg commands diff --git a/modules/git/repo_base_nogogit.go b/modules/git/repo_base_nogogit.go index e0f2d563b3..414e4eb1a8 100644 --- a/modules/git/repo_base_nogogit.go +++ b/modules/git/repo_base_nogogit.go @@ -87,7 +87,7 @@ func (repo *Repository) CatFileBatchCheck(ctx context.Context) (WriteCloserError // Close this repository, in particular close the underlying gogitStorage if this is not nil func (repo *Repository) Close() (err error) { if repo == nil { - return + return nil } if repo.batchCancel != nil { repo.batchCancel() diff --git a/modules/git/repo_index.go b/modules/git/repo_index.go index 5ff2a2e4fc..34dd1e0129 100644 --- a/modules/git/repo_index.go +++ b/modules/git/repo_index.go @@ -48,7 +48,7 @@ func (repo *Repository) readTreeToIndex(id SHA1, indexFilename ...string) error func (repo *Repository) ReadTreeToTemporaryIndex(treeish string) (filename, tmpDir string, cancel context.CancelFunc, err error) { tmpDir, err = os.MkdirTemp("", "index") if err != nil { - return + return filename, tmpDir, cancel, err } filename = filepath.Join(tmpDir, ".tmp-index") diff --git a/modules/git/signature_nogogit.go b/modules/git/signature_nogogit.go index a203d5ce6d..25277f99d5 100644 --- a/modules/git/signature_nogogit.go +++ b/modules/git/signature_nogogit.go @@ -43,12 +43,13 @@ func (s *Signature) Decode(b []byte) { // // but without the "author " at the beginning (this method should) // be used for author and committer. +// FIXME: there are a lot of "return sig, err" (but the err is also nil), that's the old behavior, to avoid breaking func newSignatureFromCommitline(line []byte) (sig *Signature, err error) { sig = new(Signature) emailStart := bytes.LastIndexByte(line, '<') emailEnd := bytes.LastIndexByte(line, '>') if emailStart == -1 || emailEnd == -1 || emailEnd < emailStart { - return + return sig, err } if emailStart > 0 { // Empty name has already occurred, even if it shouldn't @@ -58,7 +59,7 @@ func newSignatureFromCommitline(line []byte) (sig *Signature, err error) { hasTime := emailEnd+2 < len(line) if !hasTime { - return + return sig, err } // Check date format. @@ -66,7 +67,7 @@ func newSignatureFromCommitline(line []byte) (sig *Signature, err error) { if firstChar >= 48 && firstChar <= 57 { idx := bytes.IndexByte(line[emailEnd+2:], ' ') if idx < 0 { - return + return sig, err } timestring := string(line[emailEnd+2 : emailEnd+2+idx]) @@ -75,14 +76,14 @@ func newSignatureFromCommitline(line []byte) (sig *Signature, err error) { idx += emailEnd + 3 if idx >= len(line) || idx+5 > len(line) { - return + return sig, err } timezone := string(line[idx : idx+5]) tzhours, err1 := strconv.ParseInt(timezone[0:3], 10, 64) tzmins, err2 := strconv.ParseInt(timezone[3:], 10, 64) if err1 != nil || err2 != nil { - return + return sig, err } if tzhours < 0 { tzmins *= -1 @@ -92,7 +93,7 @@ func newSignatureFromCommitline(line []byte) (sig *Signature, err error) { } else { sig.When, err = time.Parse(GitTimeLayout, string(line[emailEnd+2:])) if err != nil { - return + return sig, err } } return sig, err -- cgit v1.2.3