зеркало из https://github.com/mislav/hub.git
44 строки
771 B
Bash
Executable File
44 строки
771 B
Bash
Executable File
#!/usr/bin/env bash
|
|
# Usage: script/build [-o output] [test]
|
|
#
|
|
# Sets up GOPATH and compiles hub. With `test`, runs tests instead.
|
|
|
|
set -e
|
|
|
|
find_source_files() {
|
|
find . -maxdepth 2 -name '*.go' -not -name '*_test.go' "$@"
|
|
}
|
|
|
|
count_changed_files() {
|
|
printf %d $(find_source_files -newer "$1" | wc -l)
|
|
}
|
|
|
|
up_to_date() {
|
|
[ -e "$1" ] && [ "$(count_changed_files "$1")" -eq 0 ]
|
|
}
|
|
|
|
build_hub() {
|
|
[ -n "$1" ] && (up_to_date "$1" || ./script/godep go build -o "$1" --tags noupdate)
|
|
}
|
|
|
|
case "$1" in
|
|
"" )
|
|
# always build with noupdate for now until Hub 2.0 is released
|
|
build_hub hub
|
|
;;
|
|
-o )
|
|
shift
|
|
build_hub $1
|
|
;;
|
|
test )
|
|
./script/godep go test ./...
|
|
;;
|
|
-h | --help )
|
|
sed -ne '/^#/!q;s/.\{1,2\}//;1d;p' < "$0"
|
|
exit
|
|
;;
|
|
* )
|
|
"$0" --help >&2
|
|
exit 1
|
|
esac
|