From ce30fecd4a232b9b65531202897fbb75e62707ba Mon Sep 17 00:00:00 2001 From: Nick Marden Date: Thu, 7 Jun 2012 17:58:35 -0400 Subject: [PATCH 1/3] Play nice with submodules --- lib/chef/knife/spork-bump.rb | 4 ++-- lib/chef/knife/spork-promote.rb | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/chef/knife/spork-bump.rb b/lib/chef/knife/spork-bump.rb index 3e7475c..ec3bacc 100644 --- a/lib/chef/knife/spork-bump.rb +++ b/lib/chef/knife/spork-bump.rb @@ -193,7 +193,7 @@ def git_pull_if_repo(cookbook_path) ui.msg "Opening git repo #{path}\n\n" g = Git.open(path, :log => Logger.new(strio)) ui.msg "Pulling latest changes from git\n\n" - output = IO.popen ("cd #{path} && git pull 2>&1") + output = IO.popen ("cd #{path} && git pull --recurse-submodules 2>&1") Process.wait exit_code = $? if exit_code.exitstatus == 0 @@ -204,7 +204,7 @@ def git_pull_if_repo(cookbook_path) end ui.msg "Pulling latest changes from git submodules (if any)\n\n" - output = IO.popen ("cd #{path} && git submodule foreach git pull 2>&1") + output = IO.popen ("cd #{path} && git submodule update 2>&1") Process.wait exit_code = $? if exit_code.exitstatus == 0 diff --git a/lib/chef/knife/spork-promote.rb b/lib/chef/knife/spork-promote.rb index ff3798b..81c6c7e 100644 --- a/lib/chef/knife/spork-promote.rb +++ b/lib/chef/knife/spork-promote.rb @@ -395,7 +395,7 @@ def git_pull_if_repo ui.msg "Opening git repo #{path}\n\n" g = Git.open(path, :log => Logger.new(strio)) ui.msg "Pulling latest changes from git\n\n" - output = IO.popen ("cd #{path} && git pull 2>&1") + output = IO.popen ("cd #{path} && git pull --recurse-submodules 2>&1") Process.wait exit_code = $? if exit_code.exitstatus == 0 @@ -406,7 +406,7 @@ def git_pull_if_repo end ui.msg "Pulling latest changes from git submodules (if any)\n\n" - output = IO.popen ("cd #{path} && git submodule foreach git pull 2>&1") + output = IO.popen ("cd #{path} && git submodule update 2>&1") Process.wait exit_code = $? if exit_code.exitstatus == 0 From cb0326b9a40cd3e81a8969ba810d7ec2ea25e47a Mon Sep 17 00:00:00 2001 From: Nick Marden Date: Thu, 7 Jun 2012 18:24:04 -0400 Subject: [PATCH 2/3] Detect when spork-bump is a no-op --- lib/chef/knife/spork-bump.rb | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/chef/knife/spork-bump.rb b/lib/chef/knife/spork-bump.rb index ec3bacc..e0019fe 100644 --- a/lib/chef/knife/spork-bump.rb +++ b/lib/chef/knife/spork-bump.rb @@ -158,8 +158,13 @@ def update_version(new_version, metadata_file) open_file = File.open(metadata_file, "r") body_of_file = open_file.read open_file.close - body_of_file.gsub!(/version\s+"[0-9\.]+"/, "version \"#{new_version}\"") - File.open(metadata_file, "w") { |file| file << body_of_file } + new_body_of_file = body_of_file.gsub(/version\s+"[0-9\.]+"/, "version \"#{new_version}\"") + if(body_of_file.eql?(new_body_of_file)) + ui.error("Applying version bump to #{metadata_file} did not result in a change, aborting!") + exit 2 + else + File.open(metadata_file, "w") { |file| file << new_body_of_file } + end end def get_version(cookbook_path, cookbook) From 3407e4f6fbcdf1f1ec4be8e9a69f340a0c84dc7d Mon Sep 17 00:00:00 2001 From: Nick Marden Date: Thu, 7 Jun 2012 18:31:11 -0400 Subject: [PATCH 3/3] Allow single or double quotes in version declaration of metadata.rb --- lib/chef/knife/spork-bump.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/chef/knife/spork-bump.rb b/lib/chef/knife/spork-bump.rb index e0019fe..11481f6 100644 --- a/lib/chef/knife/spork-bump.rb +++ b/lib/chef/knife/spork-bump.rb @@ -158,7 +158,7 @@ def update_version(new_version, metadata_file) open_file = File.open(metadata_file, "r") body_of_file = open_file.read open_file.close - new_body_of_file = body_of_file.gsub(/version\s+"[0-9\.]+"/, "version \"#{new_version}\"") + new_body_of_file = body_of_file.gsub(/version\s+(["'])[0-9\.]+\1/, "version \"#{new_version}\"") if(body_of_file.eql?(new_body_of_file)) ui.error("Applying version bump to #{metadata_file} did not result in a change, aborting!") exit 2