Skip to content

Commit

Permalink
Disallow branch filters for tag push event
Browse files Browse the repository at this point in the history
We cannot filter branches for a tag push event, since the
tag is referring to a certain commit and has no reference to
a branch. Therefore the webhook does not contain the information
about the branch.

Fixes #13206
  • Loading branch information
krauselukas committed Feb 14, 2023
1 parent ab9df83 commit 59a206c
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/api/app/validators/workflow_filters_validator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ def validate_filters
"#{unsupported_filters.keys.to_sentence} are unsupported")
end

@workflow.errors.add(:filters, 'for branches are not supported for the tag push event') if unsupported_filters_for_event?

return if unsupported_filter_values.blank?

@workflow.errors.add(:filters, "#{unsupported_filter_values.to_sentence} have unsupported values, " \
Expand Down Expand Up @@ -56,4 +58,9 @@ def unsupported_filter_values
unsupported_filter_values
end
end

def unsupported_filters_for_event?
# Tags do not have a reference to a branch, they are referring to a commit
@workflow_instructions[:filters][:branches].present? && @workflow.scm_webhook.tag_push_event?
end
end

0 comments on commit 59a206c

Please sign in to comment.