aboutsummaryrefslogtreecommitdiffstats
path: root/models/org_team.go
diff options
context:
space:
mode:
Diffstat (limited to 'models/org_team.go')
-rw-r--r--models/org_team.go26
1 files changed, 16 insertions, 10 deletions
diff --git a/models/org_team.go b/models/org_team.go
index 62376192ab..a5a2575eec 100644
--- a/models/org_team.go
+++ b/models/org_team.go
@@ -41,7 +41,7 @@ func AddRepository(ctx context.Context, t *organization.Team, repo *repo_model.R
// Make all team members watch this repo if enabled in global settings
if setting.Service.AutoWatchNewRepos {
- if err = t.GetMembersCtx(ctx); err != nil {
+ if err = t.LoadMembers(ctx); err != nil {
return fmt.Errorf("getMembers: %w", err)
}
for _, u := range t.Members {
@@ -213,7 +213,7 @@ func RemoveRepository(t *organization.Team, repoID int64) error {
return nil
}
- repo, err := repo_model.GetRepositoryByID(repoID)
+ repo, err := repo_model.GetRepositoryByID(db.DefaultContext, repoID)
if err != nil {
return err
}
@@ -349,8 +349,8 @@ func UpdateTeam(t *organization.Team, authChanged, includeAllChanged bool) (err
// Update access for team members if needed.
if authChanged {
- if err = t.GetRepositoriesCtx(ctx); err != nil {
- return fmt.Errorf("getRepositories: %w", err)
+ if err = t.LoadRepositories(ctx); err != nil {
+ return fmt.Errorf("LoadRepositories: %w", err)
}
for _, repo := range t.Repos {
@@ -381,11 +381,11 @@ func DeleteTeam(t *organization.Team) error {
defer committer.Close()
sess := db.GetEngine(ctx)
- if err := t.GetRepositoriesCtx(ctx); err != nil {
+ if err := t.LoadRepositories(ctx); err != nil {
return err
}
- if err := t.GetMembersCtx(ctx); err != nil {
+ if err := t.LoadMembers(ctx); err != nil {
return err
}
@@ -516,10 +516,16 @@ func AddTeamMember(team *organization.Team, userID int64) error {
}
}
- // watch could be failed, so run it in a goroutine
+ if err := committer.Commit(); err != nil {
+ return err
+ }
+ committer.Close()
+
+ // this behaviour may spend much time so run it in a goroutine
+ // FIXME: Update watch repos batchly
if setting.Service.AutoWatchNewRepos {
// Get team and its repositories.
- if err := team.GetRepositoriesCtx(db.DefaultContext); err != nil {
+ if err := team.LoadRepositories(db.DefaultContext); err != nil {
log.Error("getRepositories failed: %v", err)
}
go func(repos []*repo_model.Repository) {
@@ -531,7 +537,7 @@ func AddTeamMember(team *organization.Team, userID int64) error {
}(team.Repos)
}
- return committer.Commit()
+ return nil
}
func removeTeamMember(ctx context.Context, team *organization.Team, userID int64) error {
@@ -548,7 +554,7 @@ func removeTeamMember(ctx context.Context, team *organization.Team, userID int64
team.NumMembers--
- if err := team.GetRepositoriesCtx(ctx); err != nil {
+ if err := team.LoadRepositories(ctx); err != nil {
return err
}