summaryrefslogtreecommitdiffstats
path: root/models
diff options
context:
space:
mode:
Diffstat (limited to 'models')
-rw-r--r--models/org_team.go25
-rw-r--r--models/repo.go13
2 files changed, 24 insertions, 14 deletions
diff --git a/models/org_team.go b/models/org_team.go
index 2ab807b49b..22fb6eae24 100644
--- a/models/org_team.go
+++ b/models/org_team.go
@@ -11,6 +11,8 @@ import (
"strings"
"code.gitea.io/gitea/modules/log"
+ "code.gitea.io/gitea/modules/setting"
+
"github.com/go-xorm/xorm"
)
@@ -123,14 +125,18 @@ func (t *Team) addRepository(e Engine, repo *Repository) (err error) {
return fmt.Errorf("recalculateAccesses: %v", err)
}
- if err = t.getMembers(e); err != nil {
- return fmt.Errorf("getMembers: %v", err)
- }
- for _, u := range t.Members {
- if err = watchRepo(e, u.ID, repo.ID, true); err != nil {
- return fmt.Errorf("watchRepo: %v", err)
+ // Make all team members watch this repo if enabled in global settings
+ if setting.Service.AutoWatchNewRepos {
+ if err = t.getMembers(e); err != nil {
+ return fmt.Errorf("getMembers: %v", err)
+ }
+ for _, u := range t.Members {
+ if err = watchRepo(e, u.ID, repo.ID, true); err != nil {
+ return fmt.Errorf("watchRepo: %v", err)
+ }
}
}
+
return nil
}
@@ -618,9 +624,10 @@ func AddTeamMember(team *Team, userID int64) error {
if err := repo.recalculateTeamAccesses(sess, 0); err != nil {
return err
}
-
- if err = watchRepo(sess, userID, repo.ID, true); err != nil {
- return err
+ if setting.Service.AutoWatchNewRepos {
+ if err = watchRepo(sess, userID, repo.ID, true); err != nil {
+ return err
+ }
}
}
diff --git a/models/repo.go b/models/repo.go
index fc566ab2d3..51ea1c94bc 100644
--- a/models/repo.go
+++ b/models/repo.go
@@ -34,8 +34,8 @@ import (
"github.com/Unknwon/com"
"github.com/go-xorm/builder"
"github.com/go-xorm/xorm"
- "github.com/mcuadros/go-version"
- "gopkg.in/ini.v1"
+ version "github.com/mcuadros/go-version"
+ ini "gopkg.in/ini.v1"
)
var repoWorkingPool = sync.NewExclusivePool()
@@ -1353,9 +1353,12 @@ func createRepository(e *xorm.Session, doer, u *User, repo *Repository) (err err
}
}
- if err = watchRepo(e, doer.ID, repo.ID, true); err != nil {
- return fmt.Errorf("watchRepo: %v", err)
- } else if err = newRepoAction(e, u, repo); err != nil {
+ if setting.Service.AutoWatchNewRepos {
+ if err = watchRepo(e, doer.ID, repo.ID, true); err != nil {
+ return fmt.Errorf("watchRepo: %v", err)
+ }
+ }
+ if err = newRepoAction(e, u, repo); err != nil {
return fmt.Errorf("newRepoAction: %v", err)
}