Class: GitRepository
- Inherits:
-
Object
- Object
- GitRepository
- Defined in:
- lib/git_repository.rb
Instance Method Summary collapse
- #checkout_branch(name) ⇒ Object
- #current_branch_name ⇒ Object
-
#initialize(workspace) ⇒ GitRepository
constructor
A new instance of GitRepository.
- #run_in_subshell(command) ⇒ Object
- #top_commit_message ⇒ Object
Constructor Details
#initialize(workspace) ⇒ GitRepository
Returns a new instance of GitRepository.
2 3 4 |
# File 'lib/git_repository.rb', line 2 def initialize(workspace) @workspace = workspace end |
Instance Method Details
#checkout_branch(name) ⇒ Object
6 7 8 |
# File 'lib/git_repository.rb', line 6 def checkout_branch (name) run_in_subshell("git checkout #{name}") end |
#current_branch_name ⇒ Object
14 15 16 |
# File 'lib/git_repository.rb', line 14 def current_branch_name run_in_subshell("git rev-parse --abbrev-ref HEAD").strip end |
#run_in_subshell(command) ⇒ Object
18 19 20 21 |
# File 'lib/git_repository.rb', line 18 def run_in_subshell (command) subshell = Subshell.new @workspace subshell.run command end |
#top_commit_message ⇒ Object
10 11 12 |
# File 'lib/git_repository.rb', line 10 def run_in_subshell("git log -1 --pretty=format:'%s'") end |