From 667023cc237a541618bd0719dfe721a35f450f67 Mon Sep 17 00:00:00 2001 From: Jingwen Owen Ou Date: Sun, 30 Nov 2014 15:11:39 -0800 Subject: [PATCH] Opt out autoupdate by default. This makes our build scripts even more simpler. To build with autoupdate, run `go build -tags autoupdate` --- commands/updater.go | 9 ++++++--- commands/updater_autoupdate.go | 7 +++++++ commands/updater_config_noupdate.go | 9 --------- commands/updater_test.go | 2 ++ script/build | 3 +-- script/package | 2 +- 6 files changed, 17 insertions(+), 15 deletions(-) create mode 100644 commands/updater_autoupdate.go delete mode 100644 commands/updater_config_noupdate.go diff --git a/commands/updater.go b/commands/updater.go index 61cfa35e..3ef8c31b 100644 --- a/commands/updater.go +++ b/commands/updater.go @@ -13,16 +13,18 @@ import ( "strings" "time" + goupdate "github.com/github/hub/Godeps/_workspace/src/github.com/inconshreveable/go-update" "github.com/github/hub/git" "github.com/github/hub/github" "github.com/github/hub/utils" - goupdate "github.com/github/hub/Godeps/_workspace/src/github.com/inconshreveable/go-update" ) const ( hubAutoUpdateConfig = "hub.autoUpdate" ) +var EnableAutoUpdate = false + func NewUpdater() *Updater { version := os.Getenv("GH_VERSION") if version == "" { @@ -256,9 +258,10 @@ func saveAutoUpdateConfiguration(confirm string, always bool) { } func autoUpdateConfig() (opt string) { - opt = os.Getenv("HUB_AUTOUPDATE") - if opt == "" { + if EnableAutoUpdate { opt, _ = git.GlobalConfig(hubAutoUpdateConfig) + } else { + opt = "never" } return diff --git a/commands/updater_autoupdate.go b/commands/updater_autoupdate.go new file mode 100644 index 00000000..a5bd17dd --- /dev/null +++ b/commands/updater_autoupdate.go @@ -0,0 +1,7 @@ +// +build autoupdate + +package commands + +func init() { + EnableAutoUpdate = true +} diff --git a/commands/updater_config_noupdate.go b/commands/updater_config_noupdate.go deleted file mode 100644 index 38446267..00000000 --- a/commands/updater_config_noupdate.go +++ /dev/null @@ -1,9 +0,0 @@ -// +build noupdate - -package commands - -import "os" - -func init() { - os.Setenv("HUB_AUTOUPDATE", "never") -} diff --git a/commands/updater_test.go b/commands/updater_test.go index 4f2c98bd..2d605cbd 100644 --- a/commands/updater_test.go +++ b/commands/updater_test.go @@ -93,9 +93,11 @@ func TestDoesntSaveNoAutoUpdateOption(t *testing.T) { } func checkSavedAutoUpdateOption(t *testing.T, always bool, confirm, expected string) { + EnableAutoUpdate = true repo := fixtures.SetupTestRepo() defer repo.TearDown() saveAutoUpdateConfiguration(confirm, always) assert.Equal(t, expected, autoUpdateConfig()) + EnableAutoUpdate = false } diff --git a/script/build b/script/build index f796054d..cef469f5 100755 --- a/script/build +++ b/script/build @@ -29,10 +29,9 @@ up_to_date() { [ -e "$1" ] && [ "$(count_changed_files "$1")" -eq 0 ] } -# always build with noupdate for now until Hub 2.0 is released build_hub() { setup_gopath - [ -n "$1" ] && (up_to_date "$1" || go build -tags "noupdate" -ldflags "-X github.com/github/hub/commands.Version `./script/version`" -o "$1") + [ -n "$1" ] && (up_to_date "$1" || go build -ldflags "-X github.com/github/hub/commands.Version `./script/version`" -o "$1") } test_hub() { diff --git a/script/package b/script/package index 0b1bc3df..61497960 100755 --- a/script/package +++ b/script/package @@ -114,7 +114,7 @@ class Packer def build_hub! puts "Building for #{OS.type}" release_version = `./script/version` - exec!("gox -os=#{OS.type} -output=./target/{{.Dir}}_#{version}_{{.OS}}_{{.Arch}}/{{.Dir}} -tags=noupdate -ldflags '-X github.com/github/hub/commands.Version #{release_version}'") + exec!("gox -os=#{OS.type} -output=./target/{{.Dir}}_#{version}_{{.OS}}_{{.Arch}}/{{.Dir}} -ldflags '-X github.com/github/hub/commands.Version #{release_version}'") end def cp_assets