Class: IrkerWorker

Inherits:
Object
  • Object
show all
Includes:
Sidekiq::Worker
Defined in:
app/workers/irker_worker.rb

Instance Method Summary collapse

Instance Method Details

#perform(project_id, chans, colors, push_data, settings) ⇒ Object


7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'app/workers/irker_worker.rb', line 7

def perform(project_id, chans, colors, push_data, settings)
  project = Project.find(project_id)

  # Get config parameters
  return false unless init_perform settings, chans, colors

  repo_name = push_data['repository']['name']
  committer = push_data['user_name']
  branch = push_data['ref'].gsub(%r'refs/[^/]*/', '')

  if @colors
    repo_name = "\x0304#{repo_name}\x0f"
    branch = "\x0305#{branch}\x0f"
  end

  # First messages are for branch creation/deletion
  send_branch_updates push_data, project, repo_name, committer, branch

  # Next messages are for commits
  send_commits push_data, project, repo_name, committer, branch

  close_connection
  true
end