Commit 387698a1 authored by Joshua Kovach's avatar Joshua Kovach

Don't try to commit unchanged specs on push

parent 1fd8740b
......@@ -8,7 +8,7 @@ module Pod
self.description = <<-DESC
Validates NAME.podspec or `*.podspec' in the current working dir, creates
a directory and version folder for the pod in the local copy of
a directory and version folder for the pod in the local copy of
REPO (~/.cocoapods/[REPO]), copies the podspec file into the version directory,
and finally it pushes REPO to its remote.
DESC
......@@ -79,7 +79,7 @@ module Pod
#
# @todo Add specs for staged and unstaged files.
#
# @todo Gracefully handle the case where source is not under git
# @todo Gracefully handle the case where source is not under git
# source control.
#
# @return [void]
......@@ -117,13 +117,18 @@ module Pod
else
message = "[Add] #{spec}"
end
UI.puts " - #{message}"
FileUtils.mkdir_p(output_path)
FileUtils.cp(spec_file, output_path)
Dir.chdir(repo_dir) do
git!("add #{spec.name}")
git!("commit --no-verify -m '#{message}'")
# only commit if modified
if git!("status --porcelain 2>&1") =~ /#{spec.name}/
UI.puts " - #{message}"
git!("add #{spec.name}")
git!("commit --no-verify -m '#{message}'")
else
UI.puts " - [No change] #{spec}"
end
end
end
end
......
......@@ -53,11 +53,15 @@ module Pod
end
# prepare the spec
spec = (fixture('spec-repos') + 'master/JSONKit/1.4/JSONKit.podspec').read
spec = (fixture('spec-repos') + 'test_repo/JSONKit/1.4/JSONKit.podspec').read
spec_fix = spec.gsub(/https:\/\/github\.com\/johnezang\/JSONKit\.git/, fixture('integration/JSONKit').to_s)
spec_add = spec.gsub(/'JSONKit'/, "'PushTest'")
spec_clean = (fixture('spec-repos') + 'test_repo/BananaLib/1.0/BananaLib.podspec').read
File.open(temporary_directory + 'JSONKit.podspec', 'w') {|f| f.write(spec_fix) }
File.open(temporary_directory + 'PushTest.podspec', 'w') {|f| f.write(spec_add) }
File.open(temporary_directory + 'BananaLib.podspec', 'w') {|f| f.write(spec_clean) }
end
it "refuses to push if the repo is not clean" do
......@@ -79,6 +83,7 @@ module Pod
Dir.chdir(temporary_directory) { cmd.run }
Pod::UI.output.should.include('[Add] PushTest (1.4)')
Pod::UI.output.should.include('[Fix] JSONKit (1.4)')
Pod::UI.output.should.include('[No change] BananaLib (1.0)')
Dir.chdir(@upstream) { `git checkout master -q` }
(@upstream + 'PushTest/1.4/PushTest.podspec').read.should.include('PushTest')
end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment