podsorz 0.0.2 → 0.0.7

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.
Files changed (31) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +16 -13
  3. data/lib/podsorz.rb +12 -2
  4. data/lib/podsorz/command/binary.rb +150 -0
  5. data/lib/podsorz/command/commit.rb +2 -2
  6. data/lib/podsorz/command/install.rb +9 -3
  7. data/lib/podsorz/command/publish.rb +7 -3
  8. data/lib/podsorz/command/setup.rb +1 -1
  9. data/lib/podsorz/command/switch.rb +2 -2
  10. data/lib/podsorz/command/sync.rb +2 -2
  11. data/lib/podsorz/core/Binary/binary_builder.rb +312 -0
  12. data/lib/podsorz/core/Binary/binary_manager.rb +173 -0
  13. data/lib/podsorz/core/Binary/binary_repo.rb +178 -0
  14. data/lib/podsorz/core/Binary/binary_server.rb +21 -0
  15. data/lib/podsorz/core/Config/orz_config_templet.rb +31 -0
  16. data/lib/podsorz/core/{orz_env_detector.rb → Config/orz_env_detector.rb} +1 -1
  17. data/lib/podsorz/core/{pod_orzconfig_parse.rb → Config/pod_orzconfig_parse.rb} +15 -1
  18. data/lib/podsorz/core/{podfile_io.rb → PodFile/podfile_io.rb} +143 -4
  19. data/lib/podsorz/core/{podfile_model.rb → PodFile/podfile_model.rb} +26 -1
  20. data/lib/podsorz/core/{pods_detector.rb → PodsOrz/pods_detector.rb} +1 -1
  21. data/lib/podsorz/core/{pods_git_manager.rb → PodsOrz/pods_git_manager.rb} +22 -12
  22. data/lib/podsorz/core/{pods_git_operator.rb → PodsOrz/pods_git_operator.rb} +134 -37
  23. data/lib/podsorz/core/{pods_repo.rb → PodsOrz/pods_repo.rb} +44 -11
  24. data/lib/podsorz/core/{pods_version.rb → PodsOrz/pods_version.rb} +4 -1
  25. data/lib/podsorz/core/Specs/podspec_model.rb +45 -0
  26. data/lib/podsorz/util/git_operator.rb +47 -0
  27. data/lib/podsorz/version.rb +1 -1
  28. data/podsorz.gemspec +11 -1
  29. metadata +35 -15
  30. data/Note +0 -3
  31. data/lib/podsorz/core/orz_config_templet.rb +0 -13
@@ -1,17 +1,76 @@
1
1
  require "podsorz/util/logger"
2
- require "podsorz/core/podfile_model"
2
+ require "podsorz/core/PodFile/podfile_model"
3
3
 
4
4
  module PodsOrz
5
5
 
6
6
  class PodfileIO
7
- attr_accessor :main_path, :total_sentences, :usable_sentences, :total_pod_models
7
+ attr_accessor :main_path, :total_sentences, :usable_sentences, :total_pod_models, :http_host
8
8
 
9
9
  def initialize(main_path)
10
10
  @main_path = main_path
11
+ @http_host = "http://192.168.6.23:8080"
11
12
 
12
13
  self.parse_podfile_orz
13
14
  end
14
15
 
16
+ def filter_binary_pod_models()
17
+ filter_result_models = []
18
+
19
+ filter_strings = ["sourceVendorPods", "subspecPods", "kxPods"]
20
+
21
+ result_lines = []
22
+
23
+ switch_flag = false
24
+ filter_strings.each do |f_str|
25
+ @total_sentences.each do |line|
26
+ if line.include? f_str
27
+ switch_flag = true
28
+ end
29
+
30
+ result_lines << line if switch_flag
31
+
32
+ if line.include? "正则匹配注释#{f_str}"
33
+ switch_flag = false
34
+ break
35
+ end
36
+ end
37
+ end
38
+
39
+ result_lines.each do |line|
40
+ podfile_model = PodsOrz::PodfileModel.validate_podfile_sentence_instance(line)
41
+ filter_result_models << podfile_model unless podfile_model.nil?
42
+ end
43
+
44
+ filter_result_models
45
+ end
46
+
47
+ def get_podfile_pod_version(pod)
48
+ pod_version = ""
49
+ @total_pod_models.each do |model|
50
+ if model.name == pod
51
+ pod_version = model.version
52
+ break
53
+ end
54
+ end
55
+
56
+ pod_version = "" if pod_version.nil?
57
+
58
+ pod_version
59
+ end
60
+
61
+ def get_podfile_pod_branch(pod)
62
+ branch = ""
63
+ @total_pod_models.each do |model|
64
+ if model.name == pod
65
+ branch = model.branch
66
+ break
67
+ end
68
+ end
69
+
70
+ branch = "" if branch.nil?
71
+
72
+ branch
73
+ end
15
74
 
