class PPL::Command::Update
Public Class Methods
new(argv)
click to toggle source
Calls superclass method
PPL::Command::new
# File lib/pod-pipeline/command/update.rb, line 29 def initialize(argv) @path = argv.arguments! @channels = argv.option('channel', '').split(',') @new_version = argv.option('version', '').split(',').first @projectPath = @path.count.zero? ? Pathname.pwd.to_s : @path.first @is_master = false unless @repo @repo = 'master' @is_master = true end super end
options()
click to toggle source
Calls superclass method
PPL::Command::options
# File lib/pod-pipeline/command/update.rb, line 22 def self.options [ ['--channel=version,git', '更新内容,version为更新podspec文件中的的版本号,git为Git仓库添加对应podspec版本号的tag,并上传到远端。(默认更新所有内容)'], ['--version=x.x.x', '新版本号。(默认使用patch+1)'] ].concat(super) end
Public Instance Methods
run()
click to toggle source
# File lib/pod-pipeline/command/update.rb, line 44 def run PPL::Scanner.new(@projectPath, ['pod', 'git']).run @channels = ["all"] if @channels.count.zero? puts "\n[更新 #{@channels.join(", ")} 内容]" @channels.each do |channel| case channel when "all" update_version update_git when "version" update_version when "git" update_git else raise "暂不支持#{channel}内容扫描" end end end
update_git()
click to toggle source
# File lib/pod-pipeline/command/update.rb, line 78 def update_git git = PPL::Scanner.git new_tag = PPL::Scanner.podspec.version.version git.tags.each do |tag| raise "当前版本 #{new_tag} 已发布,请尝试其他版本号" if tag.name.eql? new_tag end git.add('.') git.commit_all(new_tag) git.add_tag(new_tag) puts "[Git 上传 #{git.remote} #{git.branches.current.first} #{new_tag}]" git.push(git.remote, git.branches.current.first, true) end
update_version()
click to toggle source
# File lib/pod-pipeline/command/update.rb, line 66 def update_version version = PPL::Scanner.podspec.version raise "版本号异常,无法更新" unless version if @new_version version.archiving(@new_version) else version.increase_patch end PPL::Scanner.linter.write_to_file('version', version.version) end