Module: Git::Whence::CLI

Defined in:
lib/git/whence.rb

Class Method Summary collapse

Class Method Details

.run(argv) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/git/whence.rb', line 7

def run(argv)
  options = parse_options(argv)
  commit = argv[0]
  unless system("git rev-parse --git-dir 2>&1 >/dev/null")
    puts "Not in a git directory"
    return 1
  end

  if is_merge?(commit)
    $stderr.puts "Commit is a merge"
    finished_with_commit(commit, options)
    1
  else
    merge = find_merge(commit)
    if merge
      finished_with_commit(merge, options)
      0
    else
      $stderr.puts "Unable to find merge"
      1
    end
  end
end