Module: GitRepositoryExtension

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

Instance Method Summary collapse

Instance Method Details

#git?Boolean

Returns:

  • (Boolean)

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

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

#git_branchObject


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

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


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

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


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

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


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

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


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

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


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

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

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

#git_short_headObject


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

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