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/wiki/wiki.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/wiki/wiki.go')
-rw-r--r-- | services/wiki/wiki.go | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/services/wiki/wiki.go b/services/wiki/wiki.go index 8faada4d59..f6986cff86 100644 --- a/services/wiki/wiki.go +++ b/services/wiki/wiki.go @@ -83,11 +83,11 @@ func InitWiki(ctx context.Context, repo *repo_model.Repository) error { } if err := git.InitRepository(ctx, repo.WikiPath(), true); err != nil { - return fmt.Errorf("InitRepository: %v", err) + return fmt.Errorf("InitRepository: %w", err) } else if err = repo_module.CreateDelegateHooks(repo.WikiPath()); err != nil { - return fmt.Errorf("createDelegateHooks: %v", err) + return fmt.Errorf("createDelegateHooks: %w", err) } else if _, _, err = git.NewCommand(ctx, "symbolic-ref", "HEAD", git.BranchPrefix+DefaultBranch).RunStdString(&git.RunOpts{Dir: repo.WikiPath()}); err != nil { - return fmt.Errorf("unable to set default wiki branch to master: %v", err) + return fmt.Errorf("unable to set default wiki branch to master: %w", err) } return nil } @@ -132,7 +132,7 @@ func updateWikiPage(ctx context.Context, doer *user_model.User, repo *repo_model defer wikiWorkingPool.CheckOut(fmt.Sprint(repo.ID)) if err = InitWiki(ctx, repo); err != nil { - return fmt.Errorf("InitWiki: %v", err) + return fmt.Errorf("InitWiki: %w", err) } hasMasterBranch := git.IsBranchExist(ctx, repo.WikiPath(), DefaultBranch) @@ -158,20 +158,20 @@ func updateWikiPage(ctx context.Context, doer *user_model.User, repo *repo_model if err := git.Clone(ctx, repo.WikiPath(), basePath, cloneOpts); err != nil { log.Error("Failed to clone repository: %s (%v)", repo.FullName(), err) - return fmt.Errorf("Failed to clone repository: %s (%v)", repo.FullName(), err) + return fmt.Errorf("Failed to clone repository: %s (%w)", repo.FullName(), err) } gitRepo, err := git.OpenRepository(ctx, basePath) if err != nil { log.Error("Unable to open temporary repository: %s (%v)", basePath, err) - return fmt.Errorf("Failed to open new temporary repository in: %s %v", basePath, err) + return fmt.Errorf("Failed to open new temporary repository in: %s %w", basePath, err) } defer gitRepo.Close() if hasMasterBranch { if err := gitRepo.ReadTreeToIndex("HEAD"); err != nil { log.Error("Unable to read HEAD tree to index in: %s %v", basePath, err) - return fmt.Errorf("Unable to read HEAD tree to index in: %s %v", basePath, err) + return fmt.Errorf("Unable to read HEAD tree to index in: %s %w", basePath, err) } } @@ -265,7 +265,7 @@ func updateWikiPage(ctx context.Context, doer *user_model.User, repo *repo_model if git.IsErrPushOutOfDate(err) || git.IsErrPushRejected(err) { return err } - return fmt.Errorf("Push: %v", err) + return fmt.Errorf("Push: %w", err) } return nil @@ -288,7 +288,7 @@ func DeleteWikiPage(ctx context.Context, doer *user_model.User, repo *repo_model defer wikiWorkingPool.CheckOut(fmt.Sprint(repo.ID)) if err = InitWiki(ctx, repo); err != nil { - return fmt.Errorf("InitWiki: %v", err) + return fmt.Errorf("InitWiki: %w", err) } basePath, err := repo_module.CreateTemporaryPath("update-wiki") @@ -307,19 +307,19 @@ func DeleteWikiPage(ctx context.Context, doer *user_model.User, repo *repo_model Branch: DefaultBranch, }); err != nil { log.Error("Failed to clone repository: %s (%v)", repo.FullName(), err) - return fmt.Errorf("Failed to clone repository: %s (%v)", repo.FullName(), err) + return fmt.Errorf("Failed to clone repository: %s (%w)", repo.FullName(), err) } gitRepo, err := git.OpenRepository(ctx, basePath) if err != nil { log.Error("Unable to open temporary repository: %s (%v)", basePath, err) - return fmt.Errorf("Failed to open new temporary repository in: %s %v", basePath, err) + return fmt.Errorf("Failed to open new temporary repository in: %s %w", basePath, err) } defer gitRepo.Close() if err := gitRepo.ReadTreeToIndex("HEAD"); err != nil { log.Error("Unable to read HEAD tree to index in: %s %v", basePath, err) - return fmt.Errorf("Unable to read HEAD tree to index in: %s %v", basePath, err) + return fmt.Errorf("Unable to read HEAD tree to index in: %s %w", basePath, err) } found, wikiPath, err := prepareWikiFileName(gitRepo, wikiName) @@ -372,7 +372,7 @@ func DeleteWikiPage(ctx context.Context, doer *user_model.User, repo *repo_model if git.IsErrPushOutOfDate(err) || git.IsErrPushRejected(err) { return err } - return fmt.Errorf("Push: %v", err) + return fmt.Errorf("Push: %w", err) } return nil |