better error messages about auto updating
This commit is contained in:
parent
60851f970a
commit
3b06d26165
1 changed files with 12 additions and 5 deletions
17
script/boxen
17
script/boxen
|
@ -29,11 +29,19 @@ Dir.chdir Pathname.new(__FILE__).realpath + "../.."
|
||||||
unless ENV["BOXEN_NO_PULL"] || ARGV.include?("--no-pull")
|
unless ENV["BOXEN_NO_PULL"] || ARGV.include?("--no-pull")
|
||||||
if system("which git > /dev/null") && File.directory?(".git")
|
if system("which git > /dev/null") && File.directory?(".git")
|
||||||
clean = `git status --porcelain`.empty?
|
clean = `git status --porcelain`.empty?
|
||||||
master = `git symbolic-ref HEAD`.chomp == "refs/heads/master"
|
current_branch = `git symbolic-ref HEAD`.chomp
|
||||||
|
master = current_branch == "refs/heads/master"
|
||||||
no_new_commits = system('git diff --exit-code --quiet origin/master master')
|
no_new_commits = system('git diff --exit-code --quiet origin/master master')
|
||||||
|
|
||||||
warn "Cannot auto-update due to unclean tree!" unless clean
|
short_branch = current_branch.split('/').last
|
||||||
warn "Cannot auto-update due to unpushed commits on master!" unless no_new_commits
|
|
||||||
|
if !master
|
||||||
|
warn "Boxen on a non-master branch '#{short_branch}', won't auto-update!"
|
||||||
|
elsif !no_new_commits
|
||||||
|
warn "Boxen has unpushed commits on master, won't auto-update!"
|
||||||
|
elsif !clean
|
||||||
|
warn "Boxen has a dirty tree, won't auto-update!"
|
||||||
|
end
|
||||||
|
|
||||||
if clean && master && no_new_commits
|
if clean && master && no_new_commits
|
||||||
quietly = "> /dev/null 2>&1"
|
quietly = "> /dev/null 2>&1"
|
||||||
|
@ -42,7 +50,7 @@ unless ENV["BOXEN_NO_PULL"] || ARGV.include?("--no-pull")
|
||||||
reclean = "(git clean -df #{quietly})"
|
reclean = "(git clean -df #{quietly})"
|
||||||
|
|
||||||
unless system "#{fetch} && #{reset} && #{reclean}"
|
unless system "#{fetch} && #{reset} && #{reclean}"
|
||||||
warn "Couldn't auto-update, continuing."
|
warn "Auto-update of Boxen FAILED, continuing."
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -56,7 +64,6 @@ abort "Can't bootstrap, dependencies are outdated." unless system *strap
|
||||||
# Set up our local configuration, deps, and load path.
|
# Set up our local configuration, deps, and load path.
|
||||||
|
|
||||||
load "config/basic.rb"
|
load "config/basic.rb"
|
||||||
|
|
||||||
require "boxen/cli"
|
require "boxen/cli"
|
||||||
|
|
||||||
# Okay, let's run this thing.
|
# Okay, let's run this thing.
|
||||||
|
|
Loading…
Reference in a new issue