summaryrefslogtreecommitdiffstats
path: root/modules/repository
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2021-11-19 19:41:40 +0800
committerGitHub <noreply@github.com>2021-11-19 19:41:40 +0800
commit7a0347315995b25bcb2dca4786504fb699b5f004 (patch)
tree803dfd39286216fd0521ad16539ffd9fc5f87fc0 /modules/repository
parenta09b40de8d1dae7107437cfba42cee201fcd6d42 (diff)
downloadgitea-7a0347315995b25bcb2dca4786504fb699b5f004.tar.gz
gitea-7a0347315995b25bcb2dca4786504fb699b5f004.zip
Use a standalone struct name for Organization (#17632)
* Use a standalone struct name for Organization * recover unnecessary change * make the code readable * Fix template failure * Fix template failure * Move HasMemberWithUserID to org * Fix test * Remove unnecessary user type check * Fix test Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Diffstat (limited to 'modules/repository')
-rw-r--r--modules/repository/create_test.go7
-rw-r--r--modules/repository/repo.go2
2 files changed, 4 insertions, 5 deletions
diff --git a/modules/repository/create_test.go b/modules/repository/create_test.go
index 55fc515588..12fc7afeeb 100644
--- a/modules/repository/create_test.go
+++ b/modules/repository/create_test.go
@@ -36,7 +36,7 @@ func TestIncludesAllRepositoriesTeams(t *testing.T) {
assert.NoError(t, err, "GetUserByID")
// Create org.
- org := &models.User{
+ org := &models.Organization{
Name: "All_repo",
IsActive: true,
Type: models.UserTypeOrganization,
@@ -52,7 +52,7 @@ func TestIncludesAllRepositoriesTeams(t *testing.T) {
// Create repos.
repoIds := make([]int64, 0)
for i := 0; i < 3; i++ {
- r, err := CreateRepository(user, org, models.CreateRepoOptions{Name: fmt.Sprintf("repo-%d", i)})
+ r, err := CreateRepository(user, org.AsUser(), models.CreateRepoOptions{Name: fmt.Sprintf("repo-%d", i)})
assert.NoError(t, err, "CreateRepository %d", i)
if r != nil {
repoIds = append(repoIds, r.ID)
@@ -114,8 +114,7 @@ func TestIncludesAllRepositoriesTeams(t *testing.T) {
}
// Create repo and check teams repositories.
- org.Teams = nil // Reset teams to allow their reloading.
- r, err := CreateRepository(user, org, models.CreateRepoOptions{Name: "repo-last"})
+ r, err := CreateRepository(user, org.AsUser(), models.CreateRepoOptions{Name: "repo-last"})
assert.NoError(t, err, "CreateRepository last")
if r != nil {
repoIds = append(repoIds, r.ID)
diff --git a/modules/repository/repo.go b/modules/repository/repo.go
index 871ba617ad..5eec5a7314 100644
--- a/modules/repository/repo.go
+++ b/modules/repository/repo.go
@@ -50,7 +50,7 @@ func MigrateRepositoryGitData(ctx context.Context, u *models.User, repo *models.
repoPath := models.RepoPath(u.Name, opts.RepoName)
if u.IsOrganization() {
- t, err := u.GetOwnerTeam()
+ t, err := models.OrgFromUser(u).GetOwnerTeam()
if err != nil {
return nil, err
}