From 549f113930b5332ce74cb0c2494394c743b41d07 Mon Sep 17 00:00:00 2001 From: Pavel Repin Date: Tue, 5 Mar 2013 12:23:38 -0800 Subject: [PATCH 1/2] Don't die if HEAD ref is not symbolic. Examples of situations when HEAD is not symbolic: * You're doing interactive rebase * You're using git bisect * ... and so on. --- script/boxen | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/script/boxen b/script/boxen index 9597ee6..293f805 100755 --- a/script/boxen +++ b/script/boxen @@ -39,9 +39,12 @@ unless ENV["BOXEN_NO_PULL"] || ARGV.include?("--no-pull") upstream_changes = `git rev-list --count master..origin/master`.chomp != '0' fast_forwardable = `git rev-list --count origin/master..master`.chomp == '0' - short_branch = current_branch.split('/')[2..-1].join('/') - if !master + short_branch = if current_branch.empty? + `git log -1 --pretty=format:%h` + else + current_branch.split('/')[2..-1].join('/') + end warn "Boxen on a non-master branch '#{short_branch}', won't auto-update!" elsif !fast_forwardable warn "Boxen's master branch is out of sync, won't auto-update!" From 9c3b1691563b10fc4fdf788202da0c1e943830ee Mon Sep 17 00:00:00 2001 From: Pavel Repin Date: Tue, 5 Mar 2013 13:57:03 -0800 Subject: [PATCH 2/2] It's cleaner to have another case: "not on any branch". --- script/boxen | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/script/boxen b/script/boxen index 293f805..e856a7a 100755 --- a/script/boxen +++ b/script/boxen @@ -39,13 +39,12 @@ unless ENV["BOXEN_NO_PULL"] || ARGV.include?("--no-pull") upstream_changes = `git rev-list --count master..origin/master`.chomp != '0' fast_forwardable = `git rev-list --count origin/master..master`.chomp == '0' - if !master - short_branch = if current_branch.empty? - `git log -1 --pretty=format:%h` - else - current_branch.split('/')[2..-1].join('/') - end - warn "Boxen on a non-master branch '#{short_branch}', won't auto-update!" + if current_branch.empty? + ref = `git log -1 --pretty=format:%h` + warn "Boxen not currently on any branch (ref: #{ref}), won't auto-update!" + elsif !master + local_branch = current_branch.split('/')[2..-1].join('/') + warn "Boxen on a non-master branch '#{local_branch}', won't auto-update!" elsif !fast_forwardable warn "Boxen's master branch is out of sync, won't auto-update!" elsif !clean