Commit 8778961d authored by Riyad Preukschas's avatar Riyad Preukschas

Move prepare_satellite! to Gitlab::Satelite::Action

parent 78235edd
......@@ -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
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
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment