diff options
Diffstat (limited to 'modules')
-rw-r--r-- | modules/context/repo.go | 10 | ||||
-rw-r--r-- | modules/convert/convert.go | 2 | ||||
-rw-r--r-- | modules/notification/ui/ui.go | 3 | ||||
-rw-r--r-- | modules/repofiles/commit_status.go | 43 | ||||
-rw-r--r-- | modules/repository/create.go | 4 | ||||
-rw-r--r-- | modules/repository/generate.go | 2 | ||||
-rw-r--r-- | modules/repository/init.go | 2 |
7 files changed, 12 insertions, 54 deletions
diff --git a/modules/context/repo.go b/modules/context/repo.go index 1725cb724d..b54401f348 100644 --- a/modules/context/repo.go +++ b/modules/context/repo.go @@ -443,10 +443,10 @@ func RepoAssignment(ctx *Context) (cancel context.CancelFunc) { repo, err := repo_model.GetRepositoryByName(owner.ID, repoName) if err != nil { if repo_model.IsErrRepoNotExist(err) { - redirectRepoID, err := models.LookupRepoRedirect(owner.ID, repoName) + redirectRepoID, err := repo_model.LookupRedirect(owner.ID, repoName) if err == nil { RedirectToRepo(ctx, redirectRepoID) - } else if models.IsErrRepoRedirectNotExist(err) { + } else if repo_model.IsErrRedirectNotExist(err) { if ctx.FormString("go-get") == "1" { EarlyResponseForGoGetMeta(ctx) return @@ -512,8 +512,8 @@ func RepoAssignment(ctx *Context) (cancel context.CancelFunc) { ctx.Data["WikiCloneLink"] = repo.WikiCloneLink() if ctx.IsSigned { - ctx.Data["IsWatchingRepo"] = models.IsWatching(ctx.User.ID, repo.ID) - ctx.Data["IsStaringRepo"] = models.IsStaring(ctx.User.ID, repo.ID) + ctx.Data["IsWatchingRepo"] = repo_model.IsWatching(ctx.User.ID, repo.ID) + ctx.Data["IsStaringRepo"] = repo_model.IsStaring(ctx.User.ID, repo.ID) } if repo.IsFork { @@ -613,7 +613,7 @@ func RepoAssignment(ctx *Context) (cancel context.CancelFunc) { // People who have push access or have forked repository can propose a new pull request. canPush := ctx.Repo.CanWrite(unit_model.TypeCode) || - (ctx.IsSigned && models.HasForkedRepo(ctx.User.ID, ctx.Repo.Repository.ID)) + (ctx.IsSigned && repo_model.HasForkedRepo(ctx.User.ID, ctx.Repo.Repository.ID)) canCompare := false // Pull request is allowed if this is a fork repository diff --git a/modules/convert/convert.go b/modules/convert/convert.go index 1c78c35cda..86e1c69d36 100644 --- a/modules/convert/convert.go +++ b/modules/convert/convert.go @@ -334,7 +334,7 @@ func ToAnnotatedTagObject(repo *repo_model.Repository, commit *git.Commit) *api. } // ToTopicResponse convert from models.Topic to api.TopicResponse -func ToTopicResponse(topic *models.Topic) *api.TopicResponse { +func ToTopicResponse(topic *repo_model.Topic) *api.TopicResponse { return &api.TopicResponse{ ID: topic.ID, Name: topic.Name, diff --git a/modules/notification/ui/ui.go b/modules/notification/ui/ui.go index 25f015d0e5..fd44cd15fd 100644 --- a/modules/notification/ui/ui.go +++ b/modules/notification/ui/ui.go @@ -6,6 +6,7 @@ package ui import ( "code.gitea.io/gitea/models" + "code.gitea.io/gitea/models/db" repo_model "code.gitea.io/gitea/models/repo" user_model "code.gitea.io/gitea/models/user" "code.gitea.io/gitea/modules/graceful" @@ -122,7 +123,7 @@ func (ns *notificationService) NotifyNewPullRequest(pr *models.PullRequest, ment return } toNotify := make(map[int64]struct{}, 32) - repoWatchers, err := models.GetRepoWatchersIDs(pr.Issue.RepoID) + repoWatchers, err := repo_model.GetRepoWatchersIDs(db.DefaultContext, pr.Issue.RepoID) if err != nil { log.Error("GetRepoWatchersIDs: %v", err) return diff --git a/modules/repofiles/commit_status.go b/modules/repofiles/commit_status.go deleted file mode 100644 index 21aaa9ee59..0000000000 --- a/modules/repofiles/commit_status.go +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright 2019 The Gitea Authors. All rights reserved. -// Use of this source code is governed by a MIT-style -// license that can be found in the LICENSE file. - -package repofiles - -import ( - "fmt" - - "code.gitea.io/gitea/models" - repo_model "code.gitea.io/gitea/models/repo" - user_model "code.gitea.io/gitea/models/user" - "code.gitea.io/gitea/modules/git" -) - -// CreateCommitStatus creates a new CommitStatus given a bunch of parameters -// NOTE: All text-values will be trimmed from whitespaces. -// Requires: Repo, Creator, SHA -func CreateCommitStatus(repo *repo_model.Repository, creator *user_model.User, sha string, status *models.CommitStatus) error { - repoPath := repo.RepoPath() - - // confirm that commit is exist - gitRepo, err := git.OpenRepository(repoPath) - if err != nil { - return fmt.Errorf("OpenRepository[%s]: %v", repoPath, err) - } - if _, err := gitRepo.GetCommit(sha); err != nil { - gitRepo.Close() - return fmt.Errorf("GetCommit[%s]: %v", sha, err) - } - gitRepo.Close() - - if err := models.NewCommitStatus(models.NewCommitStatusOptions{ - Repo: repo, - Creator: creator, - SHA: sha, - CommitStatus: status, - }); err != nil { - return fmt.Errorf("NewCommitStatus[repo_id: %d, user_id: %d, sha: %s]: %v", repo.ID, creator.ID, sha, err) - } - - return nil -} diff --git a/modules/repository/create.go b/modules/repository/create.go index ddc001d600..8b98a37173 100644 --- a/modules/repository/create.go +++ b/modules/repository/create.go @@ -22,7 +22,7 @@ import ( // CreateRepository creates a repository for the user/organization. func CreateRepository(doer, u *user_model.User, opts models.CreateRepoOptions) (*repo_model.Repository, error) { if !doer.IsAdmin && !u.CanCreateRepo() { - return nil, models.ErrReachLimitOfRepo{ + return nil, repo_model.ErrReachLimitOfRepo{ Limit: u.MaxRepoCreation, } } @@ -83,7 +83,7 @@ func CreateRepository(doer, u *user_model.User, opts models.CreateRepoOptions) ( // Previously Gitea would just delete and start afresh - this was naughty. // So we will now fail and delegate to other functionality to adopt or delete log.Error("Files already exist in %s and we are not going to adopt or delete.", repoPath) - return models.ErrRepoFilesAlreadyExist{ + return repo_model.ErrRepoFilesAlreadyExist{ Uname: u.Name, Name: repo.Name, } diff --git a/modules/repository/generate.go b/modules/repository/generate.go index 756cfe227e..3f83f51bb7 100644 --- a/modules/repository/generate.go +++ b/modules/repository/generate.go @@ -267,7 +267,7 @@ func GenerateRepository(ctx context.Context, doer, owner *user_model.User, templ return nil, err } if isExist { - return nil, models.ErrRepoFilesAlreadyExist{ + return nil, repo_model.ErrRepoFilesAlreadyExist{ Uname: generateRepo.OwnerName, Name: generateRepo.Name, } diff --git a/modules/repository/init.go b/modules/repository/init.go index 08c5aac1b8..cc59b8f29f 100644 --- a/modules/repository/init.go +++ b/modules/repository/init.go @@ -184,7 +184,7 @@ func checkInitRepository(owner, name string) (err error) { return err } if isExist { - return models.ErrRepoFilesAlreadyExist{ + return repo_model.ErrRepoFilesAlreadyExist{ Uname: owner, Name: name, } |