Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Send push event when tag is created or deleted #13999

Merged
merged 3 commits into from
Dec 16, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion services/repository/push.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ func pushUpdates(optsList []*repo_module.PushUpdateOptions) error {
return fmt.Errorf("Old and new revisions are both %s", git.EmptySHA)
}
var commits = &repo_module.PushCommits{}
if opts.IsTag() { // If is tag reference {
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 {
Expand All @@ -105,9 +105,25 @@ func pushUpdates(optsList []*repo_module.PushUpdateOptions) error {
}
tagName := opts.TagName()
if opts.IsDelRef() {
notification.NotifyPushCommits(
pusher, repo,
&repo_module.PushUpdateOptions{
RefFullName: git.TagPrefix + tagName,
OldCommitID: opts.OldCommitID,
NewCommitID: git.EmptySHA,
}, repo_module.NewPushCommits())

delTags = append(delTags, tagName)
notification.NotifyDeleteRef(pusher, repo, "tag", opts.RefFullName)
} else { // is new tag
notification.NotifyPushCommits(
pusher, repo,
&repo_module.PushUpdateOptions{
RefFullName: git.TagPrefix + tagName,
OldCommitID: git.EmptySHA,
NewCommitID: opts.NewCommitID,
}, repo_module.NewPushCommits())

addTags = append(addTags, tagName)
notification.NotifyCreateRef(pusher, repo, "tag", opts.RefFullName)
}
Expand Down