Module: GitRepositoryExtension

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

Instance Method Summary collapse

Instance Method Details

#git?Boolean

Returns:

  • (Boolean)

8
9
10
# File 'Library/Homebrew/extend/git_repository.rb', line 8

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

#git_branchObject


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

def git_branch
  return unless git? && Utils::Git.available?

  Utils.popen_read("git", "rev-parse", "--abbrev-ref", "HEAD", chdir: self).chomp.presence
end

#git_headObject


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

def git_head
  return unless git? && Utils::Git.available?

  Utils.popen_read("git", "rev-parse", "--verify", "-q", "HEAD", chdir: self).chomp.presence
end

#git_last_commitObject


36
37
38
39
40
# File 'Library/Homebrew/extend/git_repository.rb', line 36

def git_last_commit
  return unless git? && Utils::Git.available?

  Utils.popen_read("git", "show", "-s", "--format=%cr", "HEAD", chdir: self).chomp.presence
end

#git_last_commit_dateObject


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

def git_last_commit_date
  return unless git? && Utils::Git.available?

  Utils.popen_read("git", "show", "-s", "--format=%cd", "--date=short", "HEAD", chdir: self).chomp.presence
end

#git_originObject


12
13
14
15
16
# File 'Library/Homebrew/extend/git_repository.rb', line 12

def git_origin
  return unless git? && Utils::Git.available?

  Utils.popen_read("git", "config", "--get", "remote.origin.url", chdir: self).chomp.presence
end

#git_origin=(origin) ⇒ Object


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

def git_origin=(origin)
  return unless git? && Utils::Git.available?

  safe_system "git", "remote", "set-url", "origin", origin, chdir: self
end

#git_short_headObject


30
31
32
33
34
# File 'Library/Homebrew/extend/git_repository.rb', line 30

def git_short_head
  return unless git? && Utils::Git.available?

  Utils.popen_read("git", "rev-parse", "--short=4", "--verify", "-q", "HEAD", chdir: self).chomp.presence
end