Class: OmgPullRequest::GitClient

Inherits:
Object
  • Object
show all
Extended by:
Configuration::Helpers
Defined in:
lib/omg_pull_request/git_client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Configuration::Helpers

delegate_config_to

Constructor Details

#initialize(attributes = Hash.new) ⇒ GitClient

Returns a new instance of GitClient.



5
6
7
8
9
# File 'lib/omg_pull_request/git_client.rb', line 5

def initialize(attributes=Hash.new)
  attributes.each do |attr, value|
    self.send("#{attr}=", value)
  end
end

Instance Attribute Details

#configurationObject

Returns the value of attribute configuration.



3
4
5
# File 'lib/omg_pull_request/git_client.rb', line 3

def configuration
  @configuration
end

#loggerObject

Returns the value of attribute logger.



3
4
5
# File 'lib/omg_pull_request/git_client.rb', line 3

def logger
  @logger
end

Instance Method Details

#checkout!(sha) ⇒ Object



15
16
17
# File 'lib/omg_pull_request/git_client.rb', line 15

def checkout!(sha)
  execute_verify_success "cd #{local_repo} && git reset --hard && git fetch && git checkout #{sha} 2>&1"
end

#committers(from_sha, to_sha) ⇒ Object



11
12
13
# File 'lib/omg_pull_request/git_client.rb', line 11

def committers(from_sha, to_sha)
  `cd #{local_repo} && git shortlog -sne #{from_sha}..#{to_sha} | awk '{ print $NF}' | cut -d'<' -f2 | cut -d'>' -f1`.split
end

#merge!(sha) ⇒ Object



19
20
21
22
23
24
25
26
# File 'lib/omg_pull_request/git_client.rb', line 19

def merge!(sha)
  merge_response, exit_code = execute_command "cd #{local_repo} && git merge #{sha} 2>&1"
  self.logger.log merge_response
  return :success if exit_code.zero?
  return :conflict if merge_response.match(/CONFLICT/)
  
  raise "Boom goes the dynamite!  Failure to do the merge in a non-predicatable way."
end