summaryrefslogtreecommitdiff
path: root/app/models/hooks
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2023-01-10 03:07:25 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2023-01-10 03:07:25 +0000
commit4a6dacc8662ed65c0b83a3715e4eb05a78168db1 (patch)
tree04aced9d7d60c1213db9d5152158afe02126599f /app/models/hooks
parent070ac34d473978dc27ea2878ed1cf17865e24e9a (diff)
downloadgitlab-ce-4a6dacc8662ed65c0b83a3715e4eb05a78168db1.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/models/hooks')
-rw-r--r--app/models/hooks/web_hook.rb5
1 files changed, 5 insertions, 0 deletions
diff --git a/app/models/hooks/web_hook.rb b/app/models/hooks/web_hook.rb
index 189291a38ec..49418cda3ac 100644
--- a/app/models/hooks/web_hook.rb
+++ b/app/models/hooks/web_hook.rb
@@ -41,6 +41,7 @@ class WebHook < ApplicationRecord
after_initialize :initialize_url_variables
before_validation :reset_token
+ before_validation :reset_url_variables, unless: ->(hook) { hook.is_a?(ServiceHook) }
before_validation :set_branch_filter_nil, if: :branch_filter_strategy_all_branches?
validates :push_events_branch_filter, untrusted_regexp: true, if: :branch_filter_strategy_regex?
validates :push_events_branch_filter, "web_hooks/wildcard_branch_filter": true, if: :branch_filter_strategy_wildcard?
@@ -213,6 +214,10 @@ class WebHook < ApplicationRecord
self.token = nil if url_changed? && !encrypted_token_changed?
end
+ def reset_url_variables
+ self.url_variables = {} if url_changed? && !encrypted_url_variables_changed?
+ end
+
def next_failure_count
recent_failures.succ.clamp(1, MAX_FAILURES)
end