提交 90e137a6 编写于 作者: M Mislav Marohnić

improve detecting whether we are currently in a git repo

上级 b053d573
......@@ -123,14 +123,6 @@ module Hub
GIT_CONFIG["config alias.#{name}"]
end
# Core.repositoryformatversion should exist for all git
# repositories, and be blank for all non-git repositories. If
# there's a better config setting to check here, this can be
# changed without breaking anything.
def is_repo?
GIT_CONFIG['config core.repositoryformatversion']
end
def github_url(options = {})
repo = options[:repo]
user, repo = repo.split('/') if repo && repo.index('/')
......@@ -169,6 +161,14 @@ module Hub
DIRNAME
end
def git_dir
GIT_CONFIG['rev-parse --git-dir']
end
def is_repo?
!!git_dir
end
# Cross-platform web browser command; respects the value set in $BROWSER.
#
# Returns an array, e.g.: ['open']
......
......@@ -46,7 +46,7 @@ class HubTest < Test::Unit::TestCase
'config branch.master.remote' => 'origin',
'config branch.master.merge' => 'refs/heads/master',
'config --bool hub.http-clone' => 'false',
'config core.repositoryformatversion' => '0'
'rev-parse --git-dir' => '.git'
)
super
end
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册