Class: GitBlameGame

Inherits:
Object
  • Object
show all
Defined in:
lib/git-blame-game/git_blame_game.rb

Instance Method Summary collapse

Constructor Details

#initialize(path_to_file, opts = {}) ⇒ GitBlameGame

Returns a new instance of GitBlameGame.



2
3
4
5
# File 'lib/git-blame-game/git_blame_game.rb', line 2

def initialize(path_to_file, opts={})
  @path_to_file = path_to_file
  @sha = !opts[:sha].nil? ? opts[:sha] : 'HEAD'
end

Instance Method Details

#runObject



7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/git-blame-game/git_blame_game.rb', line 7

def run
  loop do
    p_flush("\n")

    sha_to_show = show_git_blame_and_prompt_for_sha

    p_flush("\n")
    files_changed = `git show --pretty="format:" --name-only #{sha_to_show}`.split("\n")[1..-1]

    @path_to_file = prompt_for_file(files_changed, sha_to_show)
    @sha = "#{sha_to_show}^"
  end
end