summaryrefslogtreecommitdiffstats
path: root/services/repository
diff options
context:
space:
mode:
Diffstat (limited to 'services/repository')
-rw-r--r--services/repository/adopt.go21
-rw-r--r--services/repository/branch.go21
-rw-r--r--services/repository/cache.go4
-rw-r--r--services/repository/check.go19
-rw-r--r--services/repository/files/commit.go5
-rw-r--r--services/repository/files/content.go7
-rw-r--r--services/repository/files/delete.go3
-rw-r--r--services/repository/files/diff.go4
-rw-r--r--services/repository/files/diff_test.go4
-rw-r--r--services/repository/files/file.go6
-rw-r--r--services/repository/files/temp_repo.go11
-rw-r--r--services/repository/files/tree.go3
-rw-r--r--services/repository/files/update.go15
-rw-r--r--services/repository/files/upload.go7
-rw-r--r--services/repository/fork.go22
-rw-r--r--services/repository/fork_test.go3
-rw-r--r--services/repository/generate.go5
-rw-r--r--services/repository/hooks.go6
-rw-r--r--services/repository/push.go11
-rw-r--r--services/repository/repository.go7
-rw-r--r--services/repository/transfer.go18
-rw-r--r--services/repository/transfer_test.go15
22 files changed, 117 insertions, 100 deletions
diff --git a/services/repository/adopt.go b/services/repository/adopt.go
index 5503155ab0..d5b851d108 100644
--- a/services/repository/adopt.go
+++ b/services/repository/adopt.go
@@ -13,6 +13,7 @@ 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/git"
"code.gitea.io/gitea/modules/log"
@@ -25,7 +26,7 @@ import (
)
// AdoptRepository adopts pre-existing repository files for the user/organization.
-func AdoptRepository(doer, u *user_model.User, opts models.CreateRepoOptions) (*models.Repository, error) {
+func AdoptRepository(doer, u *user_model.User, opts models.CreateRepoOptions) (*repo_model.Repository, error) {
if !doer.IsAdmin && !u.CanCreateRepo() {
return nil, models.ErrReachLimitOfRepo{
Limit: u.MaxRepoCreation,
@@ -36,7 +37,7 @@ func AdoptRepository(doer, u *user_model.User, opts models.CreateRepoOptions) (*
opts.DefaultBranch = setting.Repository.DefaultBranch
}
- repo := &models.Repository{
+ repo := &repo_model.Repository{
OwnerID: u.ID,
Owner: u,
OwnerName: u.Name,
@@ -53,14 +54,14 @@ func AdoptRepository(doer, u *user_model.User, opts models.CreateRepoOptions) (*
}
if err := db.WithTx(func(ctx context.Context) error {
- repoPath := models.RepoPath(u.Name, repo.Name)
+ repoPath := repo_model.RepoPath(u.Name, repo.Name)
isExist, err := util.IsExist(repoPath)
if err != nil {
log.Error("Unable to check if %s exists. Error: %v", repoPath, err)
return err
}
if !isExist {
- return models.ErrRepoNotExist{
+ return repo_model.ErrRepoNotExist{
OwnerName: u.Name,
Name: repo.Name,
}
@@ -72,7 +73,7 @@ func AdoptRepository(doer, u *user_model.User, opts models.CreateRepoOptions) (*
if err := adoptRepository(ctx, repoPath, doer, repo, opts); err != nil {
return fmt.Errorf("createDelegateHooks: %v", err)
}
- if err := repo.CheckDaemonExportOK(ctx); err != nil {
+ if err := models.CheckDaemonExportOK(ctx, repo); err != nil {
return fmt.Errorf("checkDaemonExportOK: %v", err)
}
@@ -99,7 +100,7 @@ func AdoptRepository(doer, u *user_model.User, opts models.CreateRepoOptions) (*
return repo, nil
}
-func adoptRepository(ctx context.Context, repoPath string, u *user_model.User, repo *models.Repository, opts models.CreateRepoOptions) (err error) {
+func adoptRepository(ctx context.Context, repoPath string, u *user_model.User, repo *repo_model.Repository, opts models.CreateRepoOptions) (err error) {
isExist, err := util.IsExist(repoPath)
if err != nil {
log.Error("Unable to check if %s exists. Error: %v", repoPath, err)
@@ -115,7 +116,7 @@ func adoptRepository(ctx context.Context, repoPath string, u *user_model.User, r
// Re-fetch the repository from database before updating it (else it would
// override changes that were done earlier with sql)
- if repo, err = models.GetRepositoryByIDCtx(ctx, repo.ID); err != nil {
+ if repo, err = repo_model.GetRepositoryByIDCtx(ctx, repo.ID); err != nil {
return fmt.Errorf("getRepositoryByID: %v", err)
}
@@ -191,20 +192,20 @@ func DeleteUnadoptedRepository(doer, u *user_model.User, repoName string) error
return err
}
- repoPath := models.RepoPath(u.Name, repoName)
+ repoPath := repo_model.RepoPath(u.Name, repoName)
isExist, err := util.IsExist(repoPath)
if err != nil {
log.Error("Unable to check if %s exists. Error: %v", repoPath, err)
return err
}
if !isExist {
- return models.ErrRepoNotExist{
+ return repo_model.ErrRepoNotExist{
OwnerName: u.Name,
Name: repoName,
}
}
- if exist, err := models.IsRepositoryExist(u, repoName); err != nil {
+ if exist, err := repo_model.IsRepositoryExist(u, repoName); err != nil {
return err
} else if exist {
return models.ErrRepoAlreadyExist{
diff --git a/services/repository/branch.go b/services/repository/branch.go
index 08310134bd..e1775fc12b 100644
--- a/services/repository/branch.go
+++ b/services/repository/branch.go
@@ -11,6 +11,7 @@ import (
"strings"
"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"
"code.gitea.io/gitea/modules/log"
@@ -20,7 +21,7 @@ import (
)
// CreateNewBranch creates a new repository branch
-func CreateNewBranch(doer *user_model.User, repo *models.Repository, oldBranchName, branchName string) (err error) {
+func CreateNewBranch(doer *user_model.User, repo *repo_model.Repository, oldBranchName, branchName string) (err error) {
// Check if branch name can be used
if err := checkBranchName(git.DefaultContext, repo, branchName); err != nil {
return err
@@ -47,7 +48,7 @@ func CreateNewBranch(doer *user_model.User, repo *models.Repository, oldBranchNa
}
// GetBranch returns a branch by its name
-func GetBranch(repo *models.Repository, branch string) (*git.Branch, error) {
+func GetBranch(repo *repo_model.Repository, branch string) (*git.Branch, error) {
if len(branch) == 0 {
return nil, fmt.Errorf("GetBranch: empty string for branch")
}
@@ -62,12 +63,12 @@ func GetBranch(repo *models.Repository, branch string) (*git.Branch, error) {
// GetBranches returns branches from the repository, skipping skip initial branches and
// returning at most limit branches, or all branches if limit is 0.
-func GetBranches(repo *models.Repository, skip, limit int) ([]*git.Branch, int, error) {
+func GetBranches(repo *repo_model.Repository, skip, limit int) ([]*git.Branch, int, error) {
return git.GetBranchesByPath(repo.RepoPath(), skip, limit)
}
// checkBranchName validates branch name with existing repository branches
-func checkBranchName(ctx context.Context, repo *models.Repository, name string) error {
+func checkBranchName(ctx context.Context, repo *repo_model.Repository, name string) error {
_, err := git.WalkReferences(ctx, repo.RepoPath(), func(refName string) error {
branchRefName := strings.TrimPrefix(refName, git.BranchPrefix)
switch {
@@ -97,7 +98,7 @@ func checkBranchName(ctx context.Context, repo *models.Repository, name string)
}
// CreateNewBranchFromCommit creates a new repository branch
-func CreateNewBranchFromCommit(doer *user_model.User, repo *models.Repository, commit, branchName string) (err error) {
+func CreateNewBranchFromCommit(doer *user_model.User, repo *repo_model.Repository, commit, branchName string) (err error) {
// Check if branch name can be used
if err := checkBranchName(git.DefaultContext, repo, branchName); err != nil {
return err
@@ -118,7 +119,7 @@ func CreateNewBranchFromCommit(doer *user_model.User, repo *models.Repository, c
}
// RenameBranch rename a branch
-func RenameBranch(repo *models.Repository, doer *user_model.User, gitRepo *git.Repository, from, to string) (string, error) {
+func RenameBranch(repo *repo_model.Repository, doer *user_model.User, gitRepo *git.Repository, from, to string) (string, error) {
if from == to {
return "target_exist", nil
}
@@ -131,7 +132,7 @@ func RenameBranch(repo *models.Repository, doer *user_model.User, gitRepo *git.R
return "from_not_exist", nil
}
- if err := repo.RenameBranch(from, to, func(isDefault bool) error {
+ if err := models.RenameBranch(repo, from, to, func(isDefault bool) error {
err2 := gitRepo.RenameBranch(from, to)
if err2 != nil {
return err2
@@ -162,12 +163,12 @@ var (
)
// DeleteBranch delete branch
-func DeleteBranch(doer *user_model.User, repo *models.Repository, gitRepo *git.Repository, branchName string) error {
+func DeleteBranch(doer *user_model.User, repo *repo_model.Repository, gitRepo *git.Repository, branchName string) error {
if branchName == repo.DefaultBranch {
return ErrBranchIsDefault
}
- isProtected, err := repo.IsProtectedBranch(branchName)
+ isProtected, err := models.IsProtectedBranch(repo.ID, branchName)
if err != nil {
return err
}
@@ -205,7 +206,7 @@ func DeleteBranch(doer *user_model.User, repo *models.Repository, gitRepo *git.R
log.Error("Update: %v", err)
}
- if err := repo.AddDeletedBranch(branchName, commit.ID.String(), doer.ID); err != nil {
+ if err := models.AddDeletedBranch(repo.ID, branchName, commit.ID.String(), doer.ID); err != nil {
log.Warn("AddDeletedBranch: %v", err)
}
diff --git a/services/repository/cache.go b/services/repository/cache.go
index e574f1adb7..5b0c929be1 100644
--- a/services/repository/cache.go
+++ b/services/repository/cache.go
@@ -8,7 +8,7 @@ import (
"context"
"strings"
- "code.gitea.io/gitea/models"
+ repo_model "code.gitea.io/gitea/models/repo"
"code.gitea.io/gitea/modules/cache"
"code.gitea.io/gitea/modules/git"
"code.gitea.io/gitea/modules/setting"
@@ -24,7 +24,7 @@ func getRefName(fullRefName string) string {
}
// CacheRef cachhe last commit information of the branch or the tag
-func CacheRef(ctx context.Context, repo *models.Repository, gitRepo *git.Repository, fullRefName string) error {
+func CacheRef(ctx context.Context, repo *repo_model.Repository, gitRepo *git.Repository, fullRefName string) error {
if !setting.CacheService.LastCommit.Enabled {
return nil
}
diff --git a/services/repository/check.go b/services/repository/check.go
index ab7539e555..7118b006bd 100644
--- a/services/repository/check.go
+++ b/services/repository/check.go
@@ -13,6 +13,7 @@ import (
"code.gitea.io/gitea/models"
admin_model "code.gitea.io/gitea/models/admin"
"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/git"
"code.gitea.io/gitea/modules/log"
@@ -27,10 +28,10 @@ func GitFsck(ctx context.Context, timeout time.Duration, args []string) error {
if err := db.Iterate(
db.DefaultContext,
- new(models.Repository),
+ new(repo_model.Repository),
builder.Expr("id>0 AND is_fsck_enabled=?", true),
func(idx int, bean interface{}) error {
- repo := bean.(*models.Repository)
+ repo := bean.(*repo_model.Repository)
select {
case <-ctx.Done():
return db.ErrCancelledf("before fsck of %s", repo.FullName())
@@ -62,10 +63,10 @@ func GitGcRepos(ctx context.Context, timeout time.Duration, args ...string) erro
if err := db.Iterate(
db.DefaultContext,
- new(models.Repository),
+ new(repo_model.Repository),
builder.Gt{"id": 0},
func(idx int, bean interface{}) error {
- repo := bean.(*models.Repository)
+ repo := bean.(*repo_model.Repository)
select {
case <-ctx.Done():
return db.ErrCancelledf("before GC of %s", repo.FullName())
@@ -96,7 +97,7 @@ func GitGcRepos(ctx context.Context, timeout time.Duration, args ...string) erro
}
// Now update the size of the repository
- if err := repo.UpdateSize(db.DefaultContext); err != nil {
+ if err := models.UpdateRepoSize(db.DefaultContext, repo); err != nil {
log.Error("Updating size as part of garbage collection failed for %v. Stdout: %s\nError: %v", repo, stdout, err)
desc := fmt.Sprintf("Updating size as part of garbage collection failed for %s. Stdout: %s\nError: %v", repo.RepoPath(), stdout, err)
if err = admin_model.CreateRepositoryNotice(desc); err != nil {
@@ -115,14 +116,14 @@ func GitGcRepos(ctx context.Context, timeout time.Duration, args ...string) erro
return nil
}
-func gatherMissingRepoRecords(ctx context.Context) ([]*models.Repository, error) {
- repos := make([]*models.Repository, 0, 10)
+func gatherMissingRepoRecords(ctx context.Context) ([]*repo_model.Repository, error) {
+ repos := make([]*repo_model.Repository, 0, 10)
if err := db.Iterate(
db.DefaultContext,
- new(models.Repository),
+ new(repo_model.Repository),
builder.Gt{"id": 0},
func(idx int, bean interface{}) error {
- repo := bean.(*models.Repository)
+ repo := bean.(*repo_model.Repository)
select {
case <-ctx.Done():
return db.ErrCancelledf("during gathering missing repo records before checking %s", repo.FullName())
diff --git a/services/repository/files/commit.go b/services/repository/files/commit.go
index 8f14ed8926..6bff1bb97f 100644
--- a/services/repository/files/commit.go
+++ b/services/repository/files/commit.go
@@ -8,6 +8,7 @@ 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"
"code.gitea.io/gitea/modules/structs"
@@ -16,7 +17,7 @@ import (
// 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 *models.Repository, creator *user_model.User, sha string, status *models.CommitStatus) error {
+func CreateCommitStatus(repo *repo_model.Repository, creator *user_model.User, sha string, status *models.CommitStatus) error {
repoPath := repo.RepoPath()
// confirm that commit is exist
@@ -43,7 +44,7 @@ func CreateCommitStatus(repo *models.Repository, creator *user_model.User, sha s
}
// CountDivergingCommits determines how many commits a branch is ahead or behind the repository's base branch
-func CountDivergingCommits(repo *models.Repository, branch string) (*git.DivergeObject, error) {
+func CountDivergingCommits(repo *repo_model.Repository, branch string) (*git.DivergeObject, error) {
divergence, err := git.GetDivergingCommits(repo.RepoPath(), repo.DefaultBranch, branch)
if err != nil {
return nil, err
diff --git a/services/repository/files/content.go b/services/repository/files/content.go
index afb775fed3..10461c82a7 100644
--- a/services/repository/files/content.go
+++ b/services/repository/files/content.go
@@ -11,6 +11,7 @@ import (
"strings"
"code.gitea.io/gitea/models"
+ repo_model "code.gitea.io/gitea/models/repo"
"code.gitea.io/gitea/modules/git"
"code.gitea.io/gitea/modules/setting"
api "code.gitea.io/gitea/modules/structs"
@@ -38,7 +39,7 @@ func (ct *ContentType) String() string {
// GetContentsOrList gets the meta data of a file's contents (*ContentsResponse) if treePath not a tree
// directory, otherwise a listing of file contents ([]*ContentsResponse). Ref can be a branch, commit or tag
-func GetContentsOrList(repo *models.Repository, treePath, ref string) (interface{}, error) {
+func GetContentsOrList(repo *repo_model.Repository, treePath, ref string) (interface{}, error) {
if repo.IsEmpty {
return make([]interface{}, 0), nil
}
@@ -100,7 +101,7 @@ func GetContentsOrList(repo *models.Repository, treePath, ref string) (interface
}
// GetContents gets the meta data on a file's contents. Ref can be a branch, commit or tag
-func GetContents(repo *models.Repository, treePath, ref string, forList bool) (*api.ContentsResponse, error) {
+func GetContents(repo *repo_model.Repository, treePath, ref string, forList bool) (*api.ContentsResponse, error) {
if ref == "" {
ref = repo.DefaultBranch
}
@@ -218,7 +219,7 @@ func GetContents(repo *models.Repository, treePath, ref string, forList bool) (*
}
// GetBlobBySHA get the GitBlobResponse of a repository using a sha hash.
-func GetBlobBySHA(repo *models.Repository, sha string) (*api.GitBlobResponse, error) {
+func GetBlobBySHA(repo *repo_model.Repository, sha string) (*api.GitBlobResponse, error) {
gitRepo, err := git.OpenRepository(repo.RepoPath())
if err != nil {
return nil, err
diff --git a/services/repository/files/delete.go b/services/repository/files/delete.go
index f7b342db3f..15208addda 100644
--- a/services/repository/files/delete.go
+++ b/services/repository/files/delete.go
@@ -9,6 +9,7 @@ import (
"strings"
"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"
api "code.gitea.io/gitea/modules/structs"
@@ -30,7 +31,7 @@ type DeleteRepoFileOptions struct {
}
// DeleteRepoFile deletes a file in the given repository
-func DeleteRepoFile(repo *models.Repository, doer *user_model.User, opts *DeleteRepoFileOptions) (*api.FileResponse, error) {
+func DeleteRepoFile(repo *repo_model.Repository, doer *user_model.User, opts *DeleteRepoFileOptions) (*api.FileResponse, error) {
// If no branch name is set, assume the repo's default branch
if opts.OldBranch == "" {
opts.OldBranch = repo.DefaultBranch
diff --git a/services/repository/files/diff.go b/services/repository/files/diff.go
index fadaf20231..fb41237e13 100644
--- a/services/repository/files/diff.go
+++ b/services/repository/files/diff.go
@@ -7,12 +7,12 @@ package files
import (
"strings"
- "code.gitea.io/gitea/models"
+ repo_model "code.gitea.io/gitea/models/repo"
"code.gitea.io/gitea/services/gitdiff"
)
// GetDiffPreview produces and returns diff result of a file which is not yet committed.
-func GetDiffPreview(repo *models.Repository, branch, treePath, content string) (*gitdiff.Diff, error) {
+func GetDiffPreview(repo *repo_model.Repository, branch, treePath, content string) (*gitdiff.Diff, error) {
if branch == "" {
branch = repo.DefaultBranch
}
diff --git a/services/repository/files/diff_test.go b/services/repository/files/diff_test.go
index be8e92033d..2f256e888c 100644
--- a/services/repository/files/diff_test.go
+++ b/services/repository/files/diff_test.go
@@ -7,7 +7,7 @@ package files
import (
"testing"
- "code.gitea.io/gitea/models"
+ repo_model "code.gitea.io/gitea/models/repo"
"code.gitea.io/gitea/models/unittest"
"code.gitea.io/gitea/modules/json"
"code.gitea.io/gitea/modules/test"
@@ -152,7 +152,7 @@ func TestGetDiffPreviewErrors(t *testing.T) {
content := "# repo1\n\nDescription for repo1\nthis is a new line"
t.Run("empty repo", func(t *testing.T) {
- diff, err := GetDiffPreview(&models.Repository{}, branch, treePath, content)
+ diff, err := GetDiffPreview(&repo_model.Repository{}, branch, treePath, content)
assert.Nil(t, diff)
assert.EqualError(t, err, "repository does not exist [id: 0, uid: 0, owner_name: , name: ]")
})
diff --git a/services/repository/files/file.go b/services/repository/files/file.go
index 8de60c4cb8..7886119587 100644
--- a/services/repository/files/file.go
+++ b/services/repository/files/file.go
@@ -11,14 +11,14 @@ import (
"strings"
"time"
- "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"
api "code.gitea.io/gitea/modules/structs"
)
// GetFileResponseFromCommit Constructs a FileResponse from a Commit object
-func GetFileResponseFromCommit(repo *models.Repository, commit *git.Commit, branch, treeName string) (*api.FileResponse, error) {
+func GetFileResponseFromCommit(repo *repo_model.Repository, commit *git.Commit, branch, treeName string) (*api.FileResponse, error) {
fileContents, _ := GetContents(repo, treeName, branch, false) // ok if fails, then will be nil
fileCommitResponse, _ := GetFileCommitResponse(repo, commit) // ok if fails, then will be nil
verification := GetPayloadCommitVerification(commit)
@@ -31,7 +31,7 @@ func GetFileResponseFromCommit(repo *models.Repository, commit *git.Commit, bran
}
// GetFileCommitResponse Constructs a FileCommitResponse from a Commit object
-func GetFileCommitResponse(repo *models.Repository, commit *git.Commit) (*api.FileCommitResponse, error) {
+func GetFileCommitResponse(repo *repo_model.Repository, commit *git.Commit) (*api.FileCommitResponse, error) {
if repo == nil {
return nil, fmt.Errorf("repo cannot be nil")
}
diff --git a/services/repository/files/temp_repo.go b/services/repository/files/temp_repo.go
index 55dcd7436c..815aa2c69f 100644
--- a/services/repository/files/temp_repo.go
+++ b/services/repository/files/temp_repo.go
@@ -15,6 +15,7 @@ import (
"time"
"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"
"code.gitea.io/gitea/modules/log"
@@ -24,13 +25,13 @@ import (
// TemporaryUploadRepository is a type to wrap our upload repositories as a shallow clone
type TemporaryUploadRepository struct {
- repo *models.Repository
+ repo *repo_model.Repository
gitRepo *git.Repository
basePath string
}
// NewTemporaryUploadRepository creates a new temporary upload repository
-func NewTemporaryUploadRepository(repo *models.Repository) (*TemporaryUploadRepository, error) {
+func NewTemporaryUploadRepository(repo *repo_model.Repository) (*TemporaryUploadRepository, error) {
basePath, err := models.CreateTemporaryPath("upload")
if err != nil {
return nil, err
@@ -56,7 +57,7 @@ func (t *TemporaryUploadRepository) Clone(branch string) error {
Name: branch,
}
} else if matched, _ := regexp.MatchString(".* repository .* does not exist.*", stderr); matched {
- return models.ErrRepoNotExist{
+ return repo_model.ErrRepoNotExist{
ID: t.repo.ID,
UID: t.repo.OwnerID,
OwnerName: t.repo.OwnerName,
@@ -216,10 +217,10 @@ func (t *TemporaryUploadRepository) CommitTreeWithDate(author, committer *user_m
// Determine if we should sign
if git.CheckGitVersionAtLeast("1.7.9") == nil {
- sign, keyID, signer, _ := t.repo.SignCRUDAction(author, t.basePath, "HEAD")
+ sign, keyID, signer, _ := models.SignCRUDAction(t.repo, author, t.basePath, "HEAD")
if sign {
args = append(args, "-S"+keyID)
- if t.repo.GetTrustModel() == models.CommitterTrustModel || t.repo.GetTrustModel() == models.CollaboratorCommitterTrustModel {
+ if t.repo.GetTrustModel() == repo_model.CommitterTrustModel || t.repo.GetTrustModel() == repo_model.CollaboratorCommitterTrustModel {
if committerSig.Name != authorSig.Name || committerSig.Email != authorSig.Email {
// Add trailers
_, _ = messageBytes.WriteString("\n")
diff --git a/services/repository/files/tree.go b/services/repository/files/tree.go
index ede206274e..c6b77355ed 100644
--- a/services/repository/files/tree.go
+++ b/services/repository/files/tree.go
@@ -9,13 +9,14 @@ import (
"net/url"
"code.gitea.io/gitea/models"
+ repo_model "code.gitea.io/gitea/models/repo"
"code.gitea.io/gitea/modules/git"
"code.gitea.io/gitea/modules/setting"
api "code.gitea.io/gitea/modules/structs"
)
// GetTreeBySHA get the GitTreeResponse of a repository using a sha hash.
-func GetTreeBySHA(repo *models.Repository, sha string, page, perPage int, recursive bool) (*api.GitTreeResponse, error) {
+func GetTreeBySHA(repo *repo_model.Repository, sha string, page, perPage int, recursive bool) (*api.GitTreeResponse, error) {
gitRepo, err := git.OpenRepository(repo.RepoPath())
if err != nil {
return nil, err
diff --git a/services/repository/files/update.go b/services/repository/files/update.go
index eeb98f3630..9a069acbfc 100644
--- a/services/repository/files/update.go
+++ b/services/repository/files/update.go
@@ -12,6 +12,7 @@ import (
"time"
"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/charset"
"code.gitea.io/gitea/modules/git"
@@ -55,7 +56,7 @@ type UpdateRepoFileOptions struct {
Signoff bool
}
-func detectEncodingAndBOM(entry *git.TreeEntry, repo *models.Repository) (string, bool) {
+func detectEncodingAndBOM(entry *git.TreeEntry, repo *repo_model.Repository) (string, bool) {
reader, err := entry.Blob().DataAsync()
if err != nil {
// return default
@@ -73,7 +74,7 @@ func detectEncodingAndBOM(entry *git.TreeEntry, repo *models.Repository) (string
if setting.LFS.StartServer {
pointer, _ := lfs.ReadPointerFromBuffer(buf)
if pointer.IsValid() {
- meta, err := repo.GetLFSMetaObjectByOid(pointer.Oid)
+ meta, err := models.GetLFSMetaObjectByOid(repo.ID, pointer.Oid)
if err != nil && err != models.ErrLFSObjectNotExist {
// return default
return "UTF-8", false
@@ -123,7 +124,7 @@ func detectEncodingAndBOM(entry *git.TreeEntry, repo *models.Repository) (string
}
// CreateOrUpdateRepoFile adds or updates a file in the given repository
-func CreateOrUpdateRepoFile(repo *models.Repository, doer *user_model.User, opts *UpdateRepoFileOptions) (*structs.FileResponse, error) {
+func CreateOrUpdateRepoFile(repo *repo_model.Repository, doer *user_model.User, opts *UpdateRepoFileOptions) (*structs.FileResponse, error) {
// If no branch name is set, assume default branch
if opts.OldBranch == "" {
opts.OldBranch = repo.DefaultBranch
@@ -413,7 +414,7 @@ func CreateOrUpdateRepoFile(repo *models.Repository, doer *user_model.User, opts
}
if !exist {
if err := contentStore.Put(lfsMetaObject.Pointer, strings.NewReader(opts.Content)); err != nil {
- if _, err2 := repo.RemoveLFSMetaObjectByOid(lfsMetaObject.Oid); err2 != nil {
+ if _, err2 := models.RemoveLFSMetaObjectByOid(repo.ID, lfsMetaObject.Oid); err2 != nil {
return nil, fmt.Errorf("Error whilst removing failed inserted LFS object %s: %v (Prev Error: %v)", lfsMetaObject.Oid, err2, err)
}
return nil, err
@@ -440,8 +441,8 @@ func CreateOrUpdateRepoFile(repo *models.Repository, doer *user_model.User, opts
}
// VerifyBranchProtection verify the branch protection for modifying the given treePath on the given branch
-func VerifyBranchProtection(repo *models.Repository, doer *user_model.User, branchName string, treePath string) error {
- protectedBranch, err := repo.GetBranchProtection(branchName)
+func VerifyBranchProtection(repo *repo_model.Repository, doer *user_model.User, branchName string, treePath string) error {
+ protectedBranch, err := models.GetProtectedBranchBy(repo.ID, branchName)
if err != nil {
return err
}
@@ -457,7 +458,7 @@ func VerifyBranchProtection(repo *models.Repository, doer *user_model.User, bran
}
}
if protectedBranch.RequireSignedCommits {
- _, _, _, err := repo.SignCRUDAction(doer, repo.RepoPath(), branchName)
+ _, _, _, err := models.SignCRUDAction(repo, doer, repo.RepoPath(), branchName)
if err != nil {
if !models.IsErrWontSign(err) {
return err
diff --git a/services/repository/files/upload.go b/services/repository/files/upload.go
index 7a0ea31085..5e9c936113 100644
--- a/services/repository/files/upload.go
+++ b/services/repository/files/upload.go
@@ -11,6 +11,7 @@ import (
"strings"
"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"
"code.gitea.io/gitea/modules/lfs"
@@ -39,7 +40,7 @@ func cleanUpAfterFailure(infos *[]uploadInfo, t *TemporaryUploadRepository, orig
continue
}
if !info.lfsMetaObject.Existing {
- if _, err := t.repo.RemoveLFSMetaObjectByOid(info.lfsMetaObject.Oid); err != nil {
+ if _, err := models.RemoveLFSMetaObjectByOid(t.repo.ID, info.lfsMetaObject.Oid); err != nil {
original = fmt.Errorf("%v, %v", original, err)
}
}
@@ -48,7 +49,7 @@ func cleanUpAfterFailure(infos *[]uploadInfo, t *TemporaryUploadRepository, orig
}
// UploadRepoFiles uploads files to the given repository
-func UploadRepoFiles(repo *models.Repository, doer *user_model.User, opts *UploadRepoFileOptions) error {
+func UploadRepoFiles(repo *repo_model.Repository, doer *user_model.User, opts *UploadRepoFileOptions) error {
if len(opts.Files) == 0 {
return nil
}
@@ -63,7 +64,7 @@ func UploadRepoFiles(repo *models.Repository, doer *user_model.User, opts *Uploa
for i, upload := range uploads {
// Check file is not lfs locked, will return nil if lock setting not enabled
filepath := path.Join(opts.TreePath, upload.Name)
- lfsLock, err := repo.GetTreePathLock(filepath)
+ lfsLock, err := models.GetTreePathLock(repo.ID, filepath)
if err != nil {
return err
}
diff --git a/services/repository/fork.go b/services/repository/fork.go
index 3fc08b4986..027877cfd5 100644
--- a/services/repository/fork.go
+++ b/services/repository/fork.go
@@ -12,6 +12,7 @@ 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/git"
"code.gitea.io/gitea/modules/log"
@@ -22,8 +23,8 @@ import (
)
// ForkRepository forks a repository
-func ForkRepository(doer, owner *user_model.User, opts models.ForkRepoOptions) (_ *models.Repository, err error) {
- forkedRepo, err := opts.BaseRepo.GetUserFork(owner.ID)
+func ForkRepository(doer, owner *user_model.User, opts models.ForkRepoOptions) (_ *repo_model.Repository, err error) {
+ forkedRepo, err := models.GetUserFork(opts.BaseRepo.ID, owner.ID)
if err != nil {
return nil, err
}
@@ -35,7 +36,7 @@ func ForkRepository(doer, owner *user_model.User, opts models.ForkRepoOptions) (
}
}
- repo := &models.Repository{
+ repo := &repo_model.Repository{
OwnerID: owner.ID,
Owner: owner,
OwnerName: owner.Name,
@@ -57,7 +58,7 @@ func ForkRepository(doer, owner *user_model.User, opts models.ForkRepoOptions) (
return
}
- repoPath := models.RepoPath(owner.Name, repo.Name)
+ repoPath := repo_model.RepoPath(owner.Name, repo.Name)
if exists, _ := util.IsExist(repoPath); !exists {
return
@@ -99,7 +100,7 @@ func ForkRepository(doer, owner *user_model.User, opts models.ForkRepoOptions) (
needsRollback = true
- repoPath := models.RepoPath(owner.Name, repo.Name)
+ repoPath := repo_model.RepoPath(owner.Name, repo.Name)
if stdout, err := git.NewCommandContext(ctx,
"clone", "--bare", oldRepoPath, repoPath).
SetDescription(fmt.Sprintf("ForkRepository(git clone): %s to %s", opts.BaseRepo.FullName(), repo.FullName())).
@@ -108,7 +109,7 @@ func ForkRepository(doer, owner *user_model.User, opts models.ForkRepoOptions) (
return fmt.Errorf("git clone: %v", err)
}
- if err := repo.CheckDaemonExportOK(ctx); err != nil {
+ if err := models.CheckDaemonExportOK(ctx, repo); err != nil {
return fmt.Errorf("checkDaemonExportOK: %v", err)
}
@@ -131,11 +132,10 @@ func ForkRepository(doer, owner *user_model.User, opts models.ForkRepoOptions) (
}
// even if below operations failed, it could be ignored. And they will be retried
- ctx := db.DefaultContext
- if err := repo.UpdateSize(ctx); err != nil {
+ if err := models.UpdateRepoSize(db.DefaultContext, repo); err != nil {
log.Error("Failed to update size for repository: %v", err)
}
- if err := models.CopyLanguageStat(opts.BaseRepo, repo); err != nil {
+ if err := repo_model.CopyLanguageStat(opts.BaseRepo, repo); err != nil {
log.Error("Copy language stat from oldRepo failed")
}
@@ -145,9 +145,9 @@ func ForkRepository(doer, owner *user_model.User, opts models.ForkRepoOptions) (
}
// ConvertForkToNormalRepository convert the provided repo from a forked repo to normal repo
-func ConvertForkToNormalRepository(repo *models.Repository) error {
+func ConvertForkToNormalRepository(repo *repo_model.Repository) error {
err := db.WithTx(func(ctx context.Context) error {
- repo, err := models.GetRepositoryByIDCtx(ctx, repo.ID)
+ repo, err := repo_model.GetRepositoryByIDCtx(ctx, repo.ID)
if err != nil {
return err
}
diff --git a/services/repository/fork_test.go b/services/repository/fork_test.go
index befb606135..859889fc59 100644
--- a/services/repository/fork_test.go
+++ b/services/repository/fork_test.go
@@ -8,6 +8,7 @@ import (
"testing"
"code.gitea.io/gitea/models"
+ repo_model "code.gitea.io/gitea/models/repo"
"code.gitea.io/gitea/models/unittest"
user_model "code.gitea.io/gitea/models/user"
@@ -19,7 +20,7 @@ func TestForkRepository(t *testing.T) {
// user 13 has already forked repo10
user := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 13}).(*user_model.User)
- repo := unittest.AssertExistsAndLoadBean(t, &models.Repository{ID: 10}).(*models.Repository)
+ repo := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 10}).(*repo_model.Repository)
fork, err := ForkRepository(user, user, models.ForkRepoOptions{
BaseRepo: repo,
diff --git a/services/repository/generate.go b/services/repository/generate.go
index 031648666d..2b5a750ad1 100644
--- a/services/repository/generate.go
+++ b/services/repository/generate.go
@@ -9,6 +9,7 @@ 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/log"
"code.gitea.io/gitea/modules/notification"
@@ -16,14 +17,14 @@ import (
)
// GenerateRepository generates a repository from a template
-func GenerateRepository(doer, owner *user_model.User, templateRepo *models.Repository, opts models.GenerateRepoOptions) (_ *models.Repository, err error) {
+func GenerateRepository(doer, owner *user_model.User, templateRepo *repo_model.Repository, opts models.GenerateRepoOptions) (_ *repo_model.Repository, err error) {
if !doer.IsAdmin && !owner.CanCreateRepo() {
return nil, models.ErrReachLimitOfRepo{
Limit: owner.MaxRepoCreation,
}
}
- var generateRepo *models.Repository
+ var generateRepo *repo_model.Repository
if err = db.WithTx(func(ctx context.Context) error {
generateRepo, err = repo_module.GenerateRepository(ctx, doer, owner, templateRepo, opts)
if err != nil {
diff --git a/services/repository/hooks.go b/services/repository/hooks.go
index a50853f6af..714cd6b2eb 100644
--- a/services/repository/hooks.go
+++ b/services/repository/hooks.go
@@ -8,8 +8,8 @@ import (
"context"
"fmt"
- "code.gitea.io/gitea/models"
"code.gitea.io/gitea/models/db"
+ repo_model "code.gitea.io/gitea/models/repo"
"code.gitea.io/gitea/modules/log"
repo_module "code.gitea.io/gitea/modules/repository"
@@ -23,10 +23,10 @@ func SyncRepositoryHooks(ctx context.Context) error {
if err := db.Iterate(
db.DefaultContext,
- new(models.Repository),
+ new(repo_model.Repository),
builder.Gt{"id": 0},
func(idx int, bean interface{}) error {
- repo := bean.(*models.Repository)
+ repo := bean.(*repo_model.Repository)
select {
case <-ctx.Done():
return db.ErrCancelledf("before sync repository hooks for %s", repo.FullName())
diff --git a/services/repository/push.go b/services/repository/push.go
index 7b439a41f4..60d2f0c58d 100644
--- a/services/repository/push.go
+++ b/services/repository/push.go
@@ -13,6 +13,7 @@ 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/cache"
"code.gitea.io/gitea/modules/git"
@@ -76,7 +77,7 @@ func pushUpdates(optsList []*repo_module.PushUpdateOptions) error {
return nil
}
- repo, err := models.GetRepositoryByOwnerAndName(optsList[0].RepoUserName, optsList[0].RepoName)
+ repo, err := repo_model.GetRepositoryByOwnerAndName(optsList[0].RepoUserName, optsList[0].RepoName)
if err != nil {
return fmt.Errorf("GetRepositoryByOwnerAndName failed: %v", err)
}
@@ -88,7 +89,7 @@ func pushUpdates(optsList []*repo_module.PushUpdateOptions) error {
}
defer gitRepo.Close()
- if err = repo.UpdateSize(db.DefaultContext); err != nil {
+ if err = models.UpdateRepoSize(db.DefaultContext, repo); err != nil {
log.Error("Failed to update size for repository: %v", err)
}
@@ -209,7 +210,7 @@ func pushUpdates(optsList []*repo_module.PushUpdateOptions) error {
commits.CompareURL = repo.ComposeCompareURL(opts.OldCommitID, opts.NewCommitID)
notification.NotifyPushCommits(pusher, repo, opts, commits)
- if err = models.RemoveDeletedBranch(repo.ID, branch); err != nil {
+ if err = models.RemoveDeletedBranchByName(repo.ID, branch); err != nil {
log.Error("models.RemoveDeletedBranch %s/%s failed: %v", repo.ID, branch, err)
}
@@ -246,7 +247,7 @@ func pushUpdates(optsList []*repo_module.PushUpdateOptions) error {
}
// PushUpdateAddDeleteTags updates a number of added and delete tags
-func PushUpdateAddDeleteTags(repo *models.Repository, gitRepo *git.Repository, addTags, delTags []string) error {
+func PushUpdateAddDeleteTags(repo *repo_model.Repository, gitRepo *git.Repository, addTags, delTags []string) error {
return db.WithTx(func(ctx context.Context) error {
if err := models.PushUpdateDeleteTagsContext(ctx, repo, delTags); err != nil {
return err
@@ -256,7 +257,7 @@ func PushUpdateAddDeleteTags(repo *models.Repository, gitRepo *git.Repository, a
}
// pushUpdateAddTags updates a number of add tags
-func pushUpdateAddTags(ctx context.Context, repo *models.Repository, gitRepo *git.Repository, tags []string) error {
+func pushUpdateAddTags(ctx context.Context, repo *repo_model.Repository, gitRepo *git.Repository, tags []string) error {
if len(tags) == 0 {
return nil
}
diff --git a/services/repository/repository.go b/services/repository/repository.go
index 4929f9f446..0b97148f66 100644
--- a/services/repository/repository.go
+++ b/services/repository/repository.go
@@ -8,6 +8,7 @@ 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/log"
"code.gitea.io/gitea/modules/notification"
@@ -17,7 +18,7 @@ import (
)
// CreateRepository creates a repository for the user/organization.
-func CreateRepository(doer, owner *user_model.User, opts models.CreateRepoOptions) (*models.Repository, error) {
+func CreateRepository(doer, owner *user_model.User, opts models.CreateRepoOptions) (*repo_model.Repository, error) {
repo, err := repo_module.CreateRepository(doer, owner, opts)
if err != nil {
// No need to rollback here we should do this in CreateRepository...
@@ -30,7 +31,7 @@ func CreateRepository(doer, owner *user_model.User, opts models.CreateRepoOption
}
// DeleteRepository deletes a repository for a user or organization.
-func DeleteRepository(doer *user_model.User, repo *models.Repository) error {
+func DeleteRepository(doer *user_model.User, repo *repo_model.Repository) error {
if err := pull_service.CloseRepoBranchesPulls(doer, repo); err != nil {
log.Error("CloseRepoBranchesPulls failed: %v", err)
}
@@ -43,7 +44,7 @@ func DeleteRepository(doer *user_model.User, repo *models.Repository) error {
}
// PushCreateRepo creates a repository when a new repository is pushed to an appropriate namespace
-func PushCreateRepo(authUser, owner *user_model.User, repoName string) (*models.Repository, error) {
+func PushCreateRepo(authUser, owner *user_model.User, repoName string) (*repo_model.Repository, error) {
if !authUser.IsAdmin {
if owner.IsOrganization() {
if ok, err := models.CanCreateOrgRepo(owner.ID, authUser.ID); err != nil {
diff --git a/services/repository/transfer.go b/services/repository/transfer.go
index d6aea70ffd..b60338300b 100644
--- a/services/repository/transfer.go
+++ b/services/repository/transfer.go
@@ -8,7 +8,9 @@ import (
"fmt"
"code.gitea.io/gitea/models"
+ "code.gitea.io/gitea/models/db"
"code.gitea.io/gitea/models/perm"
+ repo_model "code.gitea.io/gitea/models/repo"
user_model "code.gitea.io/gitea/models/user"
"code.gitea.io/gitea/modules/notification"
"code.gitea.io/gitea/modules/sync"
@@ -18,8 +20,8 @@ import (
var repoWorkingPool = sync.NewExclusivePool()
// TransferOwnership transfers all corresponding setting from old user to new one.
-func TransferOwnership(doer, newOwner *user_model.User, repo *models.Repository, teams []*models.Team) error {
- if err := repo.GetOwner(); err != nil {
+func TransferOwnership(doer, newOwner *user_model.User, repo *repo_model.Repository, teams []*models.Team) error {
+ if err := repo.GetOwner(db.DefaultContext); err != nil {
return err
}
for _, team := range teams {
@@ -37,7 +39,7 @@ func TransferOwnership(doer, newOwner *user_model.User, repo *models.Repository,
}
repoWorkingPool.CheckOut(fmt.Sprint(repo.ID))
- newRepo, err := models.GetRepositoryByID(repo.ID)
+ newRepo, err := repo_model.GetRepositoryByID(repo.ID)
if err != nil {
return err
}
@@ -54,7 +56,7 @@ func TransferOwnership(doer, newOwner *user_model.User, repo *models.Repository,
}
// ChangeRepositoryName changes all corresponding setting from old repository name to new one.
-func ChangeRepositoryName(doer *user_model.User, repo *models.Repository, newRepoName string) error {
+func ChangeRepositoryName(doer *user_model.User, repo *repo_model.Repository, newRepoName string) error {
oldRepoName := repo.Name
// Change repository directory name. We must lock the local copy of the
@@ -75,7 +77,7 @@ func ChangeRepositoryName(doer *user_model.User, repo *models.Repository, newRep
// StartRepositoryTransfer transfer a repo from one owner to a new one.
// it make repository into pending transfer state, if doer can not create repo for new owner.
-func StartRepositoryTransfer(doer, newOwner *user_model.User, repo *models.Repository, teams []*models.Team) error {
+func StartRepositoryTransfer(doer, newOwner *user_model.User, repo *repo_model.Repository, teams []*models.Team) error {
if err := models.TestRepositoryReadyForTransfer(repo.Status); err != nil {
return err
}
@@ -102,16 +104,16 @@ func StartRepositoryTransfer(doer, newOwner *user_model.User, repo *models.Repos
return err
}
if !hasAccess {
- if err := repo.AddCollaborator(newOwner); err != nil {
+ if err := models.AddCollaborator(repo, newOwner); err != nil {
return err
}
- if err := repo.ChangeCollaborationAccessMode(newOwner.ID, perm.AccessModeRead); err != nil {
+ if err := models.ChangeCollaborationAccessMode(repo, newOwner.ID, perm.AccessModeRead); err != nil {
return err
}
}
// Make repo as pending for transfer
- repo.Status = models.RepositoryPendingTransfer
+ repo.Status = repo_model.RepositoryPendingTransfer
if err := models.CreatePendingRepositoryTransfer(doer, newOwner, repo.ID, teams); err != nil {
return err
}
diff --git a/services/repository/transfer_test.go b/services/repository/transfer_test.go
index 866e49c866..d4fbe95834 100644
--- a/services/repository/transfer_test.go
+++ b/services/repository/transfer_test.go
@@ -9,6 +9,7 @@ import (
"testing"
"code.gitea.io/gitea/models"
+ repo_model "code.gitea.io/gitea/models/repo"
"code.gitea.io/gitea/models/unittest"
user_model "code.gitea.io/gitea/models/user"
"code.gitea.io/gitea/modules/notification"
@@ -32,17 +33,17 @@ func TestTransferOwnership(t *testing.T) {
assert.NoError(t, unittest.PrepareTestDatabase())
doer := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 2}).(*user_model.User)
- repo := unittest.AssertExistsAndLoadBean(t, &models.Repository{ID: 3}).(*models.Repository)
+ repo := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 3}).(*repo_model.Repository)
repo.Owner = unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: repo.OwnerID}).(*user_model.User)
assert.NoError(t, TransferOwnership(doer, doer, repo, nil))
- transferredRepo := unittest.AssertExistsAndLoadBean(t, &models.Repository{ID: 3}).(*models.Repository)
+ transferredRepo := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 3}).(*repo_model.Repository)
assert.EqualValues(t, 2, transferredRepo.OwnerID)
- exist, err := util.IsExist(models.RepoPath("user3", "repo3"))
+ exist, err := util.IsExist(repo_model.RepoPath("user3", "repo3"))
assert.NoError(t, err)
assert.False(t, exist)
- exist, err = util.IsExist(models.RepoPath("user2", "repo3"))
+ exist, err = util.IsExist(repo_model.RepoPath("user2", "repo3"))
assert.NoError(t, err)
assert.True(t, exist)
unittest.AssertExistsAndLoadBean(t, &models.Action{
@@ -52,7 +53,7 @@ func TestTransferOwnership(t *testing.T) {
Content: "user3/repo3",
})
- unittest.CheckConsistencyFor(t, &models.Repository{}, &user_model.User{}, &models.Team{})
+ unittest.CheckConsistencyFor(t, &repo_model.Repository{}, &user_model.User{}, &models.Team{})
}
func TestStartRepositoryTransferSetPermission(t *testing.T) {
@@ -60,7 +61,7 @@ func TestStartRepositoryTransferSetPermission(t *testing.T) {
doer := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 3}).(*user_model.User)
recipient := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 5}).(*user_model.User)
- repo := unittest.AssertExistsAndLoadBean(t, &models.Repository{ID: 3}).(*models.Repository)
+ repo := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 3}).(*repo_model.Repository)
repo.Owner = unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: repo.OwnerID}).(*user_model.User)
hasAccess, err := models.HasAccess(recipient.ID, repo)
@@ -73,5 +74,5 @@ func TestStartRepositoryTransferSetPermission(t *testing.T) {
assert.NoError(t, err)
assert.True(t, hasAccess)
- unittest.CheckConsistencyFor(t, &models.Repository{}, &user_model.User{}, &models.Team{})
+ unittest.CheckConsistencyFor(t, &repo_model.Repository{}, &user_model.User{}, &models.Team{})
}