aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/tap.rb
diff options
context:
space:
mode:
authorMartin Afanasjew2016-07-02 09:43:12 +0200
committerMartin Afanasjew2016-07-07 01:46:58 +0200
commit68bbe6ee5fc723f154d4a2372997d5bd9682a554 (patch)
tree07bdb7e161e7517586726a29be7e2bedafd0b3e7 /Library/Homebrew/tap.rb
parent77dd9d56ff39f77391d2f429a9ff25e65a362ba2 (diff)
downloadbrew-68bbe6ee5fc723f154d4a2372997d5bd9682a554.tar.bz2
Use GitRepositoryExtension for 'path' in Tap
Closes #464. Signed-off-by: Martin Afanasjew <martin@afanasjew.de>
Diffstat (limited to 'Library/Homebrew/tap.rb')
-rw-r--r--Library/Homebrew/tap.rb26
1 files changed, 8 insertions, 18 deletions
diff --git a/Library/Homebrew/tap.rb b/Library/Homebrew/tap.rb
index 9640c4948..0b10f20c0 100644
--- a/Library/Homebrew/tap.rb
+++ b/Library/Homebrew/tap.rb
@@ -62,6 +62,7 @@ class Tap
@repo = repo
@name = "#{@user}/#{@repo}".downcase
@path = TAP_DIRECTORY/"#{@user}/homebrew-#{@repo}".downcase
+ @path.extend(GitRepositoryExtension)
end
# clear internal cache
@@ -84,15 +85,8 @@ class Tap
# The remote path to this {Tap}.
# e.g. `https://github.com/user/homebrew-repo`
def remote
- @remote ||= if installed?
- if git? && Utils.git_available?
- path.cd do
- Utils.popen_read("git", "config", "--get", "remote.origin.url").chomp
- end
- end
- else
- raise TapUnavailableError, name
- end
+ raise TapUnavailableError, name unless installed?
+ @remote ||= path.git_origin
end
# The default remote path to this {Tap}.
@@ -102,35 +96,31 @@ class Tap
# True if this {Tap} is a git repository.
def git?
- (path/".git").exist?
+ path.git?
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 }
+ path.git_head
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 }
+ path.git_short_head
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 }
+ path.git_last_commit
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 }
+ path.git_last_commit_date
end
# The issues URL of this {Tap}.