Release webhook not triggered when manually adding release notes to tag
Summary
Editing a tag to add release notes after the creation of the tag creates a new release but does not fire any webhooks configured on the project to trigger on releases events
.
Steps to reproduce
- Create a new project and initialize it with a repository.
- Add a webhook to the project that triggers on
Releases events
. - Manually create a new tag but do not add release notes to it.
- Edit the newly created tag and add release notes to it.
- Observe that a release has now been created but the previously configured webhook has not fired.
Example Project
What is the current bug behavior?
When a release is created by adding release notes to an already created tag any webhook added to the project set to trigger on releases events
will not fire.
What is the expected correct behavior?
Whenever a release is created on the project any webhook added to it that is set to trigger on releases events
will fire.
Output of checks
This bug happens on GitLab.com: 14.1.0-pre b51951ef
Zendesk Reports (GitLab Internal)
Proposal
Here is the pseudocode:
diff --git a/app/controllers/projects/tags/releases_controller.rb b/app/controllers/projects/tags/releases_controller.rb
index b852673d82a..7ec3fd07bd0 100644
--- a/app/controllers/projects/tags/releases_controller.rb
+++ b/app/controllers/projects/tags/releases_controller.rb
@@ -15,7 +15,17 @@ def edit
end
def update
- release.update(release_params) if release.persisted? || release_params[:description].present?
+ if release_params[:description].present?
+ if release.persisted?
+ ::Releases::UpdateService
+ .new(user_project, current_user, release_params)
+ .execute
+ else
+ ::Releases::CreateService
+ .new(user_project, current_user, release_params)
+ .execute
+ end
+ end
redirect_to project_tag_path(@project, tag.name)
end
@@ -25,13 +35,4 @@ def update
def tag
@tag ||= @repository.find_tag(params[:tag_id])
end
-
- def release
- @release ||= Releases::CreateService.new(project, current_user, tag: @tag.name)
- .find_or_build_release
- end
-
- def release_params
- params.require(:release).permit(:description)
- end
end
Edited by Shinya Maeda