Allow gitea bot as trigger user

This commit is contained in:
Lunny Xiao 2022-11-17 17:59:47 +08:00 committed by Jason Song
parent 110072a8d4
commit f4bbd534b9
2 changed files with 19 additions and 7 deletions

View File

@ -49,8 +49,12 @@ func (runs RunList) LoadTriggerUser() error {
return err
}
for _, run := range runs {
if run.TriggerUserID == user_model.BotUserID {
run.TriggerUser = user_model.NewBotUser()
} else {
run.TriggerUser = users[run.TriggerUserID]
}
}
return nil
}

View File

@ -109,11 +109,15 @@ func pushUpdates(optsList []*repo_module.PushUpdateOptions) error {
}
if opts.IsTag() { // If is tag reference
if pusher == nil || pusher.ID != opts.PusherID {
if opts.PusherID == user_model.BotUserID {
pusher = user_model.NewBotUser()
} else {
var err error
if pusher, err = user_model.GetUserByID(opts.PusherID); err != nil {
return err
}
}
}
tagName := opts.TagName()
if opts.IsDelRef() {
notification.NotifyPushCommits(
@ -149,11 +153,15 @@ func pushUpdates(optsList []*repo_module.PushUpdateOptions) error {
}
} else if opts.IsBranch() { // If is branch reference
if pusher == nil || pusher.ID != opts.PusherID {
if opts.PusherID == user_model.BotUserID {
pusher = user_model.NewBotUser()
} else {
var err error
if pusher, err = user_model.GetUserByID(opts.PusherID); err != nil {
return err
}
}
}
branch := opts.BranchName()
if !opts.IsDelRef() {