Skip to content

Commit

Permalink
script/build creates bin/hub executable by default
Browse files Browse the repository at this point in the history
  • Loading branch information
mislav committed Jan 24, 2016
1 parent 0a789d7 commit d5aa903
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 10 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
*.swp
*~
/hub
/bin
.bundle
vendor/bundle/
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ To install `hub` from source, you need to have a [Go development environment](ht
~~~ sh
$ git clone https://github.com/github/hub.git
$ cd hub
$ ./script/build
$ cp hub YOUR_BIN_PATH
# Assuming `~/bin` is in your PATH:
$ ./script/build -o ~/bin/hub
~~~

Or, if you've done Go development before and your $GOPATH/bin
Expand Down
21 changes: 14 additions & 7 deletions script/build
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
#!/usr/bin/env bash
# Usage: script/build [-o output] [test]
# Usage: script/build [-o <EXE>]
# script/build test
#
# Sets up GOPATH and compiles hub. With `test`, runs tests instead.
# Sets up GOPATH and compiles hub to <EXE> (default: `bin/hub`).
#
# With `test`, runs tests instead.

set -e

Expand Down Expand Up @@ -47,21 +50,25 @@ up_to_date() {

build_hub() {
setup_gopath
[ -n "$1" ] && (up_to_date "$1" || go build -ldflags "-X github.com/github/hub/version.Version=`./script/version`" -o "$1")
mkdir -p "$(dirname "$1")"
up_to_date "$1" || go build -ldflags "-X github.com/github/hub/version.Version=`./script/version`" -o "$1"
}

test_hub() {
setup_gopath
find_packages | xargs go test
}

[ $# -gt 0 ] || set -- -o "bin/hub${windows:+.exe}"

case "$1" in
"" )
build_hub hub${windows:+.exe}
;;
-o )
shift
build_hub $1
if [ -z "$1" ]; then
echo "error: argument needed for \`-o'" >&2
exit 1
fi
build_hub "$1"
;;
test )
test_hub
Expand Down

0 comments on commit d5aa903

Please sign in to comment.