Class: GitRepository

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

Instance Method Summary collapse

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_nameObject



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_messageObject



10
11
12
# File 'lib/git_repository.rb', line 10

def top_commit_message 
  run_in_subshell("git log -1 --pretty=format:'%s'")
end