mirror of
https://codeberg.org/davrot/forgejo.git
synced 2025-05-20 05:00:01 +02:00
Move almost all functions' parameter db.Engine to context.Context (#19748)
* Move almost all functions' parameter db.Engine to context.Context * remove some unnecessary wrap functions
This commit is contained in:
parent
d81e31ad78
commit
fd7d83ace6
232 changed files with 1463 additions and 2108 deletions
|
@ -116,8 +116,8 @@ func WatchRepoMode(userID, repoID int64, mode WatchMode) (err error) {
|
|||
return watchRepoMode(db.DefaultContext, watch, mode)
|
||||
}
|
||||
|
||||
// WatchRepoCtx watch or unwatch repository.
|
||||
func WatchRepoCtx(ctx context.Context, userID, repoID int64, doWatch bool) (err error) {
|
||||
// WatchRepo watch or unwatch repository.
|
||||
func WatchRepo(ctx context.Context, userID, repoID int64, doWatch bool) (err error) {
|
||||
var watch Watch
|
||||
if watch, err = GetWatch(ctx, userID, repoID); err != nil {
|
||||
return err
|
||||
|
@ -132,11 +132,6 @@ func WatchRepoCtx(ctx context.Context, userID, repoID int64, doWatch bool) (err
|
|||
return err
|
||||
}
|
||||
|
||||
// WatchRepo watch or unwatch repository.
|
||||
func WatchRepo(userID, repoID int64, watch bool) (err error) {
|
||||
return WatchRepoCtx(db.DefaultContext, userID, repoID, watch)
|
||||
}
|
||||
|
||||
// GetWatchers returns all watchers of given repository.
|
||||
func GetWatchers(ctx context.Context, repoID int64) ([]*Watch, error) {
|
||||
watches := make([]*Watch, 0, 10)
|
||||
|
@ -176,7 +171,8 @@ func GetRepoWatchers(repoID int64, opts db.ListOptions) ([]*user_model.User, err
|
|||
return users, sess.Find(&users)
|
||||
}
|
||||
|
||||
func watchIfAuto(ctx context.Context, userID, repoID int64, isWrite bool) error {
|
||||
// WatchIfAuto subscribes to repo if AutoWatchOnChanges is set
|
||||
func WatchIfAuto(ctx context.Context, userID, repoID int64, isWrite bool) error {
|
||||
if !isWrite || !setting.Service.AutoWatchOnChanges {
|
||||
return nil
|
||||
}
|
||||
|
@ -189,8 +185,3 @@ func watchIfAuto(ctx context.Context, userID, repoID int64, isWrite bool) error
|
|||
}
|
||||
return watchRepoMode(ctx, watch, WatchModeAuto)
|
||||
}
|
||||
|
||||
// WatchIfAuto subscribes to repo if AutoWatchOnChanges is set
|
||||
func WatchIfAuto(userID, repoID int64, isWrite bool) error {
|
||||
return watchIfAuto(db.DefaultContext, userID, repoID, isWrite)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue