Commit deb70fb0 authored by Fabio Pelosin's avatar Fabio Pelosin

[Pod::Command::Push] --allow-warnings option

parent f014c9d6
...@@ -13,17 +13,22 @@ module Pod ...@@ -13,17 +13,22 @@ module Pod
to REPO, and finally it pushes REPO to its remote.} to REPO, and finally it pushes REPO to its remote.}
end end
def self.options
[["--allow-warnings", "Allows to push if warnings are not evitable"]].concat(super)
end
extend Executable extend Executable
executable :git executable :git
def initialize(argv) def initialize(argv)
@allow_warnings = argv.option('--allow-warnings')
@repo = argv.shift_argument @repo = argv.shift_argument
super unless argv.empty? && @repo super unless argv.empty? && @repo
end end
def run def run
validate_podspec_files! validate_podspec_files
check_repo_status! check_repo_status
update_repo update_repo
add_specs_to_repo add_specs_to_repo
push_repo push_repo
...@@ -48,7 +53,7 @@ module Pod ...@@ -48,7 +53,7 @@ module Pod
dir dir
end end
def check_repo_status! def check_repo_status
# TODO: add specs for staged and unstaged files (tested manually) # TODO: add specs for staged and unstaged files (tested manually)
status = Dir.chdir(repo_dir) { `git status --porcelain` } == '' status = Dir.chdir(repo_dir) { `git status --porcelain` } == ''
raise Informative, "[!] `#{@repo}' repo not clean".red unless status raise Informative, "[!] `#{@repo}' repo not clean".red unless status
...@@ -60,22 +65,19 @@ module Pod ...@@ -60,22 +65,19 @@ module Pod
files files
end end
def validate_podspec_files! def validate_podspec_files
puts "\nValidating specs".yellow unless config.silent puts "\nValidating specs".yellow unless config.silent
lint_argv = ["lint"] lint_argv = ["lint"]
lint_argv << "--only-errors" if @allow_warnings
lint_argv << "--silent" if config.silent lint_argv << "--silent" if config.silent
all_valid = Spec.new(ARGV.new(lint_argv)).run all_valid = Spec.new(ARGV.new(lint_argv)).run
raise Informative, "[!] All specs must pass validation before push".red unless all_valid
end end
def add_specs_to_repo def add_specs_to_repo
puts "\nAdding the specs to the #{@repo} repo\n".yellow unless config.silent puts "\nAdding the specs to the #{@repo} repo\n".yellow unless config.silent
podspec_files.each do |spec_file| podspec_files.each do |spec_file|
spec = Pod::Specification.from_file(spec_file) spec = Pod::Specification.from_file(spec_file)
output_path = File.join(repo_dir, spec.name, spec.version.to_s) output_path = File.join(repo_dir, spec.name, spec.version.to_s)
if Pathname.new(output_path).exist? if Pathname.new(output_path).exist?
message = "[Fix] #{spec}" message = "[Fix] #{spec}"
elsif Pathname.new(File.join(repo_dir, spec.name)).exist? elsif Pathname.new(File.join(repo_dir, spec.name)).exist?
......
...@@ -20,8 +20,8 @@ module Pod ...@@ -20,8 +20,8 @@ module Pod
def self.options def self.options
[ ["--no-install", "lint skips checks that would require to donwload the spec"], [ ["--no-install", "Lint skips checks that would require to donwload the spec"],
["--only-errors", "lint validates even if warnings are present"] ].concat(super) ["--only-errors", "Lint validates even if warnings are present"] ].concat(super)
end end
def initialize(argv) def initialize(argv)
......
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