提交 74641813 编写于 作者: J Jingwen Owen Ou

Merge pull request jingweno/gh:155 from jingweno/enable_bash_completion_test

Enable bash completion tests on Travis
before_install:
- sudo apt-get update -qq
- sudo apt-get install -qq zsh git
- rvm use 2.1.0 --install --binary --fuzzy
- export BUNDLE_GEMFILE=$PWD/Gemfile
- ruby --version
- rvm --version
- gem --version
- sudo apt-get update -qq
- sudo apt-get install -qq tmux zsh git
language: go
go:
- 1.2
......@@ -16,7 +16,7 @@ install:
script:
- script/build
- script/test
- bundle exec rake features
- script/ruby-test
env:
global:
- AMAZON_S3_BUCKET=gh-bundler-cache
......
......@@ -2,18 +2,34 @@ package commands
import (
"fmt"
"github.com/jingweno/gh/utils"
"os"
"strings"
)
var cmdHelp = &Command{
Usage: "help [command]",
Short: "Show help",
Long: `Shows usage for a command.`,
Usage: "help [command]",
Short: "Show help",
Long: `Shows usage for a command.`,
GitExtension: true,
}
var (
customCommands = []string{
"alias",
"create",
"browse",
"compare",
"fork",
"pull-request",
"ci-status",
"release",
"issue",
"update",
}
)
func init() {
cmdHelp.Run = runHelp // break init loop
cmdHelp.Run = runHelp
CmdRunner.Use(cmdHelp)
}
......@@ -24,10 +40,6 @@ func runHelp(cmd *Command, args *Args) {
os.Exit(0)
}
if args.ParamsSize() > 1 {
utils.Check(fmt.Errorf("too many arguments"))
}
for _, cmd := range CmdRunner.All() {
if cmd.Name() == args.FirstParam() {
cmd.PrintUsage()
......@@ -35,8 +47,24 @@ func runHelp(cmd *Command, args *Args) {
}
}
fmt.Fprintf(os.Stderr, "Unknown help topic: %q. Run 'git help'.\n", args.FirstParam())
os.Exit(2)
if parseHelpAllFlag(args) {
args.After("echo", "\ngh custom commands\n")
args.After("echo", " ", strings.Join(customCommands, " "))
}
}
func parseHelpAllFlag(args *Args) bool {
i := args.IndexOfParam("-a")
if i != -1 {
return true
}
i = args.IndexOfParam("--all")
if i != -1 {
return true
}
return false
}
var helpText = `usage: git [--version] [--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]
......
#!/usr/bin/env bash
set -e
STATUS=0
warnings="${TMPDIR:-/tmp}/gh-warnings.$$"
run() {
# Save warnings on stderr to a separate file
RUBYOPT="$RUBYOPT -w" bundle exec "$@" \
2> >(tee >(grep 'warning:' >>"$warnings") | grep -v 'warning:') || STATUS=$?
}
check_warnings() {
# Display Ruby warnings from this project's source files. Abort if any were found.
num="$(grep -F "$PWD" "$warnings" | grep -v "${PWD}/vendor/bundle" | sort | uniq -c | sort -rn | tee /dev/stderr | wc -l)"
rm -f "$warnings"
if [ "$num" -gt 0 ]; then
echo "FAILED: this test suite doesn't tolerate Ruby syntax warnings!" >&2
exit 1
fi
}
if tmux -V; then
if [ -n "$CI" ]; then
git --version
bash --version | head -1
zsh --version
echo
fi
profile="all"
else
echo "warning: skipping shell completion tests (install tmux to enable)" >&2
profile="default"
fi
run cucumber -p "$profile" -t ~@wip
check_warnings
exit $STATUS
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册