Class: GitCommandLine
- Inherits:
-
Object
- Object
- GitCommandLine
- Defined in:
- lib/travis_github_deployer/git_command_line.rb
Instance Method Summary collapse
- #add(filename) ⇒ Object
- #clone(repository, destination) ⇒ Object
- #commit(message) ⇒ Object
- #config(key, value) ⇒ Object
- #config_credential_helper_store_file(filename) ⇒ Object
- #config_email(email) ⇒ Object
- #config_username(username) ⇒ Object
- #do_system(command) ⇒ Object
- #git(command) ⇒ Object
- #previous_command_success ⇒ Object
- #push ⇒ Object
- #verbose ⇒ Object
- #verbose=(value) ⇒ Object
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() git("commit -m \"#{}\"") 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
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_success ⇒ Object
58 59 60 |
# File 'lib/travis_github_deployer/git_command_line.rb', line 58 def previous_command_success $?.success? end |
#push ⇒ Object
21 22 23 |
# File 'lib/travis_github_deployer/git_command_line.rb', line 21 def push git("push") end |
#verbose ⇒ Object
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 |