From 0ad5131eba778a35d6496d6c272b8506679fdcd3 Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Sat, 26 Mar 2016 11:56:40 +0100 Subject: [PATCH] build system: add target for verifying there are no unstaged changes --- Rakefile | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Rakefile b/Rakefile index 1c3a64e3a..78540fc1c 100755 --- a/Rakefile +++ b/Rakefile @@ -199,6 +199,17 @@ import_dependencies # Default task define_default_task +# A helper task to check if there are any unstaged changes. +task :no_unstaged_changes do + has_changes = false + has_changes = true if !system("git rev-parse --verify HEAD &> /dev/null") || $?.exitstatus != 0 + has_changes = true if !system("git update-index -q --ignore-submodules --refresh &> /dev/null") || $?.exitstatus != 0 + has_changes = true if !system("git diff-files --quiet --ignore-submodules &> /dev/null") || $?.exitstatus != 0 + has_changes = true if !system("git diff-index --cached --quiet --ignore-submodules HEAD -- &> /dev/null") || $?.exitstatus != 0 + + fail "There are unstaged changes; the operation cannot continue." if has_changes +end + desc "Build all applications" task :apps => $applications