class Pod::Command::Push::Tag
Public Class Methods
new(argv)
click to toggle source
Calls superclass method
# File lib/pod/command/push-tag.rb, line 25 def initialize(argv) @commit_local = argv.flag?('commit-local', false) @tag_on_change = argv.flag?('tag-on-change', false) @continue_if_exists = argv.flag?('continue-if-exists', false) @push_remote = argv.flag?('push-remote', false) @tag_version = argv.shift_argument @current_repo_dir = '' super end
options()
click to toggle source
Calls superclass method
# File lib/pod/command/push-tag.rb, line 16 def self.options [ ['--commit-local', 'Make commit for bump version'], ['--push-remote', 'Perform the step of pushing REPO to its remote'], ['--continue-if-exists', 'Continues running when tag is existed'], ['--tag-on-change', 'Just push tag when podspec is changed'], ].concat(super) end
Public Instance Methods
commit_then_push(name)
click to toggle source
# File lib/pod/command/push-tag.rb, line 72 def commit_then_push(name) message = "[#{name}] Bump version #{@tag_version}" podspec_name = "#{name}.podspec" # only commit if modified if pod_repo_git('status', '--porcelain').include?(podspec_name) pod_repo_git('add', '*.podspec') unless !@commit_local pod_repo_git('commit', '--no-verify', '-m', message) unless !@commit_local push_pod_repo(name) unless !@push_remote pod_repo_git('tag', '-a', @tag_version, '-m', message) push_tag_repo elsif !@tag_on_change check_repo_status(name, @current_repo_dir) update_repo(name, @current_repo_dir) pod_repo_git('tag', '-a', @tag_version, '-m', message) push_tag_repo else UI.puts " - [No change] #{name}: #{@tag_version}" end end
modify_podspec(path, version)
click to toggle source
# File lib/pod/command/push-tag.rb, line 95 def modify_podspec(path, version) unless version =~ /^\d{1,}.\d.\d$|^\d{1,}.\d$|^\d{1,}$/ UI.puts "s.version: not found" return end unless File.exist?path UI.puts "Podspec file not found" return end File.open(path, "r+") do |f| s = "" f.each_line do |line| if line.to_s =~ /s\.version\s*=\s*"(\d{1,}.\d.\d|\d{1,}.\d|\d{1,})"/ line = line.sub(/\d{1,}.\d.\d|\d{1,}.\d|\d{1,}/) do |match| version.to_s end end if line.to_s =~ /s\.version\s*=\s*'(\d{1,}.\d.\d|\d{1,}.\d|\d{1,})'/ line = line.sub(/\d{1,}.\d.\d|\d{1,}.\d|\d{1,}/) do |match| version.to_s end end s += line end File.open(path, "w+") do |f| f.write(s) end end end
run()
click to toggle source
# File lib/pod/command/push-tag.rb, line 45 def run processedPaths = Array.new podspec_files.each do |spec_file| spec = Pod::Specification.from_file(spec_file) @tag_version = spec.version.to_s unless !@tag_version.nil? @current_repo_dir = Pathname(spec_file).dirname next if processedPaths.include?(@current_repo_dir) processedPaths.push(@current_repo_dir) # check_repo_status(spec.name, Pathname(spec_file).dirname) # update_repo(spec.name, Pathname(spec_file).dirname) exists_tag = pod_repo_git('tag').include?(@tag_version) if exists_tag && !@continue_if_exists raise Informative, "#{spec.name}: tag #{@tag_version} already exists" end UI.puts "#{spec.name}: tag #{@tag_version} already exists".red unless !exists_tag commit_then_push(spec.name) unless exists_tag end end
validate!()
click to toggle source
Calls superclass method
# File lib/pod/command/push-tag.rb, line 35 def validate! super # help! 'A bump version is required.' unless @tag_version # unless @tag_version # raise Informative, # "A tag version is required." \ # '`pod push tag 0.1.0`.' # end end
Private Instance Methods
check_repo_status(name, dir)
click to toggle source
Checks that the repo is clean.
@raise If the repo is not clean.
@todo Add specs for staged and unstaged files.
@todo Gracefully handle the case where source is not under git
source control.
@return [void]
# File lib/pod/command/push-tag.rb, line 146 def check_repo_status(name, dir) porcelain_status, = Executable.capture_command('git', %w(status --porcelain), :capture => :merge, :chdir => dir) clean = porcelain_status == '' raise Informative, "The repo `#{name}` is not clean" unless clean end
pod_repo_git(*args)
click to toggle source
# File lib/pod/command/push-tag.rb, line 179 def pod_repo_git(*args) git!(['-C', @current_repo_dir] + args) end
podspec_files()
click to toggle source
@return [Array<Pathname>] The path of the specifications to push.
# File lib/pod/command/push-tag.rb, line 186 def podspec_files files = Pathname.glob('**/*.podspec') raise Informative, "Couldn't find any podspec files in current directory" if files.empty? files end
push_pod_repo(name)
click to toggle source
Pushes the git repo against the remote.
@return [void]
# File lib/pod/command/push-tag.rb, line 165 def push_pod_repo(name) UI.puts "\nPushing the `#{name}' repo\n".yellow pod_repo_git('push', 'origin', 'HEAD') end
push_tag_repo()
click to toggle source
# File lib/pod/command/push-tag.rb, line 170 def push_tag_repo UI.puts "\nPushing the `#{@tag_version}' tag\n".yellow pod_repo_git('push', 'origin', @tag_version) end
update_repo(name, dir)
click to toggle source
Updates the git repo against the remote.
@return [void]
# File lib/pod/command/push-tag.rb, line 156 def update_repo(name, dir) UI.puts "Updating the `#{name}' repo\n".yellow git!(%W(-C #{dir} pull)) end