Move prepare_satellite! to Gitlab::Satelite::Action
This commit is contained in:
parent
78235edda8
commit
8778961d33
2 changed files with 20 additions and 18 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue