From 5d9d46aec1bf4a6b77ccea635eaa089a5f271b88 Mon Sep 17 00:00:00 2001 From: Louise Crow Date: Tue, 30 Jul 2013 17:28:26 +0100 Subject: Add a rake task to print a warning if the state of a submodule is not what we expect it to be. --- lib/tasks/submodules.rake | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 lib/tasks/submodules.rake (limited to 'lib/tasks/submodules.rake') diff --git a/lib/tasks/submodules.rake b/lib/tasks/submodules.rake new file mode 100644 index 000000000..6da0ff4b8 --- /dev/null +++ b/lib/tasks/submodules.rake @@ -0,0 +1,27 @@ + +namespace :submodules do + + desc "Check the status of the project's submodules" + task :check => :environment do + commit_info = `git submodule status` + sha, repo, branch = commit_info.split(' ') + case sha[0] + when '+' + $stderr.puts "Warning: Currently checked out submodule commit for #{repo}" + $stderr.puts "does not match the commit expected by this version of Alaveteli." + $stderr.puts "You can update it with 'git submodule update'." + exit(1) + when '-' + $stderr.puts "Warning: Submodule #{repo} needs to be initialized." + $stderr.puts "You can do this by running 'git submodule update --init'." + exit(1) + when 'U' + $stderr.puts "Warning: Submodule #{repo} has merge conflicts." + $stderr.puts "You'll probably need to resolve these to run Alaveteli." + exit(1) + else + exit(0) + end + end + +end -- cgit v1.2.3 From 8d49b6838f7dfc2e72808752735cc6ee224ffcb0 Mon Sep 17 00:00:00 2001 From: Louise Crow Date: Tue, 30 Jul 2013 18:03:31 +0100 Subject: Get first character in a way that will work in Ruby 1.8 and 1.9 --- lib/tasks/submodules.rake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/tasks/submodules.rake') diff --git a/lib/tasks/submodules.rake b/lib/tasks/submodules.rake index 6da0ff4b8..4d414ea84 100644 --- a/lib/tasks/submodules.rake +++ b/lib/tasks/submodules.rake @@ -5,7 +5,7 @@ namespace :submodules do task :check => :environment do commit_info = `git submodule status` sha, repo, branch = commit_info.split(' ') - case sha[0] + case sha[0,1] when '+' $stderr.puts "Warning: Currently checked out submodule commit for #{repo}" $stderr.puts "does not match the commit expected by this version of Alaveteli." -- cgit v1.2.3 From 7caa577e504fb3212c833eb23dc0f1ed6dae464c Mon Sep 17 00:00:00 2001 From: Louise Crow Date: Tue, 30 Jul 2013 18:23:31 +0100 Subject: Call it an error, not a warning. --- lib/tasks/submodules.rake | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'lib/tasks/submodules.rake') diff --git a/lib/tasks/submodules.rake b/lib/tasks/submodules.rake index 4d414ea84..1112e443e 100644 --- a/lib/tasks/submodules.rake +++ b/lib/tasks/submodules.rake @@ -7,17 +7,17 @@ namespace :submodules do sha, repo, branch = commit_info.split(' ') case sha[0,1] when '+' - $stderr.puts "Warning: Currently checked out submodule commit for #{repo}" + $stderr.puts "Error: Currently checked out submodule commit for #{repo}" $stderr.puts "does not match the commit expected by this version of Alaveteli." $stderr.puts "You can update it with 'git submodule update'." exit(1) when '-' - $stderr.puts "Warning: Submodule #{repo} needs to be initialized." + $stderr.puts "Error: Submodule #{repo} needs to be initialized." $stderr.puts "You can do this by running 'git submodule update --init'." exit(1) when 'U' - $stderr.puts "Warning: Submodule #{repo} has merge conflicts." - $stderr.puts "You'll probably need to resolve these to run Alaveteli." + $stderr.puts "Error: Submodule #{repo} has merge conflicts." + $stderr.puts "You'll need to resolve these to run Alaveteli." exit(1) else exit(0) -- cgit v1.2.3 From 9f62a26384232890d8dcdc56cd5983b793db3be1 Mon Sep 17 00:00:00 2001 From: Louise Crow Date: Thu, 8 Aug 2013 15:13:13 +0100 Subject: Only check commonlib, don't try to split the response into segments (as @mhl points out, the case where the initial character is a space is somewhat confusing), just grab the first character of the whole string and check it against expected values. --- lib/tasks/submodules.rake | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'lib/tasks/submodules.rake') diff --git a/lib/tasks/submodules.rake b/lib/tasks/submodules.rake index 1112e443e..426192713 100644 --- a/lib/tasks/submodules.rake +++ b/lib/tasks/submodules.rake @@ -3,24 +3,25 @@ namespace :submodules do desc "Check the status of the project's submodules" task :check => :environment do - commit_info = `git submodule status` - sha, repo, branch = commit_info.split(' ') - case sha[0,1] + commit_info = `git submodule status commonlib` + case commit_info[0,1] when '+' - $stderr.puts "Error: Currently checked out submodule commit for #{repo}" + $stderr.puts "Error: Currently checked out submodule commit for commonlib" $stderr.puts "does not match the commit expected by this version of Alaveteli." $stderr.puts "You can update it with 'git submodule update'." exit(1) when '-' - $stderr.puts "Error: Submodule #{repo} needs to be initialized." + $stderr.puts "Error: Submodule commonlib needs to be initialized." $stderr.puts "You can do this by running 'git submodule update --init'." exit(1) when 'U' - $stderr.puts "Error: Submodule #{repo} has merge conflicts." + $stderr.puts "Error: Submodule commonlib has merge conflicts." $stderr.puts "You'll need to resolve these to run Alaveteli." exit(1) - else + when ' ' exit(0) + else + raise "Unexpected status character in response to 'git submodule status commonlib': #{commit_info[0,1]}" end end -- cgit v1.2.3