diff --git a/lib/gitlab/satellite/action.rb b/lib/gitlab/satellite/action.rb index 23f8185..0d7eecd 100644 --- a/lib/gitlab/satellite/action.rb +++ b/lib/gitlab/satellite/action.rb @@ -3,10 +3,11 @@ module Gitlab class Action DEFAULT_OPTIONS = { git_timeout: 30.seconds } - attr_accessor :options, :project + attr_accessor :options, :project, :user - def initialize(project, options = {}) + def initialize(project, user, options = {}) @project = project + @user = user @options = DEFAULT_OPTIONS.merge(options) end @@ -42,6 +43,21 @@ module Gitlab def lock_file Rails.root.join("tmp", "#{project.path}.lock") end + + # * Clears the satellite + # * Updates the satellite from Gitolite + # * Sets up Git variables for the user + # + # Note: use this within #in_locked_and_timed_satellite + def prepare_satellite!(repo) + project.satellite.clear + + repo.git.reset(hard: true) + repo.git.fetch({}, :origin) + + repo.git.config({}, "user.name", user.name) + repo.git.config({}, "user.email", user.email) + end end end end diff --git a/lib/gitlab/satellite/merge_action.rb b/lib/gitlab/satellite/merge_action.rb index 067a9ce..fc4cd75 100644 --- a/lib/gitlab/satellite/merge_action.rb +++ b/lib/gitlab/satellite/merge_action.rb @@ -1,12 +1,11 @@ module Gitlab module Satellite class MergeAction < Action - attr_accessor :merge_request, :user + attr_accessor :merge_request def initialize(merge_request, user) - super merge_request.project + super merge_request.project, user @merge_request = merge_request - @user = user end def can_be_merged? @@ -65,19 +64,6 @@ module Gitlab Gitlab::GitLogger.error(ex.message) false end - - # * Clears the satellite - # * Updates the satellite from Gitolite - # * Sets up Git variables for the user - def prepare_satellite!(repo) - project.satellite.clear - - repo.git.reset(hard: true) - repo.git.fetch({}, :origin) - - repo.git.config({}, "user.name", user.name) - repo.git.config({}, "user.email", user.email) - end end end end -- libgit2 0.21.2