1
0
Fork 0
mirror of https://codeberg.org/forgejo/forgejo.git synced 2025-08-06 18:35:23 +02:00

chore(cleanup): replaces unnecessary calls to formatting functions by non-formatting equivalents (#7994)

This PR replaces unnecessary calls to formatting functions (`fmt.Printf`, `fmt.Errorf`, ...) by non-formatting equivalents.
Resolves #7967

Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/7994
Reviewed-by: Gusted <gusted@noreply.codeberg.org>
Co-authored-by: chavacava <chavacava@noreply.codeberg.org>
Co-committed-by: chavacava <chavacava@noreply.codeberg.org>
This commit is contained in:
chavacava 2025-05-29 17:34:29 +02:00 committed by Gusted
parent 25f3f8e1d2
commit 99d697263f
126 changed files with 340 additions and 281 deletions

View file

@ -5,6 +5,7 @@ package files
import (
"context"
"errors"
"fmt"
"strings"
@ -88,7 +89,7 @@ func CherryPick(ctx context.Context, repo *repo_model.Repository, doer *user_mod
}
if conflict {
return nil, fmt.Errorf("failed to merge due to conflicts")
return nil, errors.New("failed to merge due to conflicts")
}
} else {
description := fmt.Sprintf("CherryPick %s onto %s", right, opts.OldBranch)
@ -98,7 +99,7 @@ func CherryPick(ctx context.Context, repo *repo_model.Repository, doer *user_mod
}
if conflict {
return nil, fmt.Errorf("failed to merge due to conflicts")
return nil, errors.New("failed to merge due to conflicts")
}
treeHash, err = t.WriteTree()

View file

@ -5,7 +5,7 @@ package files
import (
"context"
"fmt"
"errors"
"net/url"
"strings"
"time"
@ -50,10 +50,10 @@ func GetFileResponseFromFilesResponse(filesResponse *api.FilesResponse, index in
// GetFileCommitResponse Constructs a FileCommitResponse from a Commit object
func GetFileCommitResponse(repo *repo_model.Repository, commit *git.Commit) (*api.FileCommitResponse, error) {
if repo == nil {
return nil, fmt.Errorf("repo cannot be nil")
return nil, errors.New("repo cannot be nil")
}
if commit == nil {
return nil, fmt.Errorf("commit cannot be nil")
return nil, errors.New("commit cannot be nil")
}
commitURL, _ := url.Parse(repo.APIURL() + "/git/commits/" + url.PathEscape(commit.ID.String()))
commitTreeURL, _ := url.Parse(repo.APIURL() + "/git/trees/" + url.PathEscape(commit.Tree.ID.String()))

View file

@ -6,6 +6,7 @@ package files
import (
"bytes"
"context"
"errors"
"fmt"
"io"
"os"
@ -368,7 +369,7 @@ func (t *TemporaryUploadRepository) DiffIndex() (*gitdiff.Diff, error) {
// GetBranchCommit Gets the commit object of the given branch
func (t *TemporaryUploadRepository) GetBranchCommit(branch string) (*git.Commit, error) {
if t.gitRepo == nil {
return nil, fmt.Errorf("repository has not been cloned")
return nil, errors.New("repository has not been cloned")
}
return t.gitRepo.GetBranchCommit(branch)
}
@ -376,7 +377,7 @@ func (t *TemporaryUploadRepository) GetBranchCommit(branch string) (*git.Commit,
// GetCommit Gets the commit object of the given commit ID
func (t *TemporaryUploadRepository) GetCommit(commitID string) (*git.Commit, error) {
if t.gitRepo == nil {
return nil, fmt.Errorf("repository has not been cloned")
return nil, errors.New("repository has not been cloned")
}
return t.gitRepo.GetCommit(commitID)
}