Use GitRepositoryExtension for 'path' in Tap
Closes #464. Signed-off-by: Martin Afanasjew <martin@afanasjew.de>
This commit is contained in:
parent
77dd9d56ff
commit
68bbe6ee5f
@ -62,6 +62,7 @@ class Tap
|
|||||||
@repo = repo
|
@repo = repo
|
||||||
@name = "#{@user}/#{@repo}".downcase
|
@name = "#{@user}/#{@repo}".downcase
|
||||||
@path = TAP_DIRECTORY/"#{@user}/homebrew-#{@repo}".downcase
|
@path = TAP_DIRECTORY/"#{@user}/homebrew-#{@repo}".downcase
|
||||||
|
@path.extend(GitRepositoryExtension)
|
||||||
end
|
end
|
||||||
|
|
||||||
# clear internal cache
|
# clear internal cache
|
||||||
@ -84,15 +85,8 @@ class Tap
|
|||||||
# The remote path to this {Tap}.
|
# The remote path to this {Tap}.
|
||||||
# e.g. `https://github.com/user/homebrew-repo`
|
# e.g. `https://github.com/user/homebrew-repo`
|
||||||
def remote
|
def remote
|
||||||
@remote ||= if installed?
|
raise TapUnavailableError, name unless installed?
|
||||||
if git? && Utils.git_available?
|
@remote ||= path.git_origin
|
||||||
path.cd do
|
|
||||||
Utils.popen_read("git", "config", "--get", "remote.origin.url").chomp
|
|
||||||
end
|
|
||||||
end
|
|
||||||
else
|
|
||||||
raise TapUnavailableError, name
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# The default remote path to this {Tap}.
|
# The default remote path to this {Tap}.
|
||||||
@ -102,35 +96,31 @@ class Tap
|
|||||||
|
|
||||||
# True if this {Tap} is a git repository.
|
# True if this {Tap} is a git repository.
|
||||||
def git?
|
def git?
|
||||||
(path/".git").exist?
|
path.git?
|
||||||
end
|
end
|
||||||
|
|
||||||
# git HEAD for this {Tap}.
|
# git HEAD for this {Tap}.
|
||||||
def git_head
|
def git_head
|
||||||
raise TapUnavailableError, name unless installed?
|
raise TapUnavailableError, name unless installed?
|
||||||
return unless git? && Utils.git_available?
|
path.git_head
|
||||||
path.cd { Utils.popen_read("git", "rev-parse", "--verify", "-q", "HEAD").chuzzle }
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# git HEAD in short format for this {Tap}.
|
# git HEAD in short format for this {Tap}.
|
||||||
def git_short_head
|
def git_short_head
|
||||||
raise TapUnavailableError, name unless installed?
|
raise TapUnavailableError, name unless installed?
|
||||||
return unless git? && Utils.git_available?
|
path.git_short_head
|
||||||
path.cd { Utils.popen_read("git", "rev-parse", "--short=4", "--verify", "-q", "HEAD").chuzzle }
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# time since git last commit for this {Tap}.
|
# time since git last commit for this {Tap}.
|
||||||
def git_last_commit
|
def git_last_commit
|
||||||
raise TapUnavailableError, name unless installed?
|
raise TapUnavailableError, name unless installed?
|
||||||
return unless git? && Utils.git_available?
|
path.git_last_commit
|
||||||
path.cd { Utils.popen_read("git", "show", "-s", "--format=%cr", "HEAD").chuzzle }
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# git last commit date for this {Tap}.
|
# git last commit date for this {Tap}.
|
||||||
def git_last_commit_date
|
def git_last_commit_date
|
||||||
raise TapUnavailableError, name unless installed?
|
raise TapUnavailableError, name unless installed?
|
||||||
return unless git? && Utils.git_available?
|
path.git_last_commit_date
|
||||||
path.cd { Utils.popen_read("git", "show", "-s", "--format=%cd", "--date=short", "HEAD").chuzzle }
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# The issues URL of this {Tap}.
|
# The issues URL of this {Tap}.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user