Class: PPL::Command::Update
Class Method Summary
collapse
Instance Method Summary
collapse
#argv_extension, ensure_not_root_or_allowed!, git_version, options_extension, options_extension_hash, run, verify_minimum_git_version!, verify_xcode_license_approved!
Constructor Details
#initialize(argv) ⇒ Update
Returns a new instance of Update.
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
# 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
|
Class Method Details
.options ⇒ Object
22
23
24
25
26
27
|
# 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
|
Instance Method Details
#run ⇒ Object
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
# File 'lib/pod-pipeline/command/update.rb', line 44
def run
PPL::Scanner.new(@projectPath, ['all']).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 ⇒ Object
78
79
80
81
82
83
84
85
86
87
88
89
90
|
# File 'lib/pod-pipeline/command/update.rb', line 78
def update_git
git = PPL::Scanner.git
new_tag = PPL::Scanner.linter.spec.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 ⇒ Object
66
67
68
69
70
71
72
73
74
75
76
|
# File 'lib/pod-pipeline/command/update.rb', line 66
def update_version
version = PPL::Scanner.linter.spec.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
|