Class: NliPipeline::GitManager
- Inherits:
-
SystemWrapper::CallWrapper
- Object
- SystemWrapper::CallWrapper
- NliPipeline::GitManager
- Defined in:
- lib/nli_pipeline/git_manager.rb
Overview
simple class for managing git commands
Instance Attribute Summary
Attributes inherited from SystemWrapper::CallWrapper
Instance Method Summary collapse
-
#branch ⇒ String
Current branch.
-
#last_commit ⇒ String
Full length hash of last commit.
-
#last_commit_message ⇒ String
Full messaage for last commit, all as one line.
-
#last_commit_url ⇒ String
Full url to commit.
-
#remote(upstream: 'origin') ⇒ String
Url for git remote origin.
Methods inherited from SystemWrapper::CallWrapper
#call_system, #initialize, required_args, supported_args
Methods included from AbstractUtil
#add_attrs, #drop_forbidden_args_message, included, #init_with_attrs, #raise_unless_all, #to_s
Constructor Details
This class inherits a constructor from NliPipeline::SystemWrapper::CallWrapper
Instance Method Details
#branch ⇒ String
Returns current branch.
28 29 30 |
# File 'lib/nli_pipeline/git_manager.rb', line 28 def branch call_system('git symbolic-ref --short HEAD', return_output: true) end |
#last_commit ⇒ String
Returns full length hash of last commit.
18 19 20 |
# File 'lib/nli_pipeline/git_manager.rb', line 18 def last_commit call_system("git log -1 --pretty=format:'%H'", return_output: true) end |
#last_commit_message ⇒ String
Returns full messaage for last commit, all as one line.
23 24 25 |
# File 'lib/nli_pipeline/git_manager.rb', line 23 def call_system('git log -1 --format=%B --oneline', return_output: true) end |
#last_commit_url ⇒ String
Returns full url to commit.
7 8 9 |
# File 'lib/nli_pipeline/git_manager.rb', line 7 def last_commit_url "#{remote}/commits/#{last_commit}" end |
#remote(upstream: 'origin') ⇒ String
Returns url for git remote origin.
13 14 15 |
# File 'lib/nli_pipeline/git_manager.rb', line 13 def remote(upstream: 'origin') call_system("git ls-remote --get-url #{upstream}", return_output: true) end |