提交 aef16d85 编写于 作者: S Stephen Celis 提交者: Chris Wanstrath

Use cat for pager by default.

上级 74d66aa6
......@@ -290,10 +290,13 @@ module Hub
# $ hub help
# (print improved help text)
def help(args)
if args[1] == 'hub'
command = args.grep(/^[^-]/)[1]
if command == 'hub'
puts hub_manpage
exit
elsif args.size == 1
elsif command.nil?
ENV['GIT_PAGER'] = '' if args.grep(/^-{1,2}p/).empty? # Use `cat`.
puts improved_help_text
exit
end
......
......@@ -11,7 +11,7 @@ module Hub
@args = Args.new(args)
# Hack to emulate git-style
@args[0] = 'help' if @args.empty?
@args.unshift 'help' if @args.grep(/^[^-]|version/).empty?
if Commands.respond_to?(@args[0])
Commands.send(@args[0], @args)
......
......@@ -169,7 +169,7 @@ class HubTest < Test::Unit::TestCase
def test_version
out = hub('--version')
assert_includes "git version 1.6", out
assert_includes "git version", out
assert_includes "hub version #{Hub::Version}", out
end
......@@ -181,6 +181,10 @@ class HubTest < Test::Unit::TestCase
assert_equal Hub::Commands.improved_help_text, hub("")
end
def test_help_with_pager
assert_equal Hub::Commands.improved_help_text, hub("-p")
end
def test_help_hub
help_manpage = hub("help hub")
assert_includes "git + hub = github", help_manpage
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册