Class: PodsOrz::PodsGitManager
- Inherits:
-
Object
- Object
- PodsOrz::PodsGitManager
- Defined in:
- lib/podsorz/core/PodsOrz/pods_git_manager.rb
Instance Attribute Summary collapse
-
#main_path ⇒ Object
Returns the value of attribute main_path.
-
#orzconfig_parse ⇒ Object
Returns the value of attribute orzconfig_parse.
-
#podfile_io ⇒ Object
Returns the value of attribute podfile_io.
-
#pods_git_operator ⇒ Object
Returns the value of attribute pods_git_operator.
-
#pods_repo ⇒ Object
Returns the value of attribute pods_repo.
-
#pods_version ⇒ Object
Returns the value of attribute pods_version.
Instance Method Summary collapse
- #add_publish_tag(pods_list) ⇒ Object
-
#cmd_sync_pod(rebase_branch) ⇒ Object
Sync Command –.
- #delete_publish_tag(pods_list) ⇒ Object
- #ensure_pods_branch ⇒ Object
- #fetch_pods_branch_name ⇒ Object
- #filter_develop_newContent ⇒ Object
- #filter_master_newContent ⇒ Object
- #increase_pods_version(pods_list) ⇒ Object
-
#initialize(main_path) ⇒ PodsGitManager
constructor
A new instance of PodsGitManager.
-
#install_pod(main_path, binary_pods_list) ⇒ Object
Install Command –.
-
#pod_commit(is_push, is_notify) ⇒ Object
Commit Command –.
- #pods_repo_push(is_swift) ⇒ Object
- #publish_develop_branch(pods_list) ⇒ Object
- #publish_master_branch(pods_list) ⇒ Object
-
#start_repo_publish(is_swift) ⇒ Object
Publish Command –.
- #switch_bugfix_state ⇒ Object
-
#switch_develop_state ⇒ Object
Switch Command –.
- #switch_feature_state ⇒ Object
- #switch_release_state ⇒ Object
- #update_publish_podfile_orz ⇒ Object
- #update_push_podfile_io ⇒ Object
Constructor Details
#initialize(main_path) ⇒ PodsGitManager
Returns a new instance of PodsGitManager.
13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/podsorz/core/PodsOrz/pods_git_manager.rb', line 13 def initialize(main_path) @orzconfig_parse = PodsOrz::PodOrzconfigParse.new(main_path) kx_pods_path = File.("../#{@orzconfig_parse.file_devpods_name}", main_path) @pods_git_operator = PodsOrz::PodsGitOperator.new(kx_pods_path, @orzconfig_parse.app_release_version, @orzconfig_parse.) @podfile_io = PodsOrz::PodfileIO.new(main_path) @podfile_io.load_config_local_pod(@orzconfig_parse.fix_pod_list) @pods_version = PodsOrz::PodsVersion.new(main_path) @pods_repo = PodsOrz::PodsRepo.new(main_path) end |
Instance Attribute Details
#main_path ⇒ Object
Returns the value of attribute main_path.
11 12 13 |
# File 'lib/podsorz/core/PodsOrz/pods_git_manager.rb', line 11 def main_path @main_path end |
#orzconfig_parse ⇒ Object
Returns the value of attribute orzconfig_parse.
11 12 13 |
# File 'lib/podsorz/core/PodsOrz/pods_git_manager.rb', line 11 def orzconfig_parse @orzconfig_parse end |
#podfile_io ⇒ Object
Returns the value of attribute podfile_io.
11 12 13 |
# File 'lib/podsorz/core/PodsOrz/pods_git_manager.rb', line 11 def podfile_io @podfile_io end |
#pods_git_operator ⇒ Object
Returns the value of attribute pods_git_operator.
11 12 13 |
# File 'lib/podsorz/core/PodsOrz/pods_git_manager.rb', line 11 def pods_git_operator @pods_git_operator end |
#pods_repo ⇒ Object
Returns the value of attribute pods_repo.
11 12 13 |
# File 'lib/podsorz/core/PodsOrz/pods_git_manager.rb', line 11 def pods_repo @pods_repo end |
#pods_version ⇒ Object
Returns the value of attribute pods_version.
11 12 13 |
# File 'lib/podsorz/core/PodsOrz/pods_git_manager.rb', line 11 def pods_version @pods_version end |
Instance Method Details
#add_publish_tag(pods_list) ⇒ Object
336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 |
# File 'lib/podsorz/core/PodsOrz/pods_git_manager.rb', line 336 def add_publish_tag(pods_list) is_add_success = true pods_list.each {|pod| tag = @pods_version.get_podspec_version(pod) if tag.empty? is_add_success = false exit() end Logger.default("【#{pod}】will add tag: #{tag} \n") command = Thread.new do each_result = @pods_git_operator.add_pod_tag(pod, tag) is_add_success = false unless each_result end command.join Logger.separator } exit() unless is_add_success end |
#cmd_sync_pod(rebase_branch) ⇒ Object
Sync Command –
491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 |
# File 'lib/podsorz/core/PodsOrz/pods_git_manager.rb', line 491 def cmd_sync_pod(rebase_branch) is_sync_success = true pods_list = @orzconfig_parse.fix_pod_list pods_list.each {|pod| Logger.default("【#{pod}】 begin sync ...\n") command = Thread.new do each_result = @pods_git_operator.sync_pod(pod, rebase_branch) is_sync_success = false unless each_result end command.join Logger.separator } exit() unless is_sync_success end |
#delete_publish_tag(pods_list) ⇒ Object
359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 |
# File 'lib/podsorz/core/PodsOrz/pods_git_manager.rb', line 359 def delete_publish_tag(pods_list) pods_list.each {|pod| tag = @pods_version.get_podspec_version(pod) if tag.empty? exit() end Logger.default("【#{pod}】will delete tag: #{tag} \n") command = Thread.new do @pods_git_operator.delete_pod_tag(pod, tag) end command.join Logger.separator } end |
#ensure_pods_branch ⇒ Object
157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 |
# File 'lib/podsorz/core/PodsOrz/pods_git_manager.rb', line 157 def ensure_pods_branch() pods_list = @orzconfig_parse.fix_pod_list is_same = true branch_name = "" output_lines = [] pods_list.each do |pod| command = Thread.new do b_name = @pods_git_operator.current_pod_branch(pod) if branch_name.empty? branch_name = b_name end unless b_name.eql?(branch_name) is_same = false end output_lines << "'#{pod}' current_branch: #{b_name}" end command.join end unless is_same Logger.error("Fix pod list branch error.Not all pods branch is the same state") output_lines.each do |line| puts line end end is_same end |
#fetch_pods_branch_name ⇒ Object
147 148 149 150 151 152 153 154 155 |
# File 'lib/podsorz/core/PodsOrz/pods_git_manager.rb', line 147 def fetch_pods_branch_name return "" if @orzconfig_parse.fix_pod_list.empty? first_pod = @orzconfig_parse.fix_pod_list.first branch_name = @pods_git_operator.current_pod_branch(first_pod) branch_name end |
#filter_develop_newContent ⇒ Object
256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 |
# File 'lib/podsorz/core/PodsOrz/pods_git_manager.rb', line 256 def filter_develop_newContent() newContent_pod_list = [] #filter action pods_list = @orzconfig_parse.fix_pod_list pods_list.each {|pod| command = Thread.new do is_new_publish = @pods_git_operator.has_new_publish(pod, "develop") newContent_pod_list << pod if is_new_publish end command.join Logger.separator } newContent_pod_list end |
#filter_master_newContent ⇒ Object
239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 |
# File 'lib/podsorz/core/PodsOrz/pods_git_manager.rb', line 239 def filter_master_newContent() newContent_pod_list = [] #filter action pods_list = @orzconfig_parse.fix_pod_list pods_list.each {|pod| command = Thread.new do is_new_publish = @pods_git_operator.has_new_publish(pod, "master") newContent_pod_list << pod if is_new_publish end command.join Logger.separator } newContent_pod_list end |
#increase_pods_version(pods_list) ⇒ Object
273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 |
# File 'lib/podsorz/core/PodsOrz/pods_git_manager.rb', line 273 def increase_pods_version(pods_list) is_increase_success = true pods_list.each {|pod| Logger.default("【#{pod}】start increase podspec version ...\n") command = Thread.new do version_number = @pods_version.increase_pod_version(pod) if version_number.empty? is_increase_success = false @pods_git_operator.clear_modify_pod(pod) else #3.version update 提交commit commit_success = @pods_git_operator.commit_version_increase(pod, version_number) unless commit_success is_increase_success = false @pods_git_operator.clear_modify_pod(pod) end end end command.join Logger.separator } exit() unless is_increase_success end |
#install_pod(main_path, binary_pods_list) ⇒ Object
Install Command –
470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 |
# File 'lib/podsorz/core/PodsOrz/pods_git_manager.rb', line 470 def install_pod(main_path, binary_pods_list) command = Thread.new do @pods_repo.check_repo_exist @podfile_io.output_local_binary_sentence(binary_pods_list) @podfile_io.output_local_total_sentence() end command.join command = Thread.new do Open3.popen3("cd #{main_path};pod update") do |stdin , stdout , stderr, wait_thr| while line = stdout.gets puts line end end end command.join end |
#pod_commit(is_push, is_notify) ⇒ Object
Commit Command –
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 |
# File 'lib/podsorz/core/PodsOrz/pods_git_manager.rb', line 101 def pod_commit(is_push, is_notify) is_commit_success = true pods_list = @orzconfig_parse.fix_pod_list pods_list.each {|pod| Logger.default("【#{pod}】 begin commit ...\n") command = Thread.new do @pods_git_operator.commit_local(pod) if is_push is_push_success = @pods_git_operator.commit_push(pod) is_commit_success = false unless is_push_success end if is_notify && is_push_success is_notify_success = @pods_git_operator.commit_notify(pod) is_commit_success = false unless is_notify_success end end command.join Logger.separator } exit() unless is_commit_success if is_push && is_notify update_push_podfile_io end end |
#pods_repo_push(is_swift) ⇒ Object
377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 |
# File 'lib/podsorz/core/PodsOrz/pods_git_manager.rb', line 377 def pods_repo_push(is_swift) is_push_success = true pods_list = @orzconfig_parse.fix_pod_list if pods_list.empty? Logger.warning("fix_pods is empty nothing to do") else pods_sort = PodsOrz::PodsSort.new() kx_pods_subPath = @pods_git_operator.get_pod_file_path("") pods_list = pods_sort.sort(pods_list,kx_pods_subPath) end pods_list.each {|pod| Logger.default("【#{pod}】check pod_version, git_tag, remote_version...") command = Thread.new do p_version = @pods_version.get_podspec_version(pod) if p_version.empty? is_push_success = false exit() end git_tag = @pods_git_operator.get_pod_git_tag(pod) local_result = @pods_repo.ensure_local_pod_version_tag(pod, p_version, git_tag) case local_result when -1 #error is_push_success = false exit() when 0 #the same version, push ready when 1 #need add new git tag is_add_success = @pods_git_operator.add_pod_tag(pod, p_version) end remote_result = @pods_repo.ensure_remote_pod_version(pod, p_version) case remote_result when -1 #error is_push_success = false exit() when 0 #the same version, nothing to update when 1 #update remote file_path = @pods_git_operator.get_pod_file_path(pod) is_update_success = @pods_repo.push_pod_remote(pod, file_path, p_version, is_swift) unless is_update_success delete_tag_list = [] delete_tag_list << pod delete_publish_tag(delete_tag_list) is_push_success = false exit() end end end command.join Logger.separator } exit() unless is_push_success end |
#publish_develop_branch(pods_list) ⇒ Object
319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 |
# File 'lib/podsorz/core/PodsOrz/pods_git_manager.rb', line 319 def publish_develop_branch(pods_list) is_publish_success = true pods_list.each {|pod| Logger.default("【#{pod}】start merge into develop ...\n") command = Thread.new do each_result = @pods_git_operator.publish_merge(pod, "develop") is_publish_success = false unless each_result end command.join Logger.separator } exit() unless is_publish_success end |
#publish_master_branch(pods_list) ⇒ Object
302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 |
# File 'lib/podsorz/core/PodsOrz/pods_git_manager.rb', line 302 def publish_master_branch(pods_list) is_publish_success = true pods_list.each {|pod| Logger.default("【#{pod}】start merge into master ...\n") command = Thread.new do each_result = @pods_git_operator.publish_merge(pod, "master") is_publish_success = false unless each_result end command.join Logger.separator } exit() unless is_publish_success end |
#start_repo_publish(is_swift) ⇒ Object
Publish Command –
193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 |
# File 'lib/podsorz/core/PodsOrz/pods_git_manager.rb', line 193 def start_repo_publish(is_swift) if is_swift pods_list = @orzconfig_parse.fix_pod_list if pods_list.length > 1 Logger.error("Swift pod count > 1, please publish swift pod one by one") exit() end end #1.判断 release 和master 比较是否存在新的commit内容 newContent_pod_list = filter_master_newContent() if newContent_pod_list.empty? Logger.warning("All pods do not have new content to publish") else Logger.highlight("Pods have new content to publish ") newContent_pod_list.each do |pod| puts " - #{pod}" end #2.Podspec versoin increase_pods_version(newContent_pod_list) #3.Merge into master publish_master_branch(newContent_pod_list) #4.Tag add_publish_tag(newContent_pod_list) end #5.Repo push @pods_repo.check_repo_exist pods_repo_push(is_swift) #6.Update Podfile_orz update_publish_podfile_orz #7.diff content from develop branch newContent_pod_list = filter_develop_newContent() #8.Merge into develop publish_develop_branch(newContent_pod_list) end |
#switch_bugfix_state ⇒ Object
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/podsorz/core/PodsOrz/pods_git_manager.rb', line 82 def switch_bugfix_state() is_switch_success = true pods_list = @orzconfig_parse.fix_pod_list pods_list.each {|pod| Logger.default("【#{pod}】 begin switch bugfix...") command = Thread.new do each_result = @pods_git_operator.switch_bugfix_pod(pod) is_switch_success = false unless each_result end command.join Logger.separator } exit() unless is_switch_success end |
#switch_develop_state ⇒ Object
Switch Command –
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/podsorz/core/PodsOrz/pods_git_manager.rb', line 29 def switch_develop_state() is_switch_success = true pods_list = @orzconfig_parse.fix_pod_list pods_list.each {|pod| Logger.default("【#{pod}】 begin switch develop...") command = Thread.new do each_result = @pods_git_operator.switch_develop_pod(pod) is_switch_success = false unless each_result end command.join Logger.separator } exit() unless is_switch_success end |
#switch_feature_state ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/podsorz/core/PodsOrz/pods_git_manager.rb', line 47 def switch_feature_state() is_switch_success = true pods_list = @orzconfig_parse.fix_pod_list pods_list.each {|pod| Logger.default("【#{pod}】 begin switch feature...") command = Thread.new do each_result = @pods_git_operator.switch_feature_pod(pod) is_switch_success = false unless each_result end command.join Logger.separator } exit() unless is_switch_success end |
#switch_release_state ⇒ Object
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/podsorz/core/PodsOrz/pods_git_manager.rb', line 64 def switch_release_state() is_switch_success = true pods_list = @orzconfig_parse.fix_pod_list pods_list.each {|pod| Logger.default("【#{pod}】 begin switch release...") command = Thread.new do each_result = @pods_git_operator.switch_release_pod(pod) is_switch_success = false unless each_result end command.join Logger.separator } exit() unless is_switch_success end |
#update_publish_podfile_orz ⇒ Object
444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 |
# File 'lib/podsorz/core/PodsOrz/pods_git_manager.rb', line 444 def update_publish_podfile_orz is_update_success = true pod_hash = Hash.new() pods_list = @orzconfig_parse.fix_pod_list pods_list.each {|pod| command = Thread.new do pod_version = @pods_version.get_podspec_version(pod) if pod_version.empty? is_update_success = false exit() end pod_hash[pod] = pod_version end command.join } exit() unless is_update_success @podfile_io.output_publish_total_sentence(pod_hash) end |
#update_push_podfile_io ⇒ Object
133 134 135 136 137 138 139 140 141 142 143 144 145 |
# File 'lib/podsorz/core/PodsOrz/pods_git_manager.rb', line 133 def update_push_podfile_io branch_name = fetch_pods_branch_name() is_develp = branch_name.include? 'develop' is_feature = branch_name.include? 'feature' result = "develop" if is_develp || is_feature is_release = branch_name.include? "release" is_bugfix = branch_name.include? "bugfix" result = "release/" + "#{@orzconfig_parse.app_release_version}" if is_release || is_bugfix @podfile_io.output_orz_total_sentence(@orzconfig_parse.fix_pod_list, result) end |