Commit de403cdd authored by Samuel Giddins's avatar Samuel Giddins Committed by GitHub

Merge pull request #5568 from maschall/Repo-Push-Json

[repo/push] --use-json to convert podspecs to JSON format when pushing
parents 03ab3a34 e906fc10
...@@ -20,6 +20,9 @@ To install release candidates run `[sudo] gem install cocoapods --pre` ...@@ -20,6 +20,9 @@ To install release candidates run `[sudo] gem install cocoapods --pre`
[Juan Civile](https://github.com/champo) [Juan Civile](https://github.com/champo)
[#5376](https://github.com/CocoaPods/CocoaPods/issues/5376) [#5376](https://github.com/CocoaPods/CocoaPods/issues/5376)
* [repo/push] --use-json to convert podspecs to JSON format when pushing
[Mark Schall](https://github.com/maschall)
[#5568](https://github.com/CocoaPods/CocoaPods/pull/5568)
##### Bug Fixes ##### Bug Fixes
......
...@@ -31,6 +31,7 @@ module Pod ...@@ -31,6 +31,7 @@ module Pod
['--no-private', 'Lint includes checks that apply only to public repos'], ['--no-private', 'Lint includes checks that apply only to public repos'],
['--commit-message="Fix bug in pod"', 'Add custom commit message. ' \ ['--commit-message="Fix bug in pod"', 'Add custom commit message. ' \
'Opens default editor if no commit message is specified.'], 'Opens default editor if no commit message is specified.'],
['--use-json', 'Push JSON spec to repo'],
].concat(super) ].concat(super)
end end
...@@ -45,6 +46,7 @@ module Pod ...@@ -45,6 +46,7 @@ module Pod
@private = argv.flag?('private', true) @private = argv.flag?('private', true)
@message = argv.option('commit-message') @message = argv.option('commit-message')
@commit_message = argv.flag?('commit-message', false) @commit_message = argv.flag?('commit-message', false)
@use_json = argv.flag?('use-json')
super super
end end
...@@ -177,9 +179,16 @@ module Pod ...@@ -177,9 +179,16 @@ module Pod
else else
message = "[Add] #{spec}" message = "[Add] #{spec}"
end end
FileUtils.mkdir_p(output_path) FileUtils.mkdir_p(output_path)
if @use_json
json_file_name = "#{spec.name}.podspec.json"
json_file = File.join(output_path, json_file_name)
File.open(json_file, 'w') { |file| file.write(spec.to_pretty_json) }
else
FileUtils.cp(spec_file, output_path) FileUtils.cp(spec_file, output_path)
end
Dir.chdir(repo_dir) do Dir.chdir(repo_dir) do
# only commit if modified # only commit if modified
if git!('status', '--porcelain').include?(spec.name) if git!('status', '--porcelain').include?(spec.name)
......
...@@ -99,7 +99,7 @@ module Pod ...@@ -99,7 +99,7 @@ module Pod
(@upstream + 'PushTest/1.4/PushTest.podspec').should.not.exist? (@upstream + 'PushTest/1.4/PushTest.podspec').should.not.exist?
end end
it 'successfully pushes a spec' 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` }
cmd.expects(:validate_podspec_files).returns(true) cmd.expects(:validate_podspec_files).returns(true)
...@@ -107,10 +107,26 @@ module Pod ...@@ -107,10 +107,26 @@ module Pod
Pod::UI.output.should.include('[Add] PushTest (1.4)') Pod::UI.output.should.include('[Add] PushTest (1.4)')
Pod::UI.output.should.include('[Fix] JSONKit (1.4)') Pod::UI.output.should.include('[Fix] JSONKit (1.4)')
Pod::UI.output.should.include('[No change] BananaLib (1.0)') Pod::UI.output.should.include('[No change] BananaLib (1.0)')
end
it 'successfully pushes a spec' do
cmd = command('repo', 'push', 'master')
Dir.chdir(@upstream) { `git checkout -b tmp_for_push -q` }
cmd.expects(:validate_podspec_files).returns(true)
Dir.chdir(temporary_directory) { cmd.run }
Dir.chdir(@upstream) { `git checkout master -q` } Dir.chdir(@upstream) { `git checkout master -q` }
(@upstream + 'PushTest/1.4/PushTest.podspec').read.should.include('PushTest') (@upstream + 'PushTest/1.4/PushTest.podspec').read.should.include('PushTest')
end end
it 'successfully pushes converted JSON podspec' do
cmd = command('repo', 'push', 'master', '--use-json')
Dir.chdir(@upstream) { `git checkout -b tmp_for_push -q` }
cmd.expects(:validate_podspec_files).returns(true)
Dir.chdir(temporary_directory) { cmd.run }
Dir.chdir(@upstream) { `git checkout master -q` }
(@upstream + 'PushTest/1.4/PushTest.podspec.json').read.should.include('PushTest')
end
it 'initializes with default sources if no custom sources specified' do it 'initializes with default sources if no custom sources specified' do
cmd = command('repo', 'push', 'master') cmd = command('repo', 'push', 'master')
cmd.instance_variable_get(:@source_urls).should.equal [@upstream.to_s] cmd.instance_variable_get(:@source_urls).should.equal [@upstream.to_s]
......
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