Module: GitRepositoryExtension

Defined in:
Library/Homebrew/extend/git_repository.rb

Instance Method Summary collapse

Instance Method Details

#git?Boolean

Returns:

  • (Boolean)


5
6
7
# File 'Library/Homebrew/extend/git_repository.rb', line 5

def git?
  join(".git").exist?
end

#git_branchObject



39
40
41
42
43
44
45
46
# File 'Library/Homebrew/extend/git_repository.rb', line 39

def git_branch
  return unless git? && Utils.git_available?
  cd do
    Utils.popen_read(
      "git", "rev-parse", "--abbrev-ref", "HEAD"
    ).chuzzle
  end
end

#git_headObject



16
17
18
19
20
21
# File 'Library/Homebrew/extend/git_repository.rb', line 16

def git_head
  return unless git? && Utils.git_available?
  cd do
    Utils.popen_read("git", "rev-parse", "--verify", "-q", "HEAD").chuzzle
  end
end

#git_last_commitObject



32
33
34
35
36
37
# File 'Library/Homebrew/extend/git_repository.rb', line 32

def git_last_commit
  return unless git? && Utils.git_available?
  cd do
    Utils.popen_read("git", "show", "-s", "--format=%cr", "HEAD").chuzzle
  end
end

#git_last_commit_dateObject



48
49
50
51
52
53
54
55
# File 'Library/Homebrew/extend/git_repository.rb', line 48

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

#git_originObject



9
10
11
12
13
14
# File 'Library/Homebrew/extend/git_repository.rb', line 9

def git_origin
  return unless git? && Utils.git_available?
  cd do
    Utils.popen_read("git", "config", "--get", "remote.origin.url").chuzzle
  end
end

#git_short_headObject



23
24
25
26
27
28
29
30
# File 'Library/Homebrew/extend/git_repository.rb', line 23

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