diff options
| author | Xu Cheng | 2016-03-05 20:03:43 +0800 |
|---|---|---|
| committer | Xu Cheng | 2016-03-06 13:51:06 +0800 |
| commit | 9f96e41b40f52313fbc7832df631827f5e3bcacb (patch) | |
| tree | cdaabac2acce883a57092bf13e85c61e70129b11 /Library/Homebrew/tap.rb | |
| parent | a2d0d88bf1915734e1540bef4c9d6c1b403379c7 (diff) | |
| download | brew-9f96e41b40f52313fbc7832df631827f5e3bcacb.tar.bz2 | |
tap: add methods to get git related information
These methods will be used in `brew --version`, `brew config`
and `brew doctor` after core/formula separation.
Closes Homebrew/homebrew#49796.
Signed-off-by: Xu Cheng <xucheng@me.com>
Diffstat (limited to 'Library/Homebrew/tap.rb')
| -rw-r--r-- | Library/Homebrew/tap.rb | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/Library/Homebrew/tap.rb b/Library/Homebrew/tap.rb index 8519a3c6d..8958e3b11 100644 --- a/Library/Homebrew/tap.rb +++ b/Library/Homebrew/tap.rb @@ -83,7 +83,7 @@ class Tap # e.g. `https://github.com/user/homebrew-repo` def remote @remote ||= if installed? - if git? + if git? && Utils.git_available? path.cd do Utils.popen_read("git", "config", "--get", "remote.origin.url").chomp end @@ -98,6 +98,34 @@ class Tap (path/".git").exist? end + # git HEAD for this {Tap}. + def git_head + raise TapUnavailableError, name unless installed? + return unless git? && Utils.git_available? + path.cd { Utils.popen_read("git", "rev-parse", "--verify", "-q", "HEAD").chuzzle } + end + + # git HEAD in short format for this {Tap}. + def git_short_head + raise TapUnavailableError, name unless installed? + return unless git? && Utils.git_available? + path.cd { Utils.popen_read("git", "rev-parse", "--short=4", "--verify", "-q", "HEAD").chuzzle } + end + + # time since git last commit for this {Tap}. + def git_last_commit + raise TapUnavailableError, name unless installed? + return unless git? && Utils.git_available? + path.cd { Utils.popen_read("git", "show", "-s", "--format=%cr", "HEAD").chuzzle } + end + + # git last commit date for this {Tap}. + def git_last_commit_date + raise TapUnavailableError, name unless installed? + return unless git? && Utils.git_available? + path.cd { Utils.popen_read("git", "show", "-s", "--format=%cd", "--date=short", "HEAD").chuzzle } + end + # The issues URL of this {Tap}. # e.g. `https://github.com/user/homebrew-repo/issues` def issues_url |
