Unverified Commit df6872de authored by Dimitris Koutsogiorgas's avatar Dimitris Koutsogiorgas Committed by GitHub

Merge pull request #7349 from CocoaPods/seg-pod-repo-push-no-overwrite

[Repo::Push] Allow disabling overwriting published specs
parents a1799f05 5eb747a9
...@@ -16,6 +16,10 @@ To install release candidates run `[sudo] gem install cocoapods --pre` ...@@ -16,6 +16,10 @@ To install release candidates run `[sudo] gem install cocoapods --pre`
[Keith Smiley](https://github.com/keith) [Keith Smiley](https://github.com/keith)
[#7346](https://github.com/CocoaPods/CocoaPods/pull/7346) [#7346](https://github.com/CocoaPods/CocoaPods/pull/7346)
* Add a `--no-overwrite` flag to `pod repo push` to disable overwriting
existing specs that have already been pushed.
[Samuel Giddins](https://github.com/segiddins)
##### Bug Fixes ##### Bug Fixes
* Unique all available pre-release versions when displaying * Unique all available pre-release versions when displaying
......
...@@ -36,6 +36,7 @@ module Pod ...@@ -36,6 +36,7 @@ module Pod
['--use-json', 'Push JSON spec to repo'], ['--use-json', 'Push JSON spec to repo'],
['--swift-version=VERSION', 'The SWIFT_VERSION that should be used when linting the spec. ' \ ['--swift-version=VERSION', 'The SWIFT_VERSION that should be used when linting the spec. ' \
'This takes precedence over a .swift-version file.'], 'This takes precedence over a .swift-version file.'],
['--no-overwrite', 'Disallow pushing that would overwrite an existing spec.'],
].concat(super) ].concat(super)
end end
...@@ -54,6 +55,7 @@ module Pod ...@@ -54,6 +55,7 @@ module Pod
@swift_version = argv.option('swift-version', nil) @swift_version = argv.option('swift-version', nil)
@skip_import_validation = argv.flag?('skip-import-validation', false) @skip_import_validation = argv.flag?('skip-import-validation', false)
@skip_tests = argv.flag?('skip-tests', false) @skip_tests = argv.flag?('skip-tests', false)
@allow_overwrite = argv.flag?('overwrite', true)
super super
end end
...@@ -183,6 +185,9 @@ module Pod ...@@ -183,6 +185,9 @@ module Pod
if @message && !@message.empty? if @message && !@message.empty?
message = @message message = @message
elsif output_path.exist? elsif output_path.exist?
unless @allow_overwrite
raise Informative, "#{spec} already exists and overwriting has been disabled."
end
message = "[Fix] #{spec}" message = "[Fix] #{spec}"
elsif output_path.dirname.directory? elsif output_path.dirname.directory?
message = "[Update] #{spec}" message = "[Update] #{spec}"
......
...@@ -108,6 +108,20 @@ module Pod ...@@ -108,6 +108,20 @@ module Pod
(@upstream + 'PushTest/1.4/PushTest.podspec').should.not.exist? (@upstream + 'PushTest/1.4/PushTest.podspec').should.not.exist?
end end
it 'refuses to push if --no-overwrite is passed and the spec exists' do
cmd = command('repo', 'push', 'master', 'JSONKit.podspec', '--no-overwrite')
Dir.chdir(@upstream) { `git checkout -b tmp_for_push -q` }
cmd.expects(:validate_podspec_files).returns(true)
e = lambda { Dir.chdir(temporary_directory) { cmd.run } }.should.raise Pod::Informative
e.message.should == '[!] JSONKit (1.4) already exists and overwriting has been disabled.'
cmd = command('repo', 'push', 'master', 'PushTest.podspec', '--no-overwrite')
cmd.expects(:validate_podspec_files).returns(true)
Dir.chdir(temporary_directory) { cmd.run }
Pod::UI.output.should.include('[Add] PushTest (1.4)')
end
it 'generate a message for commit' do it 'generate a message for commit' do
cmd = command('repo', 'push', 'master') cmd = command('repo', 'push', 'master')
Dir.chdir(@upstream) { `git checkout -b tmp_for_push -q` } Dir.chdir(@upstream) { `git checkout -b tmp_for_push -q` }
......
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