diff options
author | delvh <leon@kske.dev> | 2022-10-24 21:29:17 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-24 20:29:17 +0100 |
commit | 0ebb45cfe7606adf021ad359d6fbfcefc54360a5 (patch) | |
tree | 541b75d083213e93bbbfadbdc5d560c739543903 /services/repository/adopt.go | |
parent | 7c11a73833f3aa9783015e5e13871d3c298d3ef6 (diff) | |
download | gitea-0ebb45cfe7606adf021ad359d6fbfcefc54360a5.tar.gz gitea-0ebb45cfe7606adf021ad359d6fbfcefc54360a5.zip |
Replace all instances of fmt.Errorf(%v) with fmt.Errorf(%w) (#21551)
Found using
`find . -type f -name '*.go' -print -exec vim {} -c
':%s/fmt\.Errorf(\(.*\)%v\(.*\)err/fmt.Errorf(\1%w\2err/g' -c ':wq' \;`
Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Diffstat (limited to 'services/repository/adopt.go')
-rw-r--r-- | services/repository/adopt.go | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/services/repository/adopt.go b/services/repository/adopt.go index 9e04c15977..3b986c66c6 100644 --- a/services/repository/adopt.go +++ b/services/repository/adopt.go @@ -71,16 +71,16 @@ func AdoptRepository(doer, u *user_model.User, opts repo_module.CreateRepoOption return err } if err := adoptRepository(ctx, repoPath, doer, repo, opts); err != nil { - return fmt.Errorf("createDelegateHooks: %v", err) + return fmt.Errorf("createDelegateHooks: %w", err) } if err := repo_module.CheckDaemonExportOK(ctx, repo); err != nil { - return fmt.Errorf("checkDaemonExportOK: %v", err) + return fmt.Errorf("checkDaemonExportOK: %w", err) } // Initialize Issue Labels if selected if len(opts.IssueLabels) > 0 { if err := repo_module.InitializeLabels(ctx, repo.ID, opts.IssueLabels, false); err != nil { - return fmt.Errorf("InitializeLabels: %v", err) + return fmt.Errorf("InitializeLabels: %w", err) } } @@ -88,7 +88,7 @@ func AdoptRepository(doer, u *user_model.User, opts repo_module.CreateRepoOption SetDescription(fmt.Sprintf("CreateRepository(git update-server-info): %s", repoPath)). RunStdString(&git.RunOpts{Dir: repoPath}); err != nil { log.Error("CreateRepository(git update-server-info) in %v: Stdout: %s\nError: %v", repo, stdout, err) - return fmt.Errorf("CreateRepository(git update-server-info): %v", err) + return fmt.Errorf("CreateRepository(git update-server-info): %w", err) } return nil }); err != nil { @@ -111,13 +111,13 @@ func adoptRepository(ctx context.Context, repoPath string, u *user_model.User, r } if err := repo_module.CreateDelegateHooks(repoPath); err != nil { - return fmt.Errorf("createDelegateHooks: %v", err) + return fmt.Errorf("createDelegateHooks: %w", err) } // Re-fetch the repository from database before updating it (else it would // override changes that were done earlier with sql) if repo, err = repo_model.GetRepositoryByIDCtx(ctx, repo.ID); err != nil { - return fmt.Errorf("getRepositoryByID: %v", err) + return fmt.Errorf("getRepositoryByID: %w", err) } repo.IsEmpty = false @@ -125,7 +125,7 @@ func adoptRepository(ctx context.Context, repoPath string, u *user_model.User, r // Don't bother looking this repo in the context it won't be there gitRepo, err := git.OpenRepository(ctx, repo.RepoPath()) if err != nil { - return fmt.Errorf("openRepository: %v", err) + return fmt.Errorf("openRepository: %w", err) } defer gitRepo.Close() @@ -133,14 +133,14 @@ func adoptRepository(ctx context.Context, repoPath string, u *user_model.User, r repo.DefaultBranch = opts.DefaultBranch if err = gitRepo.SetDefaultBranch(repo.DefaultBranch); err != nil { - return fmt.Errorf("setDefaultBranch: %v", err) + return fmt.Errorf("setDefaultBranch: %w", err) } } else { repo.DefaultBranch, err = gitRepo.GetDefaultBranch() if err != nil { repo.DefaultBranch = setting.Repository.DefaultBranch if err = gitRepo.SetDefaultBranch(repo.DefaultBranch); err != nil { - return fmt.Errorf("setDefaultBranch: %v", err) + return fmt.Errorf("setDefaultBranch: %w", err) } } } @@ -176,12 +176,12 @@ func adoptRepository(ctx context.Context, repoPath string, u *user_model.User, r } if err = gitRepo.SetDefaultBranch(repo.DefaultBranch); err != nil { - return fmt.Errorf("setDefaultBranch: %v", err) + return fmt.Errorf("setDefaultBranch: %w", err) } } if err = repo_module.UpdateRepository(ctx, repo, false); err != nil { - return fmt.Errorf("updateRepository: %v", err) + return fmt.Errorf("updateRepository: %w", err) } return nil |