git_tag_push_service.rb 753 Bytes
Newer Older
1
2
class GitTagPushService
  attr_accessor :project, :user, :push_data
3

4
  def execute(project, user, oldrev, newrev, ref)
5
    @project, @user = project, user
6
    @push_data = create_push_data(oldrev, newrev, ref)
7
8
9

    create_push_event
    project.repository.expire_cache
10
    project.execute_hooks(@push_data.dup, :tag_push_hooks)
11
12
13
14
15
16

    if project.gitlab_ci?
      project.gitlab_ci_service.async_execute(@push_data)
    end

    true
17
18
19
20
  end

  private

21
  def create_push_data(oldrev, newrev, ref)
22
23
    Gitlab::PushDataBuilder.
      build(project, user, oldrev, newrev, ref, [])
24
  end
25
26
27
28
29
30
31
32
33

  def create_push_event
    Event.create!(
      project: project,
      action: Event::PUSHED,
      data: push_data,
      author_id: push_data[:user_id]
    )
  end
34
end