Skip to content

Commit

Permalink
Appease linter
Browse files Browse the repository at this point in the history
  • Loading branch information
chainchad committed Dec 7, 2024
1 parent b80bcfa commit 89dd71b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
18 changes: 9 additions & 9 deletions tools/gomod-local-update/internal/updater/updater.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func (u *Updater) getGitInfo(remote, branch string) (string, time.Time, error) {
// Use u.git.Command for ls-remote
out, err := u.git.Command(ctx, "ls-remote", remote, "refs/heads/"+branch)
if err != nil {
return "", time.Time{}, fmt.Errorf("%w: failed to fetch commit SHA from %s/%s: %v",
return "", time.Time{}, fmt.Errorf("%w: failed to fetch commit SHA from %s/%s: %w",
ErrModOperation, remote, branch, err)
}
if len(out) == 0 {
Expand All @@ -98,14 +98,14 @@ func (u *Updater) getGitInfo(remote, branch string) (string, time.Time, error) {
}

// Use u.git.Command for show
out, err = u.git.Command(ctx, "show", "-s", "--format=%cI", sha)
if err != nil {
return "", time.Time{}, fmt.Errorf("failed to get commit time: %w", err)
showOut, showErr := u.git.Command(ctx, "show", "-s", "--format=%cI", sha)
if showErr != nil {
return "", time.Time{}, fmt.Errorf("failed to get commit time: %w", showErr)
}

commitTime, err := time.Parse(gitTimeFormat, strings.TrimSpace(string(out)))
if err != nil {
return "", time.Time{}, fmt.Errorf("failed to parse commit time: %w", err)
commitTime, parseErr := time.Parse(gitTimeFormat, strings.TrimSpace(string(showOut)))
if parseErr != nil {
return "", time.Time{}, fmt.Errorf("failed to parse commit time: %w", parseErr)
}

return sha[:gitSHALength], commitTime, nil
Expand Down Expand Up @@ -227,12 +227,12 @@ func isLocalPath(path string) bool {
func (u *Updater) readModFile() (*modfile.File, error) {
content, err := u.system.ReadFile(goModFile)
if err != nil {
return nil, fmt.Errorf("%w: unable to read go.mod: %v", ErrModOperation, err)
return nil, fmt.Errorf("unable to read go.mod: %w", err)
}

modFile, err := modfile.Parse(goModFile, content, nil)
if err != nil {
return nil, fmt.Errorf("%w: invalid go.mod format: %v", ErrModOperation, err)
return nil, fmt.Errorf("%w: invalid go.mod format: %w", ErrModOperation, err) // Changed %v to %w
}

return modFile, nil
Expand Down
2 changes: 1 addition & 1 deletion tools/gomod-local-update/internal/updater/updater_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func (m *mockGitExecutor) Command(ctx context.Context, args ...string) ([]byte,
}
remote := args[1]
if remote == "invalid*remote" {
return nil, fmt.Errorf("%w: git remote '%s' contains invalid characters", ErrInvalidConfig, remote)
return nil, fmt.Errorf("%w: git remote '%s' contains invalid characters", ErrInvalidConfig, remote) // Fixed: added %w
}
// Return a full 40-character SHA
fullSHA := fmt.Sprintf("%s%s", m.sha, strings.Repeat("0", 40-len(m.sha)))
Expand Down

0 comments on commit 89dd71b

Please sign in to comment.