1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
  | 
require "utils/git"
require "utils/popen"
module GitRepositoryExtension
  def git?
    join(".git").exist?
  end
  def git_origin
    return unless git? && Utils.git_available?
    cd do
      Utils.popen_read("git", "config", "--get", "remote.origin.url").chuzzle
    end
  end
  def git_head
    return unless git? && Utils.git_available?
    cd do
      Utils.popen_read("git", "rev-parse", "--verify", "-q", "HEAD").chuzzle
    end
  end
  def git_short_head
    return unless git? && Utils.git_available?
    cd do
      Utils.popen_read(
        "git", "rev-parse", "--short=4", "--verify", "-q", "HEAD"
      ).chuzzle
    end
  end
  def git_last_commit
    return unless git? && Utils.git_available?
    cd do
      Utils.popen_read("git", "show", "-s", "--format=%cr", "HEAD").chuzzle
    end
  end
  def git_last_commit_date
    return unless git? && Utils.git_available?
    cd do
      Utils.popen_read(
        "git", "show", "-s", "--format=%cd", "--date=short", "HEAD"
      ).chuzzle
    end
  end
end
  |