Commit 3b06d2616533629a7a85858e499762d3bed76075
1 parent
60851f970a
better error messages about auto updating
Showing 1 changed file with 12 additions and 5 deletions Side-by-side Diff
script/boxen
... | ... | @@ -29,12 +29,20 @@ |
29 | 29 | unless ENV["BOXEN_NO_PULL"] || ARGV.include?("--no-pull") |
30 | 30 | if system("which git > /dev/null") && File.directory?(".git") |
31 | 31 | clean = `git status --porcelain`.empty? |
32 | - master = `git symbolic-ref HEAD`.chomp == "refs/heads/master" | |
32 | + current_branch = `git symbolic-ref HEAD`.chomp | |
33 | + master = current_branch == "refs/heads/master" | |
33 | 34 | no_new_commits = system('git diff --exit-code --quiet origin/master master') |
34 | 35 | |
35 | - warn "Cannot auto-update due to unclean tree!" unless clean | |
36 | - warn "Cannot auto-update due to unpushed commits on master!" unless no_new_commits | |
36 | + short_branch = current_branch.split('/').last | |
37 | 37 | |
38 | + if !master | |
39 | + warn "Boxen on a non-master branch '#{short_branch}', won't auto-update!" | |
40 | + elsif !no_new_commits | |
41 | + warn "Boxen has unpushed commits on master, won't auto-update!" | |
42 | + elsif !clean | |
43 | + warn "Boxen has a dirty tree, won't auto-update!" | |
44 | + end | |
45 | + | |
38 | 46 | if clean && master && no_new_commits |
39 | 47 | quietly = "> /dev/null 2>&1" |
40 | 48 | fetch = "(git fetch origin #{quietly})" |
... | ... | @@ -42,7 +50,7 @@ |
42 | 50 | reclean = "(git clean -df #{quietly})" |
43 | 51 | |
44 | 52 | unless system "#{fetch} && #{reset} && #{reclean}" |
45 | - warn "Couldn't auto-update, continuing." | |
53 | + warn "Auto-update of Boxen FAILED, continuing." | |
46 | 54 | end |
47 | 55 | end |
48 | 56 | end |
... | ... | @@ -56,7 +64,6 @@ |
56 | 64 | # Set up our local configuration, deps, and load path. |
57 | 65 | |
58 | 66 | load "config/basic.rb" |
59 | - | |
60 | 67 | require "boxen/cli" |
61 | 68 | |
62 | 69 | # Okay, let's run this thing. |