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

Merge pull request #686 from github/build_version

Include git tag SHA in build
......@@ -8,7 +8,7 @@ import (
"github.com/github/hub/utils"
)
const Version = "2.2.0-preview1"
var Version = "2.2.0-preview1"
var cmdVersion = &Command{
Run: runVersion,
......
......@@ -5,6 +5,18 @@
set -e
setup_gopath() {
TMP_GOPATH="${TMPDIR:-/tmp}/go"
TMP_SELF="${TMP_GOPATH}/src/github.com/github/hub"
export GOPATH="${TMP_GOPATH}:${PWD}/Godeps/_workspace:$GOPATH"
if [ ! -e "$TMP_SELF" ]; then
mkdir -p "${TMP_SELF%/*}"
ln -snf "$PWD" "$TMP_SELF"
fi
}
find_source_files() {
find . -maxdepth 2 -name '*.go' -not -name '*_test.go' "$@"
}
......@@ -18,7 +30,13 @@ up_to_date() {
}
build_hub() {
[ -n "$1" ] && (up_to_date "$1" || ./script/godep go build -o "$1" --tags noupdate)
setup_gopath
[ -n "$1" ] && (up_to_date "$1" || go build -tags "noupdate" -ldflags "-X github.com/github/hub/commands.Version `./script/version`" -o "$1")
}
test_hub() {
setup_gopath
go test ./...
}
case "$1" in
......@@ -31,7 +49,7 @@ case "$1" in
build_hub $1
;;
test )
./script/godep go test ./...
test_hub
;;
-h | --help )
sed -ne '/^#/!q;s/.\{1,2\}//;1d;p' < "$0"
......
#!/usr/bin/env bash
# Usage: script/build [test]
#
# Sets up GOPATH and run command
set -e
TMP_GOPATH="${TMPDIR:-/tmp}/go"
TMP_SELF="${TMP_GOPATH}/src/github.com/github/hub"
export GOPATH="${TMP_GOPATH}:${PWD}/Godeps/_workspace:$GOPATH"
if [ ! -e "$TMP_SELF" ]; then
mkdir -p "${TMP_SELF%/*}"
ln -snf "$PWD" "$TMP_SELF"
fi
$@
#!/usr/bin/env ruby
# Usage: script/version
#
# Displays hub's release version
version = `git describe --tags HEAD 2>/dev/null`.chomp
version = if version.empty?
content = File.read('commands/version.go')
version = content[/^var Version = "(.+)"/, 1]
head_sha = `git rev-parse --short HEAD 2>/dev/null`.chomp
version += "-g#{head_sha}" unless head_sha.empty?
version
else
version.sub(/^v/, '')
end
puts version
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册