Config option to disable automatic repo watching (#5852)
Add a new config option to enable / disable the automatic watching of repos for new repositories and if a user is added to a team. Fixes #653 Signed-off-by: Sebastian Sauer <sauer.sebastian@gmail.com>
This commit is contained in:
parent
b8a81cb1b8
commit
84076211b3
5 changed files with 31 additions and 14 deletions
|
@ -368,6 +368,10 @@ DEFAULT_ALLOW_ONLY_CONTRIBUTORS_TO_TRACK_TIME = true
|
||||||
NO_REPLY_ADDRESS = noreply.example.org
|
NO_REPLY_ADDRESS = noreply.example.org
|
||||||
; Show Registration button
|
; Show Registration button
|
||||||
SHOW_REGISTRATION_BUTTON = true
|
SHOW_REGISTRATION_BUTTON = true
|
||||||
|
; Default value for AutoWatchNewRepos
|
||||||
|
; When adding a repo to a team or creating a new repo all team members will watch the
|
||||||
|
; repo automatically if enabled
|
||||||
|
AUTO_WATCH_NEW_REPOS = true
|
||||||
|
|
||||||
[webhook]
|
[webhook]
|
||||||
; Hook task queue length, increase if webhook shooting starts hanging
|
; Hook task queue length, increase if webhook shooting starts hanging
|
||||||
|
|
|
@ -207,6 +207,7 @@ Values containing `#` or `;` must be quoted using `` ` `` or `"""`.
|
||||||
- `EMAIL_DOMAIN_WHITELIST`: **\<empty\>**: If non-empty, list of domain names that can only be used to register
|
- `EMAIL_DOMAIN_WHITELIST`: **\<empty\>**: If non-empty, list of domain names that can only be used to register
|
||||||
on this instance.
|
on this instance.
|
||||||
- `SHOW_REGISTRATION_BUTTON`: **! DISABLE\_REGISTRATION**: Show Registration Button
|
- `SHOW_REGISTRATION_BUTTON`: **! DISABLE\_REGISTRATION**: Show Registration Button
|
||||||
|
- `AUTO_WATCH_NEW_REPOS`: **true** Enable this to let all organisation users watch new repos when they are created
|
||||||
|
|
||||||
## Webhook (`webhook`)
|
## Webhook (`webhook`)
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,8 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"code.gitea.io/gitea/modules/log"
|
"code.gitea.io/gitea/modules/log"
|
||||||
|
"code.gitea.io/gitea/modules/setting"
|
||||||
|
|
||||||
"github.com/go-xorm/xorm"
|
"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)
|
return fmt.Errorf("recalculateAccesses: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err = t.getMembers(e); err != nil {
|
// Make all team members watch this repo if enabled in global settings
|
||||||
return fmt.Errorf("getMembers: %v", err)
|
if setting.Service.AutoWatchNewRepos {
|
||||||
}
|
if err = t.getMembers(e); err != nil {
|
||||||
for _, u := range t.Members {
|
return fmt.Errorf("getMembers: %v", err)
|
||||||
if err = watchRepo(e, u.ID, repo.ID, true); err != nil {
|
}
|
||||||
return fmt.Errorf("watchRepo: %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
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -618,9 +624,10 @@ func AddTeamMember(team *Team, userID int64) error {
|
||||||
if err := repo.recalculateTeamAccesses(sess, 0); err != nil {
|
if err := repo.recalculateTeamAccesses(sess, 0); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
if setting.Service.AutoWatchNewRepos {
|
||||||
if err = watchRepo(sess, userID, repo.ID, true); err != nil {
|
if err = watchRepo(sess, userID, repo.ID, true); err != nil {
|
||||||
return err
|
return err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -34,8 +34,8 @@ import (
|
||||||
"github.com/Unknwon/com"
|
"github.com/Unknwon/com"
|
||||||
"github.com/go-xorm/builder"
|
"github.com/go-xorm/builder"
|
||||||
"github.com/go-xorm/xorm"
|
"github.com/go-xorm/xorm"
|
||||||
"github.com/mcuadros/go-version"
|
version "github.com/mcuadros/go-version"
|
||||||
"gopkg.in/ini.v1"
|
ini "gopkg.in/ini.v1"
|
||||||
)
|
)
|
||||||
|
|
||||||
var repoWorkingPool = sync.NewExclusivePool()
|
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 {
|
if setting.Service.AutoWatchNewRepos {
|
||||||
return fmt.Errorf("watchRepo: %v", err)
|
if err = watchRepo(e, doer.ID, repo.ID, true); err != nil {
|
||||||
} else if err = newRepoAction(e, u, repo); err != nil {
|
return fmt.Errorf("watchRepo: %v", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if err = newRepoAction(e, u, repo); err != nil {
|
||||||
return fmt.Errorf("newRepoAction: %v", err)
|
return fmt.Errorf("newRepoAction: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1247,6 +1247,7 @@ var Service struct {
|
||||||
DefaultAllowOnlyContributorsToTrackTime bool
|
DefaultAllowOnlyContributorsToTrackTime bool
|
||||||
NoReplyAddress string
|
NoReplyAddress string
|
||||||
EnableUserHeatmap bool
|
EnableUserHeatmap bool
|
||||||
|
AutoWatchNewRepos bool
|
||||||
|
|
||||||
// OpenID settings
|
// OpenID settings
|
||||||
EnableOpenIDSignIn bool
|
EnableOpenIDSignIn bool
|
||||||
|
@ -1281,6 +1282,7 @@ func newService() {
|
||||||
Service.DefaultAllowOnlyContributorsToTrackTime = sec.Key("DEFAULT_ALLOW_ONLY_CONTRIBUTORS_TO_TRACK_TIME").MustBool(true)
|
Service.DefaultAllowOnlyContributorsToTrackTime = sec.Key("DEFAULT_ALLOW_ONLY_CONTRIBUTORS_TO_TRACK_TIME").MustBool(true)
|
||||||
Service.NoReplyAddress = sec.Key("NO_REPLY_ADDRESS").MustString("noreply.example.org")
|
Service.NoReplyAddress = sec.Key("NO_REPLY_ADDRESS").MustString("noreply.example.org")
|
||||||
Service.EnableUserHeatmap = sec.Key("ENABLE_USER_HEATMAP").MustBool(true)
|
Service.EnableUserHeatmap = sec.Key("ENABLE_USER_HEATMAP").MustBool(true)
|
||||||
|
Service.AutoWatchNewRepos = sec.Key("AUTO_WATCH_NEW_REPOS").MustBool(true)
|
||||||
|
|
||||||
sec = Cfg.Section("openid")
|
sec = Cfg.Section("openid")
|
||||||
Service.EnableOpenIDSignIn = sec.Key("ENABLE_OPENID_SIGNIN").MustBool(!InstallLock)
|
Service.EnableOpenIDSignIn = sec.Key("ENABLE_OPENID_SIGNIN").MustBool(!InstallLock)
|
||||||
|
|
Loading…
Reference in a new issue