Class: GithubHook::Updater

Inherits:
Object
  • Object
show all
Defined in:
app/services/github_hook/updater.rb

Constant Summary collapse

GIT_BIN =
Redmine::Configuration['scm_git_command'] || "git"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(payload, params = {}) ⇒ Updater

Returns a new instance of Updater.



7
8
9
10
# File 'app/services/github_hook/updater.rb', line 7

def initialize(payload, params = {})
  @payload = payload
  @params = params
end

Instance Attribute Details

#logger=(value) ⇒ Object

Sets the attribute logger

Parameters:

  • value

    the value to set the attribute logger to.



5
6
7
# File 'app/services/github_hook/updater.rb', line 5

def logger=(value)
  @logger = value
end

Instance Method Details

#callObject



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'app/services/github_hook/updater.rb', line 12

def call
  repositories = find_repositories

  repositories.each do |repository|
    tg1 = Time.now
    # Fetch the changes from Github
    update_repository(repository)
    tg2 = Time.now

    tr1 = Time.now
    # Fetch the new changesets into Redmine
    repository.fetch_changesets
    tr2 = Time.now

    logger.info { "  GithubHook: Redmine repository updated: #{repository.identifier} (Git: #{time_diff_milli(tg1,tg2)}ms, Redmine: #{time_diff_milli(tr1,tr2)}ms)" }
  end
end