Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Don't try to commit unchanged specs on push #1199

Merged
merged 2 commits into from

3 participants

@shekibobo

If multiple podspecs exist in a directory, and I run 'pod push my-repo' when some of those podspecs haven't changed, the push raises an exception when trying to run 'git commit' with no changes.

I propose we simply notify that the file is unchanged and allow the process to continue, rather than exiting the process.

This PR simply checks to see if the git diff for the file actually has a change before it attempts to add and commit.

@shekibobo

Looks like 8c95e0e doesn't work, in part because git diff returns blank for new untracked files... Looking into it.

@coveralls

Coverage Status

Coverage remained the same when pulling 8c95e0e on shekibobo:pod-push-unchanged into 1fd8740 on CocoaPods:master.

@coveralls

Coverage Status

Coverage remained the same when pulling 6560783 on shekibobo:pod-push-unchanged into 1fd8740 on CocoaPods:master.

@coveralls

Coverage Status

Coverage remained the same when pulling 6918efc on shekibobo:pod-push-unchanged into 1fd8740 on CocoaPods:master.

@coveralls

Coverage Status

Coverage remained the same when pulling 7a899e9 on shekibobo:pod-push-unchanged into 1fd8740 on CocoaPods:master.

@shekibobo

Note that in order to get tests to pass, I had to change the fixture path from /master to /test_repo.

@coveralls

Coverage Status

Coverage remained the same when pulling 387698a on shekibobo:pod-push-unchanged into 1fd8740 on CocoaPods:master.

@fabiopelosin

:+1: Looks good to me, do you mind adding a note in Changelog?

@shekibobo

That okay? I'm not sure whether this would fall under bug fixes or enhancements.

@coveralls

Coverage Status

Coverage remained the same when pulling bf741f0 on shekibobo:pod-push-unchanged into 1fd8740 on CocoaPods:master.

@fabiopelosin

That okay? I'm not sure whether this would fall under bug fixes or enhancements.

I would consider that a minor enhancement :smile:

Thanks for the contribution btw!

@fabiopelosin fabiopelosin merged commit dc92827 into CocoaPods:master

1 check passed

Details default The Travis CI build passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
View
7 CHANGELOG.md
@@ -2,6 +2,13 @@
To install or update CocoaPods see this [guide](http://docs.cocoapods.org/guides/installing_cocoapods.html).
+## Master (Unreleased)
+
+###### Bug Fixes
+
+* Fixed issue with `pod push` failing when the podspec is unchanged. It will now
+ report `[No change] ExamplePod (0.1.0)` and continue to push other podspecs if
+ they exist. [#1199](https://github.com/CocoaPods/CocoaPods/pull/1199)
## 0.22.2
[CocoaPods](https://github.com/CocoaPods/CocoaPods/compare/0.22.1...0.22.2)
View
15 lib/cocoapods/command/push.rb
@@ -8,7 +8,7 @@ class Push < Command
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 @@ def validate_podspec_files
#
# @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 @@ def add_specs_to_repo
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
View
7 spec/functional/command/push_spec.rb
@@ -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
Something went wrong with that request. Please try again.