summaryrefslogtreecommitdiffstats
path: root/models/repo
diff options
context:
space:
mode:
Diffstat (limited to 'models/repo')
-rw-r--r--models/repo/attachment.go2
-rw-r--r--models/repo/avatar.go4
-rw-r--r--models/repo/collaboration.go8
-rw-r--r--models/repo/release.go20
-rw-r--r--models/repo/repo.go2
-rw-r--r--models/repo/repo_indexer.go6
-rw-r--r--models/repo/repo_list.go12
-rw-r--r--models/repo/update.go8
-rw-r--r--models/repo/upload.go16
9 files changed, 39 insertions, 39 deletions
diff --git a/models/repo/attachment.go b/models/repo/attachment.go
index 5d4e11ae72..180d7730ba 100644
--- a/models/repo/attachment.go
+++ b/models/repo/attachment.go
@@ -40,7 +40,7 @@ func init() {
func (a *Attachment) IncreaseDownloadCount() error {
// Update download count.
if _, err := db.GetEngine(db.DefaultContext).Exec("UPDATE `attachment` SET download_count=download_count+1 WHERE id=?", a.ID); err != nil {
- return fmt.Errorf("increase attachment count: %v", err)
+ return fmt.Errorf("increase attachment count: %w", err)
}
return nil
diff --git a/models/repo/avatar.go b/models/repo/avatar.go
index cdf85bf1ac..1bc37598fe 100644
--- a/models/repo/avatar.go
+++ b/models/repo/avatar.go
@@ -36,7 +36,7 @@ func generateRandomAvatar(ctx context.Context, repo *Repository) error {
seed := idToString
img, err := avatar.RandomImage([]byte(seed))
if err != nil {
- return fmt.Errorf("RandomImage: %v", err)
+ return fmt.Errorf("RandomImage: %w", err)
}
repo.Avatar = idToString
@@ -47,7 +47,7 @@ func generateRandomAvatar(ctx context.Context, repo *Repository) error {
}
return err
}); err != nil {
- return fmt.Errorf("Failed to create dir %s: %v", repo.CustomAvatarRelativePath(), err)
+ return fmt.Errorf("Failed to create dir %s: %w", repo.CustomAvatarRelativePath(), err)
}
log.Info("New random avatar created for repository: %d", repo.ID)
diff --git a/models/repo/collaboration.go b/models/repo/collaboration.go
index be05eba74c..0aaa749210 100644
--- a/models/repo/collaboration.go
+++ b/models/repo/collaboration.go
@@ -40,7 +40,7 @@ type Collaborator struct {
func GetCollaborators(ctx context.Context, repoID int64, listOptions db.ListOptions) ([]*Collaborator, error) {
collaborations, err := getCollaborations(ctx, repoID, listOptions)
if err != nil {
- return nil, fmt.Errorf("getCollaborations: %v", err)
+ return nil, fmt.Errorf("getCollaborations: %w", err)
}
collaborators := make([]*Collaborator, 0, len(collaborations))
@@ -114,7 +114,7 @@ func ChangeCollaborationAccessModeCtx(ctx context.Context, repo *Repository, uid
}
has, err := e.Get(collaboration)
if err != nil {
- return fmt.Errorf("get collaboration: %v", err)
+ return fmt.Errorf("get collaboration: %w", err)
} else if !has {
return nil
}
@@ -128,9 +128,9 @@ func ChangeCollaborationAccessModeCtx(ctx context.Context, repo *Repository, uid
ID(collaboration.ID).
Cols("mode").
Update(collaboration); err != nil {
- return fmt.Errorf("update collaboration: %v", err)
+ return fmt.Errorf("update collaboration: %w", err)
} else if _, err = e.Exec("UPDATE access SET mode = ? WHERE user_id = ? AND repo_id = ?", mode, uid, repo.ID); err != nil {
- return fmt.Errorf("update access table: %v", err)
+ return fmt.Errorf("update access table: %w", err)
}
return nil
diff --git a/models/repo/release.go b/models/repo/release.go
index 2e7bc6d322..14428f15f7 100644
--- a/models/repo/release.go
+++ b/models/repo/release.go
@@ -156,7 +156,7 @@ func AddReleaseAttachments(ctx context.Context, releaseID int64, attachmentUUIDs
// Check attachments
attachments, err := GetAttachmentsByUUIDs(ctx, attachmentUUIDs)
if err != nil {
- return fmt.Errorf("GetAttachmentsByUUIDs [uuids: %v]: %v", attachmentUUIDs, err)
+ return fmt.Errorf("GetAttachmentsByUUIDs [uuids: %v]: %w", attachmentUUIDs, err)
}
for i := range attachments {
@@ -166,7 +166,7 @@ func AddReleaseAttachments(ctx context.Context, releaseID int64, attachmentUUIDs
attachments[i].ReleaseID = releaseID
// No assign value could be 0, so ignore AllCols().
if _, err = db.GetEngine(ctx).ID(attachments[i].ID).Update(attachments[i]); err != nil {
- return fmt.Errorf("update attachment [%d]: %v", attachments[i].ID, err)
+ return fmt.Errorf("update attachment [%d]: %w", attachments[i].ID, err)
}
}
@@ -413,7 +413,7 @@ func PushUpdateDeleteTagsContext(ctx context.Context, repo *Repository, tags []s
Where("repo_id = ? AND is_tag = ?", repo.ID, true).
In("lower_tag_name", lowerTags).
Delete(new(Release)); err != nil {
- return fmt.Errorf("Delete: %v", err)
+ return fmt.Errorf("Delete: %w", err)
}
if _, err := db.GetEngine(ctx).
@@ -423,7 +423,7 @@ func PushUpdateDeleteTagsContext(ctx context.Context, repo *Repository, tags []s
Update(&Release{
IsDraft: true,
}); err != nil {
- return fmt.Errorf("Update: %v", err)
+ return fmt.Errorf("Update: %w", err)
}
return nil
@@ -436,18 +436,18 @@ func PushUpdateDeleteTag(repo *Repository, tagName string) error {
if IsErrReleaseNotExist(err) {
return nil
}
- return fmt.Errorf("GetRelease: %v", err)
+ return fmt.Errorf("GetRelease: %w", err)
}
if rel.IsTag {
if _, err = db.GetEngine(db.DefaultContext).ID(rel.ID).Delete(new(Release)); err != nil {
- return fmt.Errorf("Delete: %v", err)
+ return fmt.Errorf("Delete: %w", err)
}
} else {
rel.IsDraft = true
rel.NumCommits = 0
rel.Sha1 = ""
if _, err = db.GetEngine(db.DefaultContext).ID(rel.ID).AllCols().Update(rel); err != nil {
- return fmt.Errorf("Update: %v", err)
+ return fmt.Errorf("Update: %w", err)
}
}
@@ -458,13 +458,13 @@ func PushUpdateDeleteTag(repo *Repository, tagName string) error {
func SaveOrUpdateTag(repo *Repository, newRel *Release) error {
rel, err := GetRelease(repo.ID, newRel.TagName)
if err != nil && !IsErrReleaseNotExist(err) {
- return fmt.Errorf("GetRelease: %v", err)
+ return fmt.Errorf("GetRelease: %w", err)
}
if rel == nil {
rel = newRel
if _, err = db.GetEngine(db.DefaultContext).Insert(rel); err != nil {
- return fmt.Errorf("InsertOne: %v", err)
+ return fmt.Errorf("InsertOne: %w", err)
}
} else {
rel.Sha1 = newRel.Sha1
@@ -475,7 +475,7 @@ func SaveOrUpdateTag(repo *Repository, newRel *Release) error {
rel.PublisherID = newRel.PublisherID
}
if _, err = db.GetEngine(db.DefaultContext).ID(rel.ID).AllCols().Update(rel); err != nil {
- return fmt.Errorf("Update: %v", err)
+ return fmt.Errorf("Update: %w", err)
}
}
return nil
diff --git a/models/repo/repo.go b/models/repo/repo.go
index ce698baaef..848138c824 100644
--- a/models/repo/repo.go
+++ b/models/repo/repo.go
@@ -760,7 +760,7 @@ func CountRepositories(ctx context.Context, opts CountRepositoryOptions) (int64,
count, err := sess.Count(new(Repository))
if err != nil {
- return 0, fmt.Errorf("countRepositories: %v", err)
+ return 0, fmt.Errorf("countRepositories: %w", err)
}
return count, nil
}
diff --git a/models/repo/repo_indexer.go b/models/repo/repo_indexer.go
index cba70a14e5..67ba3382dc 100644
--- a/models/repo/repo_indexer.go
+++ b/models/repo/repo_indexer.go
@@ -95,13 +95,13 @@ func GetIndexerStatus(ctx context.Context, repo *Repository, indexerType RepoInd
func UpdateIndexerStatus(ctx context.Context, repo *Repository, indexerType RepoIndexerType, sha string) error {
status, err := GetIndexerStatus(ctx, repo, indexerType)
if err != nil {
- return fmt.Errorf("UpdateIndexerStatus: Unable to getIndexerStatus for repo: %s Error: %v", repo.FullName(), err)
+ return fmt.Errorf("UpdateIndexerStatus: Unable to getIndexerStatus for repo: %s Error: %w", repo.FullName(), err)
}
if len(status.CommitSha) == 0 {
status.CommitSha = sha
if err := db.Insert(ctx, status); err != nil {
- return fmt.Errorf("UpdateIndexerStatus: Unable to insert repoIndexerStatus for repo: %s Sha: %s Error: %v", repo.FullName(), sha, err)
+ return fmt.Errorf("UpdateIndexerStatus: Unable to insert repoIndexerStatus for repo: %s Sha: %s Error: %w", repo.FullName(), sha, err)
}
return nil
}
@@ -109,7 +109,7 @@ func UpdateIndexerStatus(ctx context.Context, repo *Repository, indexerType Repo
_, err = db.GetEngine(ctx).ID(status.ID).Cols("commit_sha").
Update(status)
if err != nil {
- return fmt.Errorf("UpdateIndexerStatus: Unable to update repoIndexerStatus for repo: %s Sha: %s Error: %v", repo.FullName(), sha, err)
+ return fmt.Errorf("UpdateIndexerStatus: Unable to update repoIndexerStatus for repo: %s Sha: %s Error: %w", repo.FullName(), sha, err)
}
return nil
}
diff --git a/models/repo/repo_list.go b/models/repo/repo_list.go
index 0cd0a3c8e3..191970d275 100644
--- a/models/repo/repo_list.go
+++ b/models/repo/repo_list.go
@@ -81,7 +81,7 @@ func (repos RepositoryList) loadAttributes(ctx context.Context) error {
Where("id > 0").
In("id", set.Values()).
Find(&users); err != nil {
- return fmt.Errorf("find users: %v", err)
+ return fmt.Errorf("find users: %w", err)
}
for i := range repos {
repos[i].Owner = users[repos[i].OwnerID]
@@ -93,7 +93,7 @@ func (repos RepositoryList) loadAttributes(ctx context.Context) error {
Where("`is_primary` = ? AND `language` != ?", true, "other").
In("`repo_id`", repoIDs).
Find(&stats); err != nil {
- return fmt.Errorf("find primary languages: %v", err)
+ return fmt.Errorf("find primary languages: %w", err)
}
stats.LoadAttributes()
for i := range repos {
@@ -537,7 +537,7 @@ func SearchRepositoryByCondition(opts *SearchRepoOptions, cond builder.Cond, loa
}
repos := make(RepositoryList, 0, defaultSize)
if err := sess.Find(&repos); err != nil {
- return nil, 0, fmt.Errorf("Repo: %v", err)
+ return nil, 0, fmt.Errorf("Repo: %w", err)
}
if opts.PageSize <= 0 {
@@ -546,7 +546,7 @@ func SearchRepositoryByCondition(opts *SearchRepoOptions, cond builder.Cond, loa
if loadAttributes {
if err := repos.loadAttributes(ctx); err != nil {
- return nil, 0, fmt.Errorf("LoadAttributes: %v", err)
+ return nil, 0, fmt.Errorf("LoadAttributes: %w", err)
}
}
@@ -582,7 +582,7 @@ func searchRepositoryByCondition(ctx context.Context, opts *SearchRepoOptions, c
Where(cond).
Count(new(Repository))
if err != nil {
- return nil, 0, fmt.Errorf("Count: %v", err)
+ return nil, 0, fmt.Errorf("Count: %w", err)
}
}
@@ -725,7 +725,7 @@ func GetUserRepositories(opts *SearchRepoOptions) (RepositoryList, int64, error)
count, err := sess.Where(cond).Count(new(Repository))
if err != nil {
- return nil, 0, fmt.Errorf("Count: %v", err)
+ return nil, 0, fmt.Errorf("Count: %w", err)
}
sess = sess.Where(cond).OrderBy(opts.OrderBy.String())
diff --git a/models/repo/update.go b/models/repo/update.go
index 64a225d2f5..cc21deb0bc 100644
--- a/models/repo/update.go
+++ b/models/repo/update.go
@@ -119,7 +119,7 @@ func CheckCreateRepository(doer, u *user_model.User, name string, overwriteOrAdo
has, err := IsRepositoryExist(db.DefaultContext, u, name)
if err != nil {
- return fmt.Errorf("IsRepositoryExist: %v", err)
+ return fmt.Errorf("IsRepositoryExist: %w", err)
} else if has {
return ErrRepoAlreadyExist{u.Name, name}
}
@@ -150,14 +150,14 @@ func ChangeRepositoryName(doer *user_model.User, repo *Repository, newRepoName s
has, err := IsRepositoryExist(db.DefaultContext, repo.Owner, newRepoName)
if err != nil {
- return fmt.Errorf("IsRepositoryExist: %v", err)
+ return fmt.Errorf("IsRepositoryExist: %w", err)
} else if has {
return ErrRepoAlreadyExist{repo.Owner.Name, newRepoName}
}
newRepoPath := RepoPath(repo.Owner.Name, newRepoName)
if err = util.Rename(repo.RepoPath(), newRepoPath); err != nil {
- return fmt.Errorf("rename repository directory: %v", err)
+ return fmt.Errorf("rename repository directory: %w", err)
}
wikiPath := repo.WikiPath()
@@ -168,7 +168,7 @@ func ChangeRepositoryName(doer *user_model.User, repo *Repository, newRepoName s
}
if isExist {
if err = util.Rename(wikiPath, WikiPath(repo.Owner.Name, newRepoName)); err != nil {
- return fmt.Errorf("rename repository wiki: %v", err)
+ return fmt.Errorf("rename repository wiki: %w", err)
}
}
diff --git a/models/repo/upload.go b/models/repo/upload.go
index e3ce7e458f..e115c8e50e 100644
--- a/models/repo/upload.go
+++ b/models/repo/upload.go
@@ -70,19 +70,19 @@ func NewUpload(name string, buf []byte, file multipart.File) (_ *Upload, err err
localPath := upload.LocalPath()
if err = os.MkdirAll(path.Dir(localPath), os.ModePerm); err != nil {
- return nil, fmt.Errorf("MkdirAll: %v", err)
+ return nil, fmt.Errorf("MkdirAll: %w", err)
}
fw, err := os.Create(localPath)
if err != nil {
- return nil, fmt.Errorf("Create: %v", err)
+ return nil, fmt.Errorf("Create: %w", err)
}
defer fw.Close()
if _, err = fw.Write(buf); err != nil {
- return nil, fmt.Errorf("Write: %v", err)
+ return nil, fmt.Errorf("Write: %w", err)
} else if _, err = io.Copy(fw, file); err != nil {
- return nil, fmt.Errorf("Copy: %v", err)
+ return nil, fmt.Errorf("Copy: %w", err)
}
if _, err := db.GetEngine(db.DefaultContext).Insert(upload); err != nil {
@@ -134,7 +134,7 @@ func DeleteUploads(uploads ...*Upload) (err error) {
if _, err = db.GetEngine(ctx).
In("id", ids).
Delete(new(Upload)); err != nil {
- return fmt.Errorf("delete uploads: %v", err)
+ return fmt.Errorf("delete uploads: %w", err)
}
if err = committer.Commit(); err != nil {
@@ -152,7 +152,7 @@ func DeleteUploads(uploads ...*Upload) (err error) {
}
if err := util.Remove(localPath); err != nil {
- return fmt.Errorf("remove upload: %v", err)
+ return fmt.Errorf("remove upload: %w", err)
}
}
@@ -166,11 +166,11 @@ func DeleteUploadByUUID(uuid string) error {
if IsErrUploadNotExist(err) {
return nil
}
- return fmt.Errorf("GetUploadByUUID: %v", err)
+ return fmt.Errorf("GetUploadByUUID: %w", err)
}
if err := DeleteUploads(upload); err != nil {
- return fmt.Errorf("DeleteUpload: %v", err)
+ return fmt.Errorf("DeleteUpload: %w", err)
}
return nil