16
75
  def parse_podfile_orz
17
76
  orz_file_path = File.expand_path("Podfile_orz.rb", @main_path)
@@ -40,8 +99,7 @@ module PodsOrz
40
99
 
41
100
  end
42
101
 
43
-
44
- def output_local_pod(pod_name_list)
102
+ def load_config_local_pod(pod_name_list)
45
103
  pod_name_list.each do |podname|
46
104
  @total_pod_models.map { |model|
47
105
  if model.name.start_with? podname.to_s
@@ -89,6 +147,14 @@ module PodsOrz
89
147
  if model.configurations
90
148
  sentence = sentence + ", :configurations => " + model.configurations.to_s
91
149
  end
150
+
151
+ if model.modular_headers
152
+ sentence = sentence + ", :modular_headers => " + model.modular_headers.to_s
153
+ end
154
+
155
+ if model.subspecs
156
+ sentence = sentence + ", :subspecs => " + model.subspecs.to_s
157
+ end
92
158
 
93
159
  puts(sentence.chomp + "\n")
94
160
  end
@@ -123,6 +189,14 @@ module PodsOrz
123
189
  if model.configurations
124
190
  sentence = sentence + ", :configurations => " + model.configurations.to_s
125
191
  end
192
+
193
+ if model.modular_headers
194
+ sentence = sentence + ", :modular_headers => " + model.modular_headers.to_s
195
+ end
196
+
197
+ if model.subspecs
198
+ sentence = sentence + ", :subspecs => " + model.subspecs.to_s
199
+ end
126
200
 
127
201
  sentence = sentence + "\n"
128
202
  puts(sentence)
@@ -170,6 +244,12 @@ module PodsOrz
170
244
  if model.configurations
171
245
  sentence = sentence + ", :configurations => " + model.configurations.to_s
172
246
  end
247
+ if model.modular_headers
248
+ sentence = sentence + ", :modular_headers => " + model.modular_headers.to_s
249
+ end
250
+ if model.subspecs
251
+ sentence = sentence + ", :subspecs => " + model.subspecs.to_s
252
+ end
173
253
 
174
254
  puts(sentence.chomp + "\n")
175
255
  end
@@ -183,5 +263,64 @@ module PodsOrz
183
263
  }
184
264
  end
185
265
 
266
+ #binary output
267
+
268
+ def output_local_binary_sentence(binary_pods_list)
269
+ return if binary_pods_list.empty?
270
+
271
+ load_config_binary_pod(binary_pods_list)
272
+
273
+ cocoas_podfile_path = File.expand_path("Podfile", @main_path)
274
+
275
+ output_pod_list = @total_pod_models.reject { |model|
276
+ podspec = model.podspec
277
+ podspec.to_s.empty?
278
+ }
279
+
280
+ File.open(cocoas_podfile_path, "w+") {|io|
281
+ Logger.highlight("Podfile binary podspec completed!")
282
+
283
+ @usable_sentences.map! do |sentence|
284
+ output_pod_list.each do |model|
285
+ filter_str = "\'#{model.name}\'"
286
+ if sentence.include? filter_str
287
+ splite_list = sentence.split(filter_str)
288
+ sentence = splite_list[0].to_s + filter_str + ", :podspec => " + "\'#{model.podspec.to_s}\'"
289
+ if model.configurations
290
+ sentence = sentence + ", :configurations => " + model.configurations.to_s
291
+ end
292
+
293
+ if model.modular_headers
294
+ sentence = sentence + ", :modular_headers => " + model.modular_headers.to_s
295
+ end
296
+
297
+ if model.subspecs
298
+ sentence = sentence + ", :subspecs => " + model.subspecs.to_s
299
+ end
300
+
301
+ sentence = sentence + "\n"
302
+ puts(sentence)
303
+ end
304
+ end
305
+
306
+ io.write(sentence + "\n")
307
+
308
+ sentence
309
+ end
310
+ }
311
+ end
312
+
313
+ def load_config_binary_pod(pod_name_list)
314
+ pod_name_list.each do |podname|
315
+ @total_pod_models.map { |model|
316
+ if model.name.start_with? podname.to_s
317
+ model.podspec = "#{@http_host}/#{model.name}/#{model.version}/#{model.name}.podspec" unless model.version.nil?
318
+ end
319
+ }
320
+ end
321
+ end
322
+
323
+ #class end
324
+
186
325
  end
