Skip to content

Commit

Permalink
fix: don't replace err variable in nested check (go-gitea#22416)
Browse files Browse the repository at this point in the history
We can use `:=` to make `err` local to the if-scope instead of
overwriting the `err` in outer scope.

Signed-off-by: jolheiser <[email protected]>
  • Loading branch information
jolheiser committed Jan 13, 2023
1 parent 421d879 commit b552ec2
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions services/repository/check.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func GitGcRepos(ctx context.Context, timeout time.Duration, args ...git.CmdArg)
if err != nil {
log.Error("Repository garbage collection failed for %v. Stdout: %s\nError: %v", repo, stdout, err)
desc := fmt.Sprintf("Repository garbage collection failed for %s. Stdout: %s\nError: %v", repo.RepoPath(), stdout, err)
if err = system_model.CreateRepositoryNotice(desc); err != nil {
if err := system_model.CreateRepositoryNotice(desc); err != nil {
log.Error("CreateRepositoryNotice: %v", err)
}
return fmt.Errorf("Repository garbage collection failed in repo: %s: Error: %w", repo.FullName(), err)
Expand All @@ -93,7 +93,7 @@ func GitGcRepos(ctx context.Context, timeout time.Duration, args ...git.CmdArg)
if err := repo_module.UpdateRepoSize(ctx, repo); err != nil {
log.Error("Updating size as part of garbage collection failed for %v. Stdout: %s\nError: %v", repo, stdout, err)
desc := fmt.Sprintf("Updating size as part of garbage collection failed for %s. Stdout: %s\nError: %v", repo.RepoPath(), stdout, err)
if err = system_model.CreateRepositoryNotice(desc); err != nil {
if err := system_model.CreateRepositoryNotice(desc); err != nil {
log.Error("CreateRepositoryNotice: %v", err)
}
return fmt.Errorf("Updating size as part of garbage collection failed in repo: %s: Error: %w", repo.FullName(), err)
Expand Down

0 comments on commit b552ec2

Please sign in to comment.