Ensure that pusher is not nil preventing panic in push (#13945)

PR #13381 refactored notification actions to call NotifyCreateRef and
NotifyDeleteRef in a slightly different manner. This leads to the pusher
not being set before the call.

This PR ensures that the pusher is updated before the call.

Fix #13940

Signed-off-by: Andrew Thornton <art27@cantab.net>
This commit is contained in:
zeripath 2020-12-11 17:27:00 +00:00 committed by GitHub
parent 160f606a15
commit f2f99a7d0c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -97,6 +97,12 @@ func pushUpdates(optsList []*repo_module.PushUpdateOptions) error {
}
var commits = &repo_module.PushCommits{}
if opts.IsTag() { // If is tag reference {
if pusher == nil || pusher.ID != opts.PusherID {
var err error
if pusher, err = models.GetUserByID(opts.PusherID); err != nil {
return err
}
}
tagName := opts.TagName()
if opts.IsDelRef() {
delTags = append(delTags, tagName)