podsorz 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +8 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +109 -0
- data/LICENSE.txt +21 -0
- data/Podfile +0 -0
- data/PodsOrzConfig.rb +13 -0
- data/README.md +39 -0
- data/Rakefile +2 -0
- data/bin/podsorz +14 -0
- data/lib/podsorz.rb +40 -0
- data/lib/podsorz/command/commit.rb +35 -0
- data/lib/podsorz/command/install.rb +23 -0
- data/lib/podsorz/command/publish.rb +40 -0
- data/lib/podsorz/command/setup.rb +28 -0
- data/lib/podsorz/command/switch.rb +47 -0
- data/lib/podsorz/core/orz_config_templet.rb +13 -0
- data/lib/podsorz/core/orz_env_detector.rb +56 -0
- data/lib/podsorz/core/pod_orzconfig_parse.rb +24 -0
- data/lib/podsorz/core/podfile_io.rb +188 -0
- data/lib/podsorz/core/podfile_model.rb +34 -0
- data/lib/podsorz/core/pods_detector.rb +96 -0
- data/lib/podsorz/core/pods_git_manager.rb +429 -0
- data/lib/podsorz/core/pods_git_operator.rb +700 -0
- data/lib/podsorz/core/pods_repo.rb +195 -0
- data/lib/podsorz/core/pods_version.rb +138 -0
- data/lib/podsorz/util/git_operator.rb +208 -0
- data/lib/podsorz/util/logger.rb +32 -0
- data/lib/podsorz/util/process_operator.rb +19 -0
- data/lib/podsorz/version.rb +3 -0
- data/podsorz.gemspec +40 -0
- metadata +117 -0
@@ -0,0 +1,56 @@
|
|
1
|
+
require "podsorz/util/logger"
|
2
|
+
|
3
|
+
module PodsOrz
|
4
|
+
class OrzEnvDetector
|
5
|
+
|
6
|
+
def check_directory(directoryPath)
|
7
|
+
is_directory = File.directory?(directoryPath)
|
8
|
+
Logger.error("Detect failure, directory path error: #{directoryPath}") unless is_directory
|
9
|
+
|
10
|
+
is_directory
|
11
|
+
end
|
12
|
+
|
13
|
+
def detect_podfile(directoryPath)
|
14
|
+
podfile_path = File.expand_path("Podfile", directoryPath)
|
15
|
+
result = File.exist?(podfile_path)
|
16
|
+
unless result
|
17
|
+
Logger.warning("Podfile not exist, create empty Podfile")
|
18
|
+
IO.popen("cd #{directoryPath};touch Podfile")
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def detect_podfile_orz(directoryPath)
|
23
|
+
podfile_path = File.expand_path("Podfile_orz.rb", directoryPath)
|
24
|
+
result = File.exist?(podfile_path)
|
25
|
+
unless result
|
26
|
+
Logger.error("Podfile_orz.rb not exist, please manual makeup one. Copy content from project Podfile")
|
27
|
+
end
|
28
|
+
|
29
|
+
result
|
30
|
+
end
|
31
|
+
|
32
|
+
def detect_PodsOrzConfig(directoryPath)
|
33
|
+
orzconfig_path = File.expand_path("PodsOrzConfig.rb", directoryPath)
|
34
|
+
orzconfig_result = File.exist?(orzconfig_path)
|
35
|
+
|
36
|
+
generate_default_config(orzconfig_path) unless orzconfig_result
|
37
|
+
end
|
38
|
+
|
39
|
+
def generate_default_config(file_path)
|
40
|
+
Logger.warning("PodsOrzConfig not exist, generate default config")
|
41
|
+
file_name = File.basename(file_path)
|
42
|
+
directory = File.dirname(file_path)
|
43
|
+
IO.popen("cd #{directory};touch #{file_name}") { |io|
|
44
|
+
templet_config_path = File.expand_path("../core/orz_config_templet.rb", File.dirname(__FILE__))
|
45
|
+
File.open(templet_config_path, "r") { |templet_file|
|
46
|
+
File.open(file_path, "w+") { |file|
|
47
|
+
templet_file.readlines.each {|line|
|
48
|
+
puts line
|
49
|
+
file.write(line)
|
50
|
+
}
|
51
|
+
}
|
52
|
+
}
|
53
|
+
}
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require "podsorz/util/logger"
|
2
|
+
|
3
|
+
|
4
|
+
module PodsOrz
|
5
|
+
class PodOrzconfigParse
|
6
|
+
attr_accessor :app_release_version, :branch_author_suffix, :fix_pod_list
|
7
|
+
|
8
|
+
def initialize(main_path)
|
9
|
+
orzconfig_path = File.expand_path("PodsOrzConfig.rb", main_path)
|
10
|
+
orzconfig_result = File.exist?(orzconfig_path)
|
11
|
+
|
12
|
+
unless orzconfig_result
|
13
|
+
Logger.error("PodsOrzConfig.rb is not found. Please 'podsorz setup' first")
|
14
|
+
exit()
|
15
|
+
end
|
16
|
+
|
17
|
+
require orzconfig_path
|
18
|
+
|
19
|
+
@app_release_version = GitConfig::APP_RELEASE_VERSION
|
20
|
+
@branch_author_suffix = GitConfig::BRANCH_AUTHOR_SUFFIX
|
21
|
+
@fix_pod_list = $FIX_POD_LIST
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,188 @@
|
|
1
|
+
require "podsorz/util/logger"
|
2
|
+
require "podsorz/core/podfile_model"
|
3
|
+
require File.expand_path("../core/podfile_model.rb", File.dirname(__FILE__))
|
4
|
+
|
5
|
+
module PodsOrz
|
6
|
+
|
7
|
+
class PodfileIO
|
8
|
+
attr_accessor :main_path, :total_sentences, :usable_sentences, :total_pod_models
|
9
|
+
|
10
|
+
def initialize(main_path)
|
11
|
+
@main_path = main_path
|
12
|
+
|
13
|
+
self.parse_podfile_orz
|
14
|
+
end
|
15
|
+
|
16
|
+
|
17
|
+
def parse_podfile_orz
|
18
|
+
orz_file_path = File.expand_path("Podfile_orz.rb", @main_path)
|
19
|
+
|
20
|
+
@total_sentences = []
|
21
|
+
@usable_sentences = []
|
22
|
+
@total_pod_models = []
|
23
|
+
|
24
|
+
File.open(orz_file_path, "r") { |io|
|
25
|
+
@total_sentences = io.readlines
|
26
|
+
|
27
|
+
@total_sentences.each { |orz_line|
|
28
|
+
orz_line_content = orz_line.strip.chomp
|
29
|
+
unless orz_line_content.empty? || orz_line_content.size.zero?
|
30
|
+
unless orz_line_content.start_with?("#")
|
31
|
+
@usable_sentences << orz_line
|
32
|
+
|
33
|
+
if orz_line_content.start_with?("pod ")
|
34
|
+
podfile_model = PodsOrz::PodfileModel.new(orz_line_content)
|
35
|
+
@total_pod_models << podfile_model
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
}
|
40
|
+
}
|
41
|
+
|
42
|
+
end
|
43
|
+
|
44
|
+
|
45
|
+
def output_local_pod(pod_name_list)
|
46
|
+
pod_name_list.each do |podname|
|
47
|
+
@total_pod_models.map { |model|
|
48
|
+
if model.name.start_with? podname.to_s
|
49
|
+
model.path = "../kx_pods/" + podname.to_s
|
50
|
+
end
|
51
|
+
}
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
|
56
|
+
def output_orz_total_sentence(pod_name_list, branch_name)
|
57
|
+
pod_name_list.each do |podname|
|
58
|
+
@total_pod_models.map { |model|
|
59
|
+
if model.name.start_with? podname.to_s
|
60
|
+
model.git = "git@gitlab.91banban.com:ios_pods/Pods/" + podname.to_s + ".git"
|
61
|
+
model.branch = branch_name.to_s
|
62
|
+
end
|
63
|
+
}
|
64
|
+
end
|
65
|
+
|
66
|
+
cocoas_podfile_path = File.expand_path("Podfile_orz.rb", @main_path)
|
67
|
+
|
68
|
+
output_pod_list = @total_pod_models.reject { |model|
|
69
|
+
pod_name = model.name
|
70
|
+
!pod_name_list.include? pod_name
|
71
|
+
}
|
72
|
+
|
73
|
+
File.open(cocoas_podfile_path, "w+") {|io|
|
74
|
+
Logger.highlight("Remote Podfile_orz.rb edite completed!")
|
75
|
+
|
76
|
+
@total_sentences.each do |sentence|
|
77
|
+
sentence_content = sentence.strip.chomp.to_s
|
78
|
+
|
79
|
+
is_sentence_comtent_empty = sentence_content.empty?
|
80
|
+
is_sentence_comtent_size_zero = sentence_content.size.zero?
|
81
|
+
|
82
|
+
unless is_sentence_comtent_empty || is_sentence_comtent_size_zero
|
83
|
+
unless sentence_content.start_with?("#")
|
84
|
+
|
85
|
+
output_pod_list.each do |model|
|
86
|
+
filter_str = "\'#{model.name}\'"
|
87
|
+
if sentence.include? filter_str
|
88
|
+
splite_list = sentence.split(filter_str)
|
89
|
+
sentence = splite_list[0].to_s + filter_str + ", :git => " + "\'#{model.git}\'" + ", :branch => " + "\'#{model.branch}\'"
|
90
|
+
if model.configurations
|
91
|
+
sentence = sentence + ", :configurations => " + model.configurations.to_s
|
92
|
+
end
|
93
|
+
|
94
|
+
puts(sentence.chomp + "\n")
|
95
|
+
end
|
96
|
+
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
io.write(sentence.chomp + "\n")
|
101
|
+
end
|
102
|
+
}
|
103
|
+
|
104
|
+
end
|
105
|
+
|
106
|
+
|
107
|
+
def output_local_total_sentence
|
108
|
+
cocoas_podfile_path = File.expand_path("Podfile", @main_path)
|
109
|
+
|
110
|
+
output_pod_list = @total_pod_models.reject { |model|
|
111
|
+
path = model.path
|
112
|
+
path.to_s.empty?
|
113
|
+
}
|
114
|
+
|
115
|
+
File.open(cocoas_podfile_path, "w+") {|io|
|
116
|
+
Logger.highlight("Local Podfile edite completed!")
|
117
|
+
|
118
|
+
@usable_sentences.each do |sentence|
|
119
|
+
output_pod_list.each do |model|
|
120
|
+
filter_str = "\'#{model.name}\'"
|
121
|
+
if sentence.include? filter_str
|
122
|
+
splite_list = sentence.split(filter_str)
|
123
|
+
sentence = splite_list[0].to_s + filter_str + ", :path => " + "\'#{model.path.to_s}\'"
|
124
|
+
if model.configurations
|
125
|
+
sentence = sentence + ", :configurations => " + model.configurations.to_s
|
126
|
+
end
|
127
|
+
|
128
|
+
sentence = sentence + "\n"
|
129
|
+
puts(sentence)
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
io.write(sentence + "\n")
|
134
|
+
end
|
135
|
+
}
|
136
|
+
end
|
137
|
+
|
138
|
+
def output_publish_total_sentence(pod_hash)
|
139
|
+
pod_hash.each { |pod_name, version|
|
140
|
+
@total_pod_models.map { |model|
|
141
|
+
if model.name.start_with? pod_name.to_s
|
142
|
+
model.version = version
|
143
|
+
end
|
144
|
+
}
|
145
|
+
}
|
146
|
+
|
147
|
+
cocoas_podfile_path = File.expand_path("Podfile_orz.rb", @main_path)
|
148
|
+
|
149
|
+
output_pod_list = @total_pod_models.reject { |model|
|
150
|
+
pod_name = model.name
|
151
|
+
!pod_hash.include? pod_name
|
152
|
+
}
|
153
|
+
|
154
|
+
File.open(cocoas_podfile_path, "w+") {|io|
|
155
|
+
Logger.highlight("Remote Podfile_orz.rb edite completed!")
|
156
|
+
|
157
|
+
@total_sentences.each do |sentence|
|
158
|
+
sentence_content = sentence.strip.chomp.to_s
|
159
|
+
|
160
|
+
is_sentence_comtent_empty = sentence_content.empty?
|
161
|
+
is_sentence_comtent_size_zero = sentence_content.size.zero?
|
162
|
+
|
163
|
+
unless is_sentence_comtent_empty || is_sentence_comtent_size_zero
|
164
|
+
unless sentence_content.start_with?("#")
|
165
|
+
|
166
|
+
output_pod_list.each do |model|
|
167
|
+
filter_str = "\'#{model.name}\'"
|
168
|
+
if sentence.include? filter_str
|
169
|
+
splite_list = sentence.split(filter_str)
|
170
|
+
sentence = splite_list[0].to_s + filter_str + ", \'#{model.version}\'"
|
171
|
+
if model.configurations
|
172
|
+
sentence = sentence + ", :configurations => " + model.configurations.to_s
|
173
|
+
end
|
174
|
+
|
175
|
+
puts(sentence.chomp + "\n")
|
176
|
+
end
|
177
|
+
|
178
|
+
end
|
179
|
+
end
|
180
|
+
end
|
181
|
+
|
182
|
+
io.write(sentence.chomp + "\n")
|
183
|
+
end
|
184
|
+
}
|
185
|
+
end
|
186
|
+
|
187
|
+
end
|
188
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
|
2
|
+
module PodsOrz
|
3
|
+
|
4
|
+
class PodfileModel
|
5
|
+
|
6
|
+
attr_accessor :name, :git, :path, :configurations, :branch,:tag, :version
|
7
|
+
|
8
|
+
def initialize(sentence)
|
9
|
+
sentence_slip_list = sentence.split(',')
|
10
|
+
return if sentence_slip_list.size.zero?
|
11
|
+
|
12
|
+
for piece in sentence_slip_list do
|
13
|
+
if /:git =>/ =~ piece
|
14
|
+
@git = $~.post_match.strip
|
15
|
+
elsif /:path =>/ =~ piece
|
16
|
+
@path = $~.post_match.strip
|
17
|
+
elsif /:configurations =>/ =~ piece
|
18
|
+
@configurations = $~.post_match.strip
|
19
|
+
elsif /:branch =>/ =~ piece
|
20
|
+
@branch = $~.post_match.strip
|
21
|
+
elsif /:tag =>/ =~ piece
|
22
|
+
@tag = $~.post_match.strip
|
23
|
+
elsif /pod /=~ piece
|
24
|
+
@name = $~.post_match.delete("'\n ")
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
# puts %Q{model name:#{@name},git:#{@git},path:#{@path},config:#{@configurations},branch:#{@branch},tag:#{@tag}}
|
29
|
+
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
@@ -0,0 +1,96 @@
|
|
1
|
+
require "podsorz/core/pod_orzconfig_parse"
|
2
|
+
require "podsorz/util/logger"
|
3
|
+
|
4
|
+
module PodsOrz
|
5
|
+
class PodsDetector
|
6
|
+
attr_accessor :kx_pods_path, :orzconfig_parse
|
7
|
+
|
8
|
+
def initialize(main_path)
|
9
|
+
@kx_pods_path = File.expand_path("../kx_pods", main_path)
|
10
|
+
|
11
|
+
detect_kx_pods(main_path)
|
12
|
+
@orzconfig_parse = PodsOrz::PodOrzconfigParse.new(main_path)
|
13
|
+
end
|
14
|
+
|
15
|
+
def check_directory(main_path)
|
16
|
+
is_directory = File.directory?(main_path)
|
17
|
+
Logger.error("Detect failure, it is not a directory path: #{main_path}") unless is_directory
|
18
|
+
|
19
|
+
is_directory
|
20
|
+
end
|
21
|
+
|
22
|
+
def detect_kx_pods(main_path)
|
23
|
+
|
24
|
+
result = check_directory(main_path)
|
25
|
+
|
26
|
+
if result
|
27
|
+
pods_result = File.directory?(@kx_pods_path)
|
28
|
+
unless pods_result
|
29
|
+
Logger.warning("kx_pods directory not exist, generate default 'kx_pods' directory")
|
30
|
+
Dir.mkdir(@kx_pods_path)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def start_detector()
|
36
|
+
if @orzconfig_parse.fix_pod_list.empty?
|
37
|
+
Logger.warning("Fix pod list is empty, there is nothings to do, please setup 'FIX_POD_LIST' in \"PodsOrzConfig.rb\"")
|
38
|
+
else
|
39
|
+
ensure_kxpods_exist()
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def ensure_kxpods_exist()
|
44
|
+
pods_list = @orzconfig_parse.fix_pod_list
|
45
|
+
is_clone_success = true
|
46
|
+
pods_list.each {|pod|
|
47
|
+
command = Thread.new do
|
48
|
+
each_result = detect_pod(pod)
|
49
|
+
is_clone_success = false unless each_result
|
50
|
+
end
|
51
|
+
|
52
|
+
command.join
|
53
|
+
}
|
54
|
+
|
55
|
+
exit() unless is_clone_success
|
56
|
+
end
|
57
|
+
|
58
|
+
def detect_pod(pod)
|
59
|
+
pod_path = File.expand_path(pod, @kx_pods_path)
|
60
|
+
result = File.directory?(pod_path)
|
61
|
+
if result
|
62
|
+
file_entries = Dir.entries(pod_path)
|
63
|
+
result = false if file_entries.empty?
|
64
|
+
result = false unless file_entries.include?(".git")
|
65
|
+
|
66
|
+
Logger.error("【#{pod}】 at #{pod_path} exist, but .git not work success, please manual check.") unless result
|
67
|
+
else
|
68
|
+
result = clone_orz_pod(pod)
|
69
|
+
end
|
70
|
+
|
71
|
+
result
|
72
|
+
end
|
73
|
+
|
74
|
+
def clone_orz_pod(pod)
|
75
|
+
is_clone_success = true
|
76
|
+
pod_directory = File.expand_path(pod, @kx_pods_path)
|
77
|
+
|
78
|
+
Logger.default("Start clone 【#{pod}】 Project...")
|
79
|
+
git_clone_content = ""
|
80
|
+
IO.popen("git clone git@gitlab.91banban.com:ios_pods/Pods/#{pod}.git #{pod_directory}", :err=>[:child, :out]) {|io|
|
81
|
+
git_clone_content = io.read
|
82
|
+
puts(git_clone_content)
|
83
|
+
is_clone_success = false if git_clone_content.to_s.include? "fatal"
|
84
|
+
}
|
85
|
+
|
86
|
+
if is_clone_success
|
87
|
+
Logger.highlight("Clone 【#{pod}】 success!")
|
88
|
+
else
|
89
|
+
Logger.error("Clone 【#{pod}】 failure!")
|
90
|
+
end
|
91
|
+
|
92
|
+
is_clone_success
|
93
|
+
end
|
94
|
+
|
95
|
+
end
|
96
|
+
end
|
@@ -0,0 +1,429 @@
|
|
1
|
+
require "podsorz/core/pod_orzconfig_parse"
|
2
|
+
require "podsorz/core/pods_git_operator"
|
3
|
+
require "podsorz/core/podfile_io"
|
4
|
+
require "podsorz/core/pods_version"
|
5
|
+
require "podsorz/core/pods_repo"
|
6
|
+
require 'open3'
|
7
|
+
|
8
|
+
module PodsOrz
|
9
|
+
class PodsGitManager
|
10
|
+
attr_accessor :main_path, :orzconfig_parse, :pods_git_operator, :podfile_io, :pods_version, :pods_repo
|
11
|
+
|
12
|
+
def initialize(main_path)
|
13
|
+
@orzconfig_parse = PodsOrz::PodOrzconfigParse.new(main_path)
|
14
|
+
|
15
|
+
kx_pods_path = File.expand_path("../kx_pods", main_path)
|
16
|
+
@pods_git_operator = PodsOrz::PodsGitOperator.new(kx_pods_path, @orzconfig_parse.app_release_version, @orzconfig_parse.branch_author_suffix)
|
17
|
+
|
18
|
+
@podfile_io = PodsOrz::PodfileIO.new(main_path)
|
19
|
+
@podfile_io.output_local_pod(@orzconfig_parse.fix_pod_list)
|
20
|
+
|
21
|
+
@pods_version = PodsOrz::PodsVersion.new(main_path)
|
22
|
+
|
23
|
+
@pods_repo = PodsOrz::PodsRepo.new()
|
24
|
+
end
|
25
|
+
|
26
|
+
#Switch Command --
|
27
|
+
|
28
|
+
def switch_develop_state()
|
29
|
+
is_switch_success = true
|
30
|
+
pods_list = @orzconfig_parse.fix_pod_list
|
31
|
+
|
32
|
+
pods_list.each {|pod|
|
33
|
+
Logger.default("【#{pod}】 begin switch develop...")
|
34
|
+
|
35
|
+
command = Thread.new do
|
36
|
+
each_result = @pods_git_operator.switch_develop_pod(pod)
|
37
|
+
is_switch_success = false unless each_result
|
38
|
+
end
|
39
|
+
|
40
|
+
command.join
|
41
|
+
Logger.separator
|
42
|
+
}
|
43
|
+
exit() unless is_switch_success
|
44
|
+
end
|
45
|
+
|
46
|
+
def switch_feature_state()
|
47
|
+
is_switch_success = true
|
48
|
+
pods_list = @orzconfig_parse.fix_pod_list
|
49
|
+
pods_list.each {|pod|
|
50
|
+
Logger.default("【#{pod}】 begin switch feature...")
|
51
|
+
|
52
|
+
command = Thread.new do
|
53
|
+
each_result = @pods_git_operator.switch_feature_pod(pod)
|
54
|
+
is_switch_success = false unless each_result
|
55
|
+
end
|
56
|
+
|
57
|
+
command.join
|
58
|
+
Logger.separator
|
59
|
+
}
|
60
|
+
exit() unless is_switch_success
|
61
|
+
end
|
62
|
+
|
63
|
+
def switch_release_state()
|
64
|
+
is_switch_success = true
|
65
|
+
pods_list = @orzconfig_parse.fix_pod_list
|
66
|
+
pods_list.each {|pod|
|
67
|
+
Logger.default("【#{pod}】 begin switch release...")
|
68
|
+
|
69
|
+
command = Thread.new do
|
70
|
+
each_result = @pods_git_operator.switch_release_pod(pod)
|
71
|
+
is_switch_success = false unless each_result
|
72
|
+
end
|
73
|
+
|
74
|
+
command.join
|
75
|
+
Logger.separator
|
76
|
+
}
|
77
|
+
exit() unless is_switch_success
|
78
|
+
|
79
|
+
end
|
80
|
+
|
81
|
+
def switch_bugfix_state()
|
82
|
+
is_switch_success = true
|
83
|
+
pods_list = @orzconfig_parse.fix_pod_list
|
84
|
+
pods_list.each {|pod|
|
85
|
+
Logger.default("【#{pod}】 begin switch bugfix...")
|
86
|
+
|
87
|
+
command = Thread.new do
|
88
|
+
each_result = @pods_git_operator.switch_bugfix_pod(pod)
|
89
|
+
is_switch_success = false unless each_result
|
90
|
+
end
|
91
|
+
|
92
|
+
command.join
|
93
|
+
Logger.separator
|
94
|
+
}
|
95
|
+
exit() unless is_switch_success
|
96
|
+
end
|
97
|
+
|
98
|
+
#Commit Command --
|
99
|
+
|
100
|
+
def pod_commit(is_push, is_notify)
|
101
|
+
is_push_success = true
|
102
|
+
|
103
|
+
pods_list = @orzconfig_parse.fix_pod_list
|
104
|
+
pods_list.each {|pod|
|
105
|
+
Logger.default("【#{pod}】 begin commit ...\n")
|
106
|
+
|
107
|
+
command = Thread.new do
|
108
|
+
@pods_git_operator.commit_local(pod)
|
109
|
+
|
110
|
+
if is_push
|
111
|
+
is_push_success = @pods_git_operator.commit_push(pod)
|
112
|
+
end
|
113
|
+
|
114
|
+
if is_notify && is_push_success
|
115
|
+
is_push_success = @pods_git_operator.commit_notify(pod)
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
command.join
|
120
|
+
Logger.separator
|
121
|
+
}
|
122
|
+
|
123
|
+
exit() unless is_push_success
|
124
|
+
|
125
|
+
if is_push && is_notify
|
126
|
+
update_push_podfile_io
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
def update_push_podfile_io
|
131
|
+
branch_name = fetch_pods_branch_name()
|
132
|
+
|
133
|
+
is_develp = branch_name.include? 'develop'
|
134
|
+
is_feature = branch_name.include? 'feature'
|
135
|
+
result = "develop" if is_develp || is_feature
|
136
|
+
|
137
|
+
is_release = branch_name.include? "release"
|
138
|
+
is_bugfix = branch_name.include? "bugfix"
|
139
|
+
result = "release/" + "#{@orzconfig_parse.app_release_version}" if is_release || is_bugfix
|
140
|
+
|
141
|
+
@podfile_io.output_orz_total_sentence(@orzconfig_parse.fix_pod_list, result)
|
142
|
+
end
|
143
|
+
|
144
|
+
def fetch_pods_branch_name
|
145
|
+
return "" if @orzconfig_parse.fix_pod_list.empty?
|
146
|
+
|
147
|
+
first_pod = @orzconfig_parse.fix_pod_list.first
|
148
|
+
|
149
|
+
branch_name = @pods_git_operator.current_pod_branch(first_pod)
|
150
|
+
|
151
|
+
branch_name
|
152
|
+
end
|
153
|
+
|
154
|
+
def ensure_pods_branch()
|
155
|
+
pods_list = @orzconfig_parse.fix_pod_list
|
156
|
+
|
157
|
+
is_same = true
|
158
|
+
branch_name = ""
|
159
|
+
output_lines = []
|
160
|
+
|
161
|
+
pods_list.each do |pod|
|
162
|
+
command = Thread.new do
|
163
|
+
b_name = @pods_git_operator.current_pod_branch(pod)
|
164
|
+
if branch_name.empty?
|
165
|
+
branch_name = b_name
|
166
|
+
end
|
167
|
+
|
168
|
+
unless b_name.eql?(branch_name)
|
169
|
+
is_same = false
|
170
|
+
end
|
171
|
+
|
172
|
+
output_lines << "'#{pod}' current_branch: #{b_name}"
|
173
|
+
end
|
174
|
+
|
175
|
+
command.join
|
176
|
+
end
|
177
|
+
|
178
|
+
unless is_same
|
179
|
+
Logger.error("Fix pod list branch error.Not all pods branch is the same state")
|
180
|
+
output_lines.each do |line|
|
181
|
+
puts line
|
182
|
+
end
|
183
|
+
end
|
184
|
+
|
185
|
+
is_same
|
186
|
+
end
|
187
|
+
|
188
|
+
#Publish Command --
|
189
|
+
|
190
|
+
def start_repo_publish
|
191
|
+
#1.判断 release 是否存在新的commit内容
|
192
|
+
newContent_pod_list = filter_newContent_pods()
|
193
|
+
|
194
|
+
if newContent_pod_list.empty?
|
195
|
+
Logger.warning("All pods do not have new content to publish")
|
196
|
+
else
|
197
|
+
Logger.highlight("Pods have new content to publish ")
|
198
|
+
newContent_pod_list.each do |pod|
|
199
|
+
puts " - #{pod}"
|
200
|
+
end
|
201
|
+
|
202
|
+
#2.Podspec versoin
|
203
|
+
increase_pods_version(newContent_pod_list)
|
204
|
+
|
205
|
+
#3.Merge into master / develop
|
206
|
+
publish_master_develop_branch(newContent_pod_list)
|
207
|
+
|
208
|
+
#4.Tag
|
209
|
+
add_publish_tag(newContent_pod_list)
|
210
|
+
end
|
211
|
+
|
212
|
+
#5.Repo push
|
213
|
+
@pods_repo.check_repo_exist
|
214
|
+
|
215
|
+
pods_repo_push
|
216
|
+
|
217
|
+
#6.Update Podfile_orz
|
218
|
+
update_publish_podfile_orz
|
219
|
+
end
|
220
|
+
|
221
|
+
def filter_newContent_pods()
|
222
|
+
newContent_pod_list = []
|
223
|
+
#filter action
|
224
|
+
pods_list = @orzconfig_parse.fix_pod_list
|
225
|
+
pods_list.each {|pod|
|
226
|
+
command = Thread.new do
|
227
|
+
is_new_publish = @pods_git_operator.has_new_publish(pod)
|
228
|
+
newContent_pod_list << pod if is_new_publish
|
229
|
+
end
|
230
|
+
|
231
|
+
command.join
|
232
|
+
Logger.separator
|
233
|
+
}
|
234
|
+
|
235
|
+
newContent_pod_list
|
236
|
+
end
|
237
|
+
|
238
|
+
def increase_pods_version(pods_list)
|
239
|
+
is_increase_success = true
|
240
|
+
|
241
|
+
pods_list.each {|pod|
|
242
|
+
Logger.default("【#{pod}】start increase podspec version ...\n")
|
243
|
+
|
244
|
+
command = Thread.new do
|
245
|
+
version_number = @pods_version.increase_pod_version(pod)
|
246
|
+
|
247
|
+
if version_number.empty?
|
248
|
+
is_increase_success = false
|
249
|
+
@pods_git_operator.clear_modify_pod(pod)
|
250
|
+
else
|
251
|
+
#3.version update 提交commit
|
252
|
+
commit_success = @pods_git_operator.commit_version_increase(pod, version_number)
|
253
|
+
unless commit_success
|
254
|
+
is_increase_success = false
|
255
|
+
@pods_git_operator.clear_modify_pod(pod)
|
256
|
+
end
|
257
|
+
end
|
258
|
+
end
|
259
|
+
|
260
|
+
command.join
|
261
|
+
Logger.separator
|
262
|
+
}
|
263
|
+
|
264
|
+
exit() unless is_increase_success
|
265
|
+
end
|
266
|
+
|
267
|
+
def publish_master_develop_branch(pods_list)
|
268
|
+
is_publish_success = true
|
269
|
+
pods_list.each {|pod|
|
270
|
+
Logger.default("【#{pod}】start merge into master & develop ...\n")
|
271
|
+
|
272
|
+
command = Thread.new do
|
273
|
+
each_result = @pods_git_operator.publish_merge(pod)
|
274
|
+
is_publish_success = false unless each_result
|
275
|
+
end
|
276
|
+
|
277
|
+
command.join
|
278
|
+
Logger.separator
|
279
|
+
}
|
280
|
+
|
281
|
+
exit() unless is_publish_success
|
282
|
+
end
|
283
|
+
|
284
|
+
def add_publish_tag(pods_list)
|
285
|
+
is_add_success = true
|
286
|
+
pods_list.each {|pod|
|
287
|
+
tag = @pods_version.get_podspec_version(pod)
|
288
|
+
if tag.empty?
|
289
|
+
is_add_success = false
|
290
|
+
exit()
|
291
|
+
end
|
292
|
+
|
293
|
+
Logger.default("【#{pod}】will add tag: #{tag} \n")
|
294
|
+
|
295
|
+
command = Thread.new do
|
296
|
+
each_result = @pods_git_operator.add_pod_tag(pod, tag)
|
297
|
+
is_add_success = false unless each_result
|
298
|
+
end
|
299
|
+
|
300
|
+
command.join
|
301
|
+
Logger.separator
|
302
|
+
}
|
303
|
+
|
304
|
+
exit() unless is_add_success
|
305
|
+
end
|
306
|
+
|
307
|
+
def delete_publish_tag(pods_list)
|
308
|
+
pods_list.each {|pod|
|
309
|
+
tag = @pods_version.get_podspec_version(pod)
|
310
|
+
if tag.empty?
|
311
|
+
exit()
|
312
|
+
end
|
313
|
+
|
314
|
+
Logger.default("【#{pod}】will delete tag: #{tag} \n")
|
315
|
+
|
316
|
+
command = Thread.new do
|
317
|
+
@pods_git_operator.delete_pod_tag(pod, tag)
|
318
|
+
end
|
319
|
+
|
320
|
+
command.join
|
321
|
+
Logger.separator
|
322
|
+
}
|
323
|
+
end
|
324
|
+
|
325
|
+
def pods_repo_push
|
326
|
+
is_push_success = true
|
327
|
+
|
328
|
+
pods_list = @orzconfig_parse.fix_pod_list
|
329
|
+
pods_list.each {|pod|
|
330
|
+
Logger.default("【#{pod}】check pod_version, git_tag, remote_version...")
|
331
|
+
|
332
|
+
command = Thread.new do
|
333
|
+
p_version = @pods_version.get_podspec_version(pod)
|
334
|
+
if p_version.empty?
|
335
|
+
is_push_success = false
|
336
|
+
exit()
|
337
|
+
end
|
338
|
+
|
339
|
+
git_tag = @pods_git_operator.get_pod_git_tag(pod)
|
340
|
+
local_result = @pods_repo.ensure_local_pod_version_tag(pod, p_version, git_tag)
|
341
|
+
case local_result
|
342
|
+
when -1
|
343
|
+
#error
|
344
|
+
is_push_success = false
|
345
|
+
exit()
|
346
|
+
when 0
|
347
|
+
#the same version, push ready
|
348
|
+
when 1
|
349
|
+
#need add new git tag
|
350
|
+
is_add_success = @pods_git_operator.add_pod_tag(pod, p_version)
|
351
|
+
end
|
352
|
+
|
353
|
+
remote_result = @pods_repo.ensure_remote_pod_version(pod, p_version)
|
354
|
+
case remote_result
|
355
|
+
when -1
|
356
|
+
#error
|
357
|
+
is_push_success = false
|
358
|
+
exit()
|
359
|
+
when 0
|
360
|
+
#the same version, nothing to update
|
361
|
+
when 1
|
362
|
+
#update remote
|
363
|
+
file_path = @pods_git_operator.get_pod_file_path(pod)
|
364
|
+
is_update_success = @pods_repo.push_pod_remote(pod, file_path, p_version)
|
365
|
+
unless is_update_success
|
366
|
+
delete_tag_list = []
|
367
|
+
delete_tag_list << pod
|
368
|
+
delete_publish_tag(delete_tag_list)
|
369
|
+
|
370
|
+
is_push_success = false
|
371
|
+
exit()
|
372
|
+
end
|
373
|
+
end
|
374
|
+
end
|
375
|
+
|
376
|
+
command.join
|
377
|
+
Logger.separator
|
378
|
+
}
|
379
|
+
|
380
|
+
exit() unless is_push_success
|
381
|
+
|
382
|
+
end
|
383
|
+
|
384
|
+
def update_publish_podfile_orz
|
385
|
+
is_update_success = true
|
386
|
+
pod_hash = Hash.new()
|
387
|
+
|
388
|
+
pods_list = @orzconfig_parse.fix_pod_list
|
389
|
+
pods_list.each {|pod|
|
390
|
+
command = Thread.new do
|
391
|
+
pod_version = @pods_version.get_podspec_version(pod)
|
392
|
+
if pod_version.empty?
|
393
|
+
is_update_success = false
|
394
|
+
exit()
|
395
|
+
end
|
396
|
+
|
397
|
+
pod_hash[pod] = pod_version
|
398
|
+
end
|
399
|
+
|
400
|
+
command.join
|
401
|
+
}
|
402
|
+
|
403
|
+
exit() unless is_update_success
|
404
|
+
|
405
|
+
@podfile_io.output_publish_total_sentence(pod_hash)
|
406
|
+
end
|
407
|
+
|
408
|
+
#Install Command --
|
409
|
+
|
410
|
+
def install_pod(main_path)
|
411
|
+
command = Thread.new do
|
412
|
+
@pods_repo.check_repo_exist
|
413
|
+
@podfile_io.output_local_total_sentence
|
414
|
+
end
|
415
|
+
|
416
|
+
command.join
|
417
|
+
|
418
|
+
command = Thread.new do
|
419
|
+
Open3.popen3("cd #{main_path};pod update --no-repo-update --verbose") do |stdin , stdout , stderr, wait_thr|
|
420
|
+
while line = stdout.gets
|
421
|
+
puts line
|
422
|
+
end
|
423
|
+
end
|
424
|
+
end
|
425
|
+
|
426
|
+
command.join
|
427
|
+
end
|
428
|
+
end
|
429
|
+
end
|