git_tag_push_service.rb 666 Bytes
Newer Older
1
2
class GitTagPushService
  attr_accessor :project, :user, :push_data
3
  def execute(project, user, oldrev, newrev, ref)
4
    @project, @user = project, user
5
    @push_data = create_push_data(oldrev, newrev, ref)
6
7
8
9
10
    project.execute_hooks(@push_data.dup, :tag_push_hooks)
  end

  private

11
  def create_push_data(oldrev, newrev, ref)
12
13
    data = {
      ref: ref,
14
15
      before: oldrev,
      after: newrev,
16
17
18
19
20
21
22
23
24
25
26
27
      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
end