diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2021-12-10 09:27:50 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-12-10 09:27:50 +0800 |
commit | 719bddcd76610a63dadc8555760072957a11cf30 (patch) | |
tree | 0df26092fba7e3e21444fe493e6b349473b6b0cb /services/release | |
parent | fb8166c6c6b652a0e6fa98681780a6a71090faf3 (diff) | |
download | gitea-719bddcd76610a63dadc8555760072957a11cf30.tar.gz gitea-719bddcd76610a63dadc8555760072957a11cf30.zip |
Move repository model into models/repo (#17933)
* Some refactors related repository model
* Move more methods out of repository
* Move repository into models/repo
* Fix test
* Fix test
* some improvements
* Remove unnecessary function
Diffstat (limited to 'services/release')
-rw-r--r-- | services/release/release.go | 6 | ||||
-rw-r--r-- | services/release/release_test.go | 14 |
2 files changed, 10 insertions, 10 deletions
diff --git a/services/release/release.go b/services/release/release.go index ec1494d426..e20b91ece0 100644 --- a/services/release/release.go +++ b/services/release/release.go @@ -31,7 +31,7 @@ func createTag(gitRepo *git.Repository, rel *models.Release, msg string) (bool, return false, err } - protectedTags, err := rel.Repo.GetProtectedTags() + protectedTags, err := models.GetProtectedTags(rel.Repo.ID) if err != nil { return false, fmt.Errorf("GetProtectedTags: %v", err) } @@ -137,7 +137,7 @@ func CreateRelease(gitRepo *git.Repository, rel *models.Release, attachmentUUIDs } // CreateNewTag creates a new repository tag -func CreateNewTag(doer *user_model.User, repo *models.Repository, commit, tagName, msg string) error { +func CreateNewTag(doer *user_model.User, repo *repo_model.Repository, commit, tagName, msg string) error { isExist, err := models.IsReleaseExist(repo.ID, tagName) if err != nil { return err @@ -285,7 +285,7 @@ func DeleteReleaseByID(id int64, doer *user_model.User, delTag bool) error { return fmt.Errorf("GetReleaseByID: %v", err) } - repo, err := models.GetRepositoryByID(rel.RepoID) + repo, err := repo_model.GetRepositoryByID(rel.RepoID) if err != nil { return fmt.Errorf("GetRepositoryByID: %v", err) } diff --git a/services/release/release_test.go b/services/release/release_test.go index 29ff78ca3a..b41eea7e9e 100644 --- a/services/release/release_test.go +++ b/services/release/release_test.go @@ -28,8 +28,8 @@ func TestRelease_Create(t *testing.T) { assert.NoError(t, unittest.PrepareTestDatabase()) user := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 2}).(*user_model.User) - repo := unittest.AssertExistsAndLoadBean(t, &models.Repository{ID: 1}).(*models.Repository) - repoPath := models.RepoPath(user.Name, repo.Name) + repo := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 1}).(*repo_model.Repository) + repoPath := repo_model.RepoPath(user.Name, repo.Name) gitRepo, err := git.OpenRepository(repoPath) assert.NoError(t, err) @@ -132,8 +132,8 @@ func TestRelease_Update(t *testing.T) { assert.NoError(t, unittest.PrepareTestDatabase()) user := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 2}).(*user_model.User) - repo := unittest.AssertExistsAndLoadBean(t, &models.Repository{ID: 1}).(*models.Repository) - repoPath := models.RepoPath(user.Name, repo.Name) + repo := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 1}).(*repo_model.Repository) + repoPath := repo_model.RepoPath(user.Name, repo.Name) gitRepo, err := git.OpenRepository(repoPath) assert.NoError(t, err) @@ -274,8 +274,8 @@ func TestRelease_createTag(t *testing.T) { assert.NoError(t, unittest.PrepareTestDatabase()) user := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 2}).(*user_model.User) - repo := unittest.AssertExistsAndLoadBean(t, &models.Repository{ID: 1}).(*models.Repository) - repoPath := models.RepoPath(user.Name, repo.Name) + repo := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 1}).(*repo_model.Repository) + repoPath := repo_model.RepoPath(user.Name, repo.Name) gitRepo, err := git.OpenRepository(repoPath) assert.NoError(t, err) @@ -356,7 +356,7 @@ func TestRelease_createTag(t *testing.T) { func TestCreateNewTag(t *testing.T) { assert.NoError(t, unittest.PrepareTestDatabase()) user := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 2}).(*user_model.User) - repo := unittest.AssertExistsAndLoadBean(t, &models.Repository{ID: 1}).(*models.Repository) + repo := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 1}).(*repo_model.Repository) assert.NoError(t, CreateNewTag(user, repo, "master", "v2.0", "v2.0 is released \n\n BUGFIX: .... \n\n 123")) |