Class: GitCommandLine

Inherits:
Object
  • Object
show all
Defined in:
lib/travis_github_deployer/git_command_line.rb

Instance Method Summary collapse

Instance Method Details

#add(filename) ⇒ Object



13
14
15
# File 'lib/travis_github_deployer/git_command_line.rb', line 13

def add(filename)
  git("add #{filename}")
end

#clone(repository, destination) ⇒ Object



5
6
7
# File 'lib/travis_github_deployer/git_command_line.rb', line 5

def clone(repository, destination)
  git("clone " + repository + " " + destination)
end

#commit(message) ⇒ Object



17
18
19
# File 'lib/travis_github_deployer/git_command_line.rb', line 17

def commit(message)
  git("commit -m \"#{message}\"")
end

#config(key, value) ⇒ Object



9
10
11
# File 'lib/travis_github_deployer/git_command_line.rb', line 9

def config(key, value)
  git("config #{key} '#{value}'")
end

#config_credential_helper_store_file(filename) ⇒ Object



33
34
35
# File 'lib/travis_github_deployer/git_command_line.rb', line 33

def config_credential_helper_store_file(filename)
  config("credential.helper", "store --file=#{filename}")
end

#config_email(email) ⇒ Object



29
30
31
# File 'lib/travis_github_deployer/git_command_line.rb', line 29

def config_email(email)
  config("user.email", email)
end

#config_username(username) ⇒ Object



25
26
27
# File 'lib/travis_github_deployer/git_command_line.rb', line 25

def config_username(username)
  config("user.name", username)
end

#do_system(command) ⇒ Object



54
55
56
# File 'lib/travis_github_deployer/git_command_line.rb', line 54

def do_system(command)
  `#{command}`
end

#git(command) ⇒ Object

Raises:

  • (StandardError)


45
46
47
48
49
50
51
52
# File 'lib/travis_github_deployer/git_command_line.rb', line 45

def git(command)
  git_command = "git #{command}"
  puts("command: #{git_command}") if verbose
  output = do_system("#{git_command} 2>&1")
  puts("output: #{output}") if verbose
  raise StandardError, "Git command: '#{command}' failed. Message: : " + output unless previous_command_success
  output
end

#previous_command_successObject



58
59
60
# File 'lib/travis_github_deployer/git_command_line.rb', line 58

def previous_command_success
  $?.success?
end

#pushObject



21
22
23
# File 'lib/travis_github_deployer/git_command_line.rb', line 21

def push
  git("push")
end

#verboseObject



41
42
43
# File 'lib/travis_github_deployer/git_command_line.rb', line 41

def verbose
  @verbose
end

#verbose=(value) ⇒ Object



37
38
39
# File 'lib/travis_github_deployer/git_command_line.rb', line 37

def verbose=(value)
  @verbose = true
end