Commit 8778961d33c15938f4ed3de301fd9b865b9299d8

Authored by Riyad Preukschas
1 parent 78235edd

Move prepare_satellite! to Gitlab::Satelite::Action

lib/gitlab/satellite/action.rb
@@ -3,10 +3,11 @@ module Gitlab @@ -3,10 +3,11 @@ module Gitlab
3 class Action 3 class Action
4 DEFAULT_OPTIONS = { git_timeout: 30.seconds } 4 DEFAULT_OPTIONS = { git_timeout: 30.seconds }
5 5
6 - attr_accessor :options, :project 6 + attr_accessor :options, :project, :user
7 7
8 - def initialize(project, options = {}) 8 + def initialize(project, user, options = {})
9 @project = project 9 @project = project
  10 + @user = user
10 @options = DEFAULT_OPTIONS.merge(options) 11 @options = DEFAULT_OPTIONS.merge(options)
11 end 12 end
12 13
@@ -42,6 +43,21 @@ module Gitlab @@ -42,6 +43,21 @@ module Gitlab
42 def lock_file 43 def lock_file
43 Rails.root.join("tmp", "#{project.path}.lock") 44 Rails.root.join("tmp", "#{project.path}.lock")
44 end 45 end
  46 +
  47 + # * Clears the satellite
  48 + # * Updates the satellite from Gitolite
  49 + # * Sets up Git variables for the user
  50 + #
  51 + # Note: use this within #in_locked_and_timed_satellite
  52 + def prepare_satellite!(repo)
  53 + project.satellite.clear
  54 +
  55 + repo.git.reset(hard: true)
  56 + repo.git.fetch({}, :origin)
  57 +
  58 + repo.git.config({}, "user.name", user.name)
  59 + repo.git.config({}, "user.email", user.email)
  60 + end
45 end 61 end
46 end 62 end
47 end 63 end
lib/gitlab/satellite/merge_action.rb
1 module Gitlab 1 module Gitlab
2 module Satellite 2 module Satellite
3 class MergeAction < Action 3 class MergeAction < Action
4 - attr_accessor :merge_request, :user 4 + attr_accessor :merge_request
5 5
6 def initialize(merge_request, user) 6 def initialize(merge_request, user)
7 - super merge_request.project 7 + super merge_request.project, user
8 @merge_request = merge_request 8 @merge_request = merge_request
9 - @user = user  
10 end 9 end
11 10
12 def can_be_merged? 11 def can_be_merged?
@@ -65,19 +64,6 @@ module Gitlab @@ -65,19 +64,6 @@ module Gitlab
65 Gitlab::GitLogger.error(ex.message) 64 Gitlab::GitLogger.error(ex.message)
66 false 65 false
67 end 66 end
68 -  
69 - # * Clears the satellite  
70 - # * Updates the satellite from Gitolite  
71 - # * Sets up Git variables for the user  
72 - def prepare_satellite!(repo)  
73 - project.satellite.clear  
74 -  
75 - repo.git.reset(hard: true)  
76 - repo.git.fetch({}, :origin)  
77 -  
78 - repo.git.config({}, "user.name", user.name)  
79 - repo.git.config({}, "user.email", user.email)  
80 - end  
81 end 67 end
82 end 68 end
83 end 69 end