2019-07-31 22:56:46 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Git
|
|
|
|
class TagHooksService < ::Git::BaseHooksService
|
|
|
|
private
|
|
|
|
|
|
|
|
def hook_name
|
|
|
|
:tag_push_hooks
|
|
|
|
end
|
|
|
|
|
|
|
|
def commits
|
|
|
|
[tag_commit].compact
|
|
|
|
end
|
|
|
|
|
|
|
|
def event_message
|
|
|
|
tag&.message
|
|
|
|
end
|
|
|
|
|
|
|
|
def tag
|
|
|
|
strong_memoize(:tag) do
|
2019-12-21 20:55:43 +05:30
|
|
|
next if Gitlab::Git.blank_ref?(newrev)
|
2019-07-31 22:56:46 +05:30
|
|
|
|
2019-12-21 20:55:43 +05:30
|
|
|
tag_name = Gitlab::Git.ref_name(ref)
|
2019-07-31 22:56:46 +05:30
|
|
|
tag = project.repository.find_tag(tag_name)
|
|
|
|
|
2019-12-21 20:55:43 +05:30
|
|
|
tag if tag && tag.target == newrev
|
2019-07-31 22:56:46 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def tag_commit
|
|
|
|
strong_memoize(:tag_commit) do
|
|
|
|
project.commit(tag.dereferenced_target) if tag
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2019-12-04 20:38:33 +05:30
|
|
|
|
2021-06-08 01:23:25 +05:30
|
|
|
Git::TagHooksService.prepend_mod_with('Git::TagHooksService')
|