Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Play nice with submodules #8

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions lib/chef/knife/spork-bump.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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\.]+\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
else
File.open(metadata_file, "w") { |file| file << new_body_of_file }
end
end

def get_version(cookbook_path, cookbook)
Expand Down Expand Up @@ -193,7 +198,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
Expand All @@ -204,7 +209,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
Expand Down
4 changes: 2 additions & 2 deletions lib/chef/knife/spork-promote.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down