187
326
  end
@@ -3,7 +3,22 @@ module PodsOrz
3
3
 
4
4
  class PodfileModel
5
5
 
6
- attr_accessor :name, :git, :path, :configurations, :branch,:tag, :version
6
+ attr_accessor :name, :git, :path, :branch,:tag, :version, :podspec, :configurations, :modular_headers, :subspecs
7
+
8
+ def self.validate_podfile_sentence_instance(sentence)
9
+ result_model = nil
10
+
11
+ sentence = sentence.strip.chomp
12
+ unless sentence.empty? || sentence.size.zero?
13
+ unless sentence.start_with?("#")
14
+ if sentence.start_with?("pod ")
15
+ result_model = PodsOrz::PodfileModel.new(sentence)
16
+ end
17
+ end
18
+ end
19
+
20
+ result_model
21
+ end
7
22
 
8
23
  def initialize(sentence)
9
24
  sentence_slip_list = sentence.split(',')
@@ -16,12 +31,20 @@ module PodsOrz
16
31
  @path = $~.post_match.strip
17
32
  elsif /:configurations =>/ =~ piece
18
33
  @configurations = $~.post_match.strip
34
+ elsif /:modular_headers =>/ =~ piece
35
+ @modular_headers = $~.post_match.strip
19
36
  elsif /:branch =>/ =~ piece
20
37
  @branch = $~.post_match.strip
21
38
  elsif /:tag =>/ =~ piece
22
39
  @tag = $~.post_match.strip
23
40
  elsif /pod /=~ piece
24
41
  @name = $~.post_match.delete("'\n ")
42
+ elsif /:subspecs =>/ =~ piece
43
+ @subspecs = $~.post_match.strip
44
+ else
45
+ mt = /\'\d{1,}\..*\d{1,}\'/.match(piece)
46
+ @version = mt[0].gsub(/[\'\"]/, "") unless mt.nil?
47
+
25
48
  end
26
49
  end
27
50
 
@@ -29,6 +52,8 @@ module PodsOrz
29
52
 
30
53
  end
31
54
 
55
+
56
+ #class end
32
57
  end
33
58
 
34
59
  end
@@ -1,4 +1,4 @@
1
- require "podsorz/core/pod_orzconfig_parse"
1
+ require "podsorz/core/Config/pod_orzconfig_parse"
2
2
  require "podsorz/util/logger"
3
3
 
4
4
  module PodsOrz
@@ -1,8 +1,8 @@
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"
1
+ require "podsorz/core/Config/pod_orzconfig_parse"
2
+ require "podsorz/core/PodsOrz/pods_git_operator"
3
+ require "podsorz/core/PodFile/podfile_io"
4
+ require "podsorz/core/PodsOrz/pods_version"
5
+ require "podsorz/core/PodsOrz/pods_repo"
6
6
  require 'open3'
7
7
 
8
8
  module PodsOrz
@@ -16,7 +16,7 @@ module PodsOrz
16
16
  @pods_git_operator = PodsOrz::PodsGitOperator.new(kx_pods_path, @orzconfig_parse.app_release_version, @orzconfig_parse.branch_author_suffix)
17
17
 
18
18
  @podfile_io = PodsOrz::PodfileIO.new(main_path)
19
- @podfile_io.output_local_pod(@orzconfig_parse.fix_pod_list)
19
+ @podfile_io.load_config_local_pod(@orzconfig_parse.fix_pod_list)
20
20
 
21
21
  @pods_version = PodsOrz::PodsVersion.new(main_path)
22
22
 
@@ -189,7 +189,16 @@ module PodsOrz
189
189
 
190
190
  #Publish Command --
191
191
 
192
- def start_repo_publish
192
+ def start_repo_publish(is_swift)
193
+ if is_swift
194
+ pods_list = @orzconfig_parse.fix_pod_list
195
+ if pods_list.length > 1
196
+ Logger.error("Swift pod count > 1, please publish swift pod one by one")
197
+ exit()
198
+ end
199
+ end
200
+
201
+
193
202
  #1.判断 release 是否存在新的commit内容
194
203
  newContent_pod_list = filter_newContent_pods()
195
204
 
@@ -214,7 +223,7 @@ module PodsOrz
214
223
  #5.Repo push
215
224
  @pods_repo.check_repo_exist
216
225
 
217
- pods_repo_push
226
+ pods_repo_push(is_swift)
218
227
 
219
228
  #6.Update Podfile_orz
220
229
  update_publish_podfile_orz
@@ -344,7 +353,7 @@ module PodsOrz
344
353
  }
345
354
  end
346
355
 
347
- def pods_repo_push
356
+ def pods_repo_push(is_swift)
348
357
  is_push_success = true
349
358
 
350
359
  pods_list = @orzconfig_parse.fix_pod_list
@@ -383,7 +392,7 @@ module PodsOrz
383
392
  when 1
384
393
  #update remote
385
394
  file_path = @pods_git_operator.get_pod_file_path(pod)
386
- is_update_success = @pods_repo.push_pod_remote(pod, file_path, p_version)
395
+ is_update_success = @pods_repo.push_pod_remote(pod, file_path, p_version, is_swift)
387
396
  unless is_update_success
388
397
  delete_tag_list = []
389
398
  delete_tag_list << pod
@@ -429,10 +438,11 @@ module PodsOrz
429
438
 
430
439
  #Install Command --
431
440
 
432
- def install_pod(main_path)
441
+ def install_pod(main_path, binary_pods_list)
433
442
  command = Thread.new do
434
443
  @pods_repo.check_repo_exist
435
- @podfile_io.output_local_total_sentence
444
+ @podfile_io.output_local_binary_sentence(binary_pods_list)
445
+ @podfile_io.output_local_total_sentence()
436
446
  end
437
447
 
438
448
  command.join
@@ -528,29 +528,8 @@ module PodsOrz
528
528
  is_merge_success = true
529
529
  pod_file_path = File.expand_path(pod, @kx_pods_path)
530
530
 
531
- merge_cmd_list = []
532
- merge_cmd_list << "cd #{pod_file_path}"
533
- merge_cmd_list << "git checkout #{into_branch}"
534
- merge_cmd_list << "git fetch origin #{into_branch}"
535
- merge_cmd_list << "git reset --hard origin/#{into_branch}"
536
- merge_cmd_list << "git merge #{from_branch} --no-ff --no-squash --no-edit"
537
-
538
- merge_cmd_lines = []
539
- has_conflicts = false
540
- IO.popen(merge_cmd_list.join(";")) do |io|
541
- merge_cmd_lines = io.readlines
542
- merge_cmd_lines.each do |line|
543
- has_conflicts = true if line.include? "Merge conflict"
544
- end
545
-
546
- io.close
547
- end
548
-
549
- if has_conflicts
550
- Logger.error("【#{pod}】 on branch: \"#{into_branch}\" Merge conflict, please manual fix conflicts.(fix conflicts and run \"git commit\")(use \"git merge --abort\" to abort the merge)")
551
- is_merge_success = false
552
- return is_merge_success
553
- end
531
+ is_merge_success = @git_operator.merge(pod_file_path, into_branch, from_branch)
532
+ return is_merge_success unless is_merge_success
554
533
 
555
534
  push_cmd_list = []
556
535
  push_cmd_list << "cd #{pod_file_path}"
@@ -668,9 +647,8 @@ module PodsOrz
668
647
 
669
648
  #rebase
670
649
  rebase_branch = rebase_branch.strip.chomp
671
- if rebase_branch.empty?
672
- return is_check_success
673
- end
650
+ return is_sync_success if rebase_branch.nil?
651
+ return is_sync_success if rebase_branch.empty?
674
652
 
675
653
  is_prepare_rebase = sync_prepare_rebase(pod, rebase_branch)
676
654
  unless is_prepare_rebase
@@ -727,8 +705,15 @@ module PodsOrz
727
705
  return is_rebase_success
728
706
  end
729
707
 
730
- #personal
731
- is_rebase_success = sync_personal_rebase(pod, rebase_branch)
708
+ is_current_release_branch = current_branch.include? "release"
709
+
710
+ if is_current_release_branch
711
+ #release
712
+ is_rebase_success = sync_parent_rebase(pod, rebase_branch)
713
+ else
714
+ #personal
715
+ is_rebase_success = sync_personal_rebase(pod, rebase_branch)
716
+ end
732
717
 
733
718
  is_rebase_success
734
719
  end
@@ -740,32 +725,144 @@ module PodsOrz
740
725
  current_branch = @git_operator.current_branch(pod_file_path)
741
726
 
742
727
  #1.except develop
743
- cmp_result = current_branch.casecmp("develop")
744
- if cmp_result == 0
728
+ is_inlcude = current_branch.include? "develop"
729
+ if is_inlcude
745
730
  Logger.error("CMD of sync which current_branch can't be 'develop','develop' not support --rebase")
746
731
  is_check_success = false
747
732
  return is_check_success
748
733
  end
749
734
 
750
- #2.except release rebase
735
+ #2.release_branch can only rebase develop
751
736
  is_current_release_branch = current_branch.include? "release"
752
737
  if is_current_release_branch
753
- Logger.error("CMD of sync which current_branch is '#{current_branch}','release' not support --rebase, switch 'bugfix' branch, 'podsorz sync --rebase=develop' instead")
754
- is_check_success = false
755
- return is_check_success
738
+ is_inlcude = rebase_branch.include? "develop"
739
+ unless is_inlcude
740
+ Logger.error("current_branch:#{current_branch} can only rebase 'develop', rebase_branch:#{rebase_branch} not support!")
741
+ is_check_success = false
742
+ return is_check_success
743
+ end
756
744
  end
757
745
 
758
746
  #3.except rebase myself
759
- cmp_result = current_branch.casecmp(rebase_branch)
760
- if cmp_result == 0
747
+ is_inlcude = current_branch.include? rebase_branch
748
+ if is_inlcude
761
749
  Logger.error("CMD of sync which current_branch :#{current_branch} can't --rebase itself ")
762
750
  is_check_success = false
763
751
  return is_check_success
764
752
  end
765
753
 
754
+ #4.feature & bugfix
755
+ is_feature_branch = current_branch.include? "feature"
756
+ if is_feature_branch
757
+ is_rebase_branch_develop = rebase_branch.include? "develop"
758
+ unless is_rebase_branch_develop
759
+ Logger.error("CMD of sync which current_branch :#{current_branch} can only --rebase=develop")
760
+ is_check_success = false
761
+ return is_check_success
762
+ end
763
+ end
764
+
765
+ is_bugfix_branch = current_branch.include? "bugfix"
766
+ if is_bugfix_branch
767
+ is_rebase_branch_release = rebase_branch.include? "release"
768
+ unless is_rebase_branch_release
769
+ Logger.error("CMD of sync which current_branch :#{current_branch} can only --rebase='release_xxxx'")
770
+ is_check_success = false
771
+ return is_check_success
772
+ end
773
+ end
774
+
775
+
766
776
  is_check_success
767
777
  end
768
778
 
779
+ def sync_parent_rebase(pod, rebase_branch)
780
+ is_rebase_success = true
781
+
782
+ pod_file_path = File.expand_path(pod, @kx_pods_path)
783
+ current_branch = @git_operator.current_branch(pod_file_path)
784
+
785
+ Logger.default("【#{pod}】 current_branch:#{current_branch} --rebase=#{rebase_branch} start...")
786
+
787
+ #0.fetch origin develop
788
+ @git_operator.fetch(pod_file_path, rebase_branch)
789
+
790
+ diff_commit_lines = @git_operator.compare_branch(pod_file_path, current_branch, "origin/#{rebase_branch}")
791
+
792
+ unless diff_commit_lines.empty?
793
+ Logger.warning("【#{pod}】has diff commits between '#{current_branch}'-'#{rebase_branch}':\n")
794
+ diff_commit_lines.each do |line|
795
+ puts(line)
796
+ end
797
+ end
798
+
799
+ is_develop_has_commit = false
800
+ is_release_has_commit = false
801
+
802
+ diff_commit_lines.each do |line|
803
+ is_develop_has_commit = true if line.include? ">"
804
+ is_release_has_commit = true if line.include? "<"
805
+ end
806
+
807
+ #1.release only
808
+ if is_release_has_commit && !is_develop_has_commit
809
+ Logger.highlight("【#{pod}】:#{current_branch} already has totoal commits from 'develop'")
810
+ return(is_rebase_success)
811
+ end
812
+
813
+ #2.develop only
814
+ if !is_release_has_commit && is_develop_has_commit
815
+ is_rebase_success = @git_operator.rebase(pod_file_path, rebase_branch)
816
+
817
+ if is_rebase_success
818
+ is_rebase_success = @git_operator.push_to_remote(pod_file_path, current_branch)
819
+ end
820
+
821
+ Logger.highlight("【#{pod}】:#{current_branch} sync commits from 'develop' completed!") if is_rebase_success
822
+
823
+ return(is_rebase_success)
824
+ end
825
+
826
+ #3.release,develop diff each other
827
+ #3.1 Merge
828
+ is_rebase_success = @git_operator.merge(pod_file_path, rebase_branch, current_branch)
829
+ unless is_rebase_success
830
+ todo_desc = %{
831
+ CMD on 【#{pod}】 sync --rebase=develop failure!
832
+
833
+ 1.fix develop merge #{current_branch} conflicts.
834
+ 2.'push' develop merged code to remote
835
+ 3.checkout #{current_branch} ,rebase 'develop'
836
+ 4.#{current_branch} push to remote
837
+ }
838
+ Logger.error("#{todo_desc}")
839
+ return is_rebase_success
840
+ end
841
+
842
+ #3.2 Push develop
843
+ is_rebase_success = @git_operator.push_to_remote(pod_file_path, rebase_branch)
844
+ return is_rebase_success unless is_rebase_success
845
+
846
+ Logger.highlight("【#{pod}】:'develop' merged commits from '#{current_branch}' completed!")
847
+
848
+ #3.3 Rebase develop
849
+ is_rebase_success = @git_operator.checkout(pod_file_path, current_branch)
850
+ return(is_rebase_success) unless is_rebase_success
851
+
852
+ is_rebase_success = @git_operator.rebase(pod_file_path, rebase_branch)
853
+ return(is_rebase_success) unless is_rebase_success
854
+
855
+ Logger.highlight("【#{pod}】:'#{current_branch}' sync commits from 'develop' completed!")
856
+
857
+ #3.4 Push current to remote
858
+ is_rebase_success = @git_operator.push_to_remote(pod_file_path, current_branch)
859
+ return(is_rebase_success) unless is_rebase_success
860
+
861
+ Logger.highlight("【#{pod}】:'#{current_branch}' && 'develop' stand at the same starting line!")
862
+
863
+ is_rebase_success
864
+ end
865
+
769
866
  def sync_personal_rebase(pod, rebase_branch)
770
867
  is_rebase_success = true
771
868
 
@@ -786,7 +883,7 @@ module PodsOrz
786
883
  if has_div
787
884
  is_rebase_success = double_check_personal_rebase_fore_push(pod)
788
885
  else
789
- Logger.highlight("【#{pod}】 current_branch:#{current_branch} --rebase=#{rebase_branch} completed, use 'podsorz commit --push --notify' to push & notify updated code, or 'git reset commit' role back to old version")
886
+ Logger.highlight("【#{pod}】 current_branch:#{current_branch} --rebase=#{rebase_branch} completed, use 'podsorz commit --push --notify' to push & notify updated code, or 'git reset commit' roll back to old version")
790
887
  end
791
888
 
792
889
  is_rebase_success