提交 00e1b995 编写于 作者: M Mislav Marohnić

Remove obsolete build steps

This was from the time when we tried to have hub build even if it wasn't
checkout out within a local GOPATH. This change assumes a working Go
environment.
上级 e8a7d796
SOURCES = $(shell script/build files)
SOURCES_FMT = $(shell script/build files | cut -d/ -f1-2 | sort -u)
MIN_COVERAGE = 89.4
......@@ -35,15 +34,11 @@ HELP_ALL = share/man/man1/hub.1 $(HELP_CMD) $(HELP_EXT)
TEXT_WIDTH = 87
.PHONY: clean test test-all man-pages fmt install
all: bin/hub
bin/hub: $(SOURCES)
script/build -o $@
test:
script/build test
go test ./...
test-all: bin/cucumber
ifdef CI
......@@ -56,8 +51,7 @@ bin/ronn bin/cucumber:
script/bootstrap
fmt:
go fmt $(filter %.go,$(SOURCES_FMT))
go fmt $(filter-out %.go,$(SOURCES_FMT))
go fmt ./...
man-pages: $(HELP_ALL:=.ronn) $(HELP_ALL) $(HELP_ALL:=.txt)
......@@ -78,3 +72,5 @@ install: bin/hub man-pages
clean:
git clean -fdx bin share/man
.PHONY: clean test test-all man-pages fmt install
......@@ -16,8 +16,6 @@ if [ -n "$TRAVIS" ] && [ ! -x ~/bin/tmux ]; then
curl -fsSL "https://${AMAZON_S3_BUCKET}.s3.amazonaws.com/${cache_name}.tgz" | tar -xz -C ~
fi
script/build check || STATUS=1
{ ruby --version
if [ -n "$TRAVIS" ]; then
script/cached-bundle install --deployment --jobs=3 --retry=3 --path bundle
......
#!/usr/bin/env bash
# vi:ft=sh:
# Usage: script/build [-o <EXE>]
# script/build test
#
# Sets up GOPATH and compiles hub to <EXE> (default: `bin/hub`).
#
# With `test`, runs tests instead.
# Usage: script/build [-o <BIN>]
# script/build files
set -e
windows=
[[ $OS == Windows* ]] && windows=1
setup_gopath() {
TMPDIR="${LOCALAPPDATA:-$TMPDIR}"
TMPDIR=${TMPDIR:-/tmp}
TMP_GOPATH="${TMPDIR%/}/go"
TMP_SELF="${TMP_GOPATH}/src/github.com/github/hub"
if [ -n "$windows" ]; then
export GOPATH="${TMP_GOPATH//\//\\}"
else
export GOPATH="$TMP_GOPATH"
fi
mkdir -p "${TMP_SELF%/*}"
ln -snf "$PWD" "$TMP_SELF" 2>/dev/null || {
rm -rf "$TMP_SELF"
mkdir "$TMP_SELF"
cp -R "$PWD"/* "${TMP_SELF}/"
}
}
find_source_files() {
find . -maxdepth 2 -name '*.go' '!' -name '*_test.go' "$@"
}
find_packages() {
find_source_files | cut -d/ -f2 | sort -u | grep -v '.go$' | sed 's!^!github.com/github/hub/!'
}
check_go_version() {
local version="$(go version)"
local minor="$(grep -o 'go1.[[:digit:]]\+' <<<"$version" | head -1)"
[ -z "$version" ] || echo "$version"
if [[ -z "$version" || -n "$minor" && "${minor##*.}" -lt 8 ]]; then
echo "You need to install Go 1.8 or higher to build hub" >&2
return 1
fi
}
build_hub() {
check_go_version >/dev/null
setup_gopath
mkdir -p "$(dirname "$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
-o )
shift
if [ -z "$1" ]; then
echo "error: argument needed for \`-o'" >&2
exit 1
fi
build_hub "$1"
;;
test )
test_hub
build_hub "${2?}"
;;
files )
find_source_files
;;
check )
check_go_version
;;
-h | --help )
sed -ne '/^#/!q;s/.\{1,2\}//;1,2d;p' < "$0"
sed -ne '/^#/!q;s/.\{1,2\}//;1d;p' < "$0"
exit
;;
* )
......
......@@ -33,7 +33,7 @@ trap "exit 1" INT
[ -z "$HUB_COVERAGE" ] || script/coverage prepare
script/build
script/build test || STATUS="$?"
go test ./... || STATUS="$?"
script/ruby-test "$@" || STATUS="$?"
if [ -n "$HUB_COVERAGE" ]; then
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册