Commit 1df99f2bc6d2d3d10d6b1bbc8bdbb30057e74f6d
Merge pull request #123 from paxan/dont-die-when-head-is-detached
Don't panic if your HEAD is detached
Showing 1 changed file Side-by-side Diff
script/boxen
... | ... | @@ -39,10 +39,12 @@ |
39 | 39 | upstream_changes = `git rev-list --count master..origin/master`.chomp != '0' |
40 | 40 | fast_forwardable = `git rev-list --count origin/master..master`.chomp == '0' |
41 | 41 | |
42 | - short_branch = current_branch.split('/')[2..-1].join('/') | |
43 | - | |
44 | - if !master | |
45 | - warn "Boxen on a non-master branch '#{short_branch}', won't auto-update!" | |
42 | + if current_branch.empty? | |
43 | + ref = `git log -1 --pretty=format:%h` | |
44 | + warn "Boxen not currently on any branch (ref: #{ref}), won't auto-update!" | |
45 | + elsif !master | |
46 | + local_branch = current_branch.split('/')[2..-1].join('/') | |
47 | + warn "Boxen on a non-master branch '#{local_branch}', won't auto-update!" | |
46 | 48 | elsif !fast_forwardable |
47 | 49 | warn "Boxen's master branch is out of sync, won't auto-update!" |
48 | 50 | elsif !clean |