This instance will be upgraded to Heptapod 0.31.0rc on 2022-05-19 at 11:00 UTC+2 (a few minutes of down time)

git_tag_push_service.rb 895 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
11
12
13
14
    project.execute_hooks(@push_data.dup, :tag_push_hooks)
  end

  private

15
  def create_push_data(oldrev, newrev, ref)
16
17
    data = {
      ref: ref,
18
19
      before: oldrev,
      after: newrev,
20
21
22
23
24
25
26
27
28
29
30
      user_id: user.id,
      user_name: user.name,
      project_id: project.id,
      repository: {
        name: project.name,
        url: project.url_to_repo,
        description: project.description,
        homepage: project.web_url
      }
    }
  end
31
32
33
34
35
36
37
38
39

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