podsorz 0.0.6 → 0.0.12

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9e9fe4e4abe9b87b0674798c053b4b5108abab803bad286b4f2d700eb4fd36d7
4
- data.tar.gz: a58df9bf3b426f4f90515139c66d405e76750db805a4daa81a90479cd3ff370e
3
+ metadata.gz: a4917923f5a634c8bf8f212ac3d6621ab13eab6c9442f189bf45143a88a25036
4
+ data.tar.gz: 4a3caaa94b2a16a5a05c2da94901fd18dd4c300a6f8e7239636516f9310a1e61
5
5
  SHA512:
6
- metadata.gz: c7642c8580351e44b87fd896c599ee13bec73921729a11201f3f701cb68f8ff163ff2f7a568f92b26dce4dbf7d74a3dc08f325338509d2a02b1f28e516345a7b
7
- data.tar.gz: 302416db39162b707b3ba21ab5ccf4bcf62184b4d274b8c3536dad4d1e2311080bc31ab9c700f4edaaf9bc9787f17118068ce1dc0ac350ae689ee0a42b2a2f3c
6
+ metadata.gz: bac63452c1fae9ad3d222f33f7b9e302b453431ae86d3578f8ec958364826a6c9a21aabc523925ab0d8160050726cb78549eca3a35905ae5f5b8b24b763f7991
7
+ data.tar.gz: 445fb40a279eb2a916d255b52fde91f6c343abf460673eeae81242c10aaa8b1b894d53100e91c92ede85669adc9a17d9a0bfccc9df90fb89e462e6582a290ca2
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --require spec_helper
data/Gemfile CHANGED
@@ -4,3 +4,13 @@ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
4
 
5
5
  # Specify your gem's dependencies in podsorz.gemspec
6
6
  gemspec
7
+ gem "rspec"
8
+
9
+ group :development do
10
+ gem 'bacon'
11
+ gem 'mocha-on-bacon'
12
+ gem 'mocha'
13
+ gem 'prettybacon'
14
+ gem 'coveralls', :require => false
15
+ gem 'rubocop'
16
+ end
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- podsorz (0.0.5)
4
+ podsorz (0.0.8)
5
5
  cocoapods
6
6
  cocoapods-packager
7
7
  colorize
@@ -21,7 +21,9 @@ GEM
21
21
  algoliasearch (1.27.5)
22
22
  httpclient (~> 2.8, >= 2.8.3)
23
23
  json (>= 1.5.1)
24
+ ast (2.4.2)
24
25
  atomos (0.1.3)
26
+ bacon (1.2.0)
25
27
  claide (1.0.3)
26
28
  cocoapods (1.10.1)
27
29
  addressable (~> 2.6)
@@ -65,6 +67,14 @@ GEM
65
67
  colored2 (3.1.2)
66
68
  colorize (0.8.1)
67
69
  concurrent-ruby (1.1.8)
70
+ coveralls (0.8.23)
71
+ json (>= 1.8, < 3)
72
+ simplecov (~> 0.16.1)
73
+ term-ansicolor (~> 1.3)
74
+ thor (>= 0.19.4, < 2.0)
75
+ tins (~> 1.6)
76
+ diff-lcs (1.4.4)
77
+ docile (1.3.5)
68
78
  escape (0.0.4)
69
79
  ethon (0.12.0)
70
80
  ffi (>= 1.3.0)
@@ -78,17 +88,65 @@ GEM
78
88
  concurrent-ruby (~> 1.0)
79
89
  json (2.5.1)
80
90
  minitest (5.14.4)
91
+ mocha (1.12.0)
92
+ mocha-on-bacon (0.2.3)
93
+ mocha (>= 0.13.0)
81
94
  molinillo (0.6.6)
82
95
  nanaimo (0.3.0)
83
96
  nap (1.1.0)
84
97
  netrc (0.11.0)
98
+ parallel (1.20.1)
99
+ parser (3.0.0.0)
100
+ ast (~> 2.4.1)
101
+ prettybacon (0.0.2)
102
+ bacon (~> 1.2)
85
103
  public_suffix (4.0.6)
104
+ rainbow (3.0.0)
105
+ regexp_parser (2.1.1)
106
+ rexml (3.2.4)
107
+ rspec (3.10.0)
108
+ rspec-core (~> 3.10.0)
109
+ rspec-expectations (~> 3.10.0)
110
+ rspec-mocks (~> 3.10.0)
111
+ rspec-core (3.10.1)
112
+ rspec-support (~> 3.10.0)
113
+ rspec-expectations (3.10.1)
114
+ diff-lcs (>= 1.2.0, < 2.0)
115
+ rspec-support (~> 3.10.0)
116
+ rspec-mocks (3.10.2)
117
+ diff-lcs (>= 1.2.0, < 2.0)
118
+ rspec-support (~> 3.10.0)
119
+ rspec-support (3.10.2)
120
+ rubocop (1.11.0)
121
+ parallel (~> 1.10)
122
+ parser (>= 3.0.0.0)
123
+ rainbow (>= 2.2.2, < 4.0)
124
+ regexp_parser (>= 1.8, < 3.0)
125
+ rexml
126
+ rubocop-ast (>= 1.2.0, < 2.0)
127
+ ruby-progressbar (~> 1.7)
128
+ unicode-display_width (>= 1.4.0, < 3.0)
129
+ rubocop-ast (1.4.1)
130
+ parser (>= 2.7.1.5)
86
131
  ruby-macho (1.4.0)
132
+ ruby-progressbar (1.11.0)
133
+ simplecov (0.16.1)
134
+ docile (~> 1.1)
135
+ json (>= 1.8, < 3)
136
+ simplecov-html (~> 0.10.0)
137
+ simplecov-html (0.10.2)
138
+ sync (0.5.0)
139
+ term-ansicolor (1.7.1)
140
+ tins (~> 1.0)
141
+ thor (1.1.0)
87
142
  thread_safe (0.3.6)
143
+ tins (1.28.0)
144
+ sync
88
145
  typhoeus (1.4.0)
89
146
  ethon (>= 0.9.0)
90
147
  tzinfo (1.2.9)
91
148
  thread_safe (~> 0.1)
149
+ unicode-display_width (2.0.0)
92
150
  xcodeproj (1.19.0)
93
151
  CFPropertyList (>= 2.3.3, < 4.0)
94
152
  atomos (~> 0.1.3)
@@ -100,7 +158,14 @@ PLATFORMS
100
158
  ruby
101
159
 
102
160
  DEPENDENCIES
161
+ bacon
162
+ coveralls
163
+ mocha
164
+ mocha-on-bacon
103
165
  podsorz!
166
+ prettybacon
167
+ rspec
168
+ rubocop
104
169
 
105
170
  BUNDLED WITH
106
171
  1.17.2
data/Podfile ADDED
File without changes
data/lib/podsorz.rb CHANGED
@@ -8,6 +8,8 @@ require "podsorz/command/publish"
8
8
  require "podsorz/command/sync"
9
9
  require "podsorz/command/binary"
10
10
  require "podsorz/command/install"
11
+ require "podsorz/command/check"
12
+ require "podsorz/command/sort"
11
13
 
12
14
  require 'gli'
13
15
 
@@ -40,6 +42,8 @@ module PodsOrz
40
42
  install_command()
41
43
  sync_command()
42
44
  binary_command()
45
+ check_command()
46
+ sort_command()
43
47
 
44
48
  desc "Show podsorz version"
45
49
  command :version do |version|
@@ -134,10 +134,17 @@ module PodsOrz
134
134
  end
135
135
  end
136
136
 
137
- Logger.highlight("[cmd:#{cmd_type}] Exist static library pods : \n #{exist_binary_list.inspect}")
137
+ Logger.highlight("[cmd:#{cmd_type}] Exist static library pods :")
138
+ exist_binary_list.each do |item|
139
+ puts item.colorize(:green)
140
+ end
141
+
138
142
  Logger.separator
139
- Logger.warning("[cmd:#{cmd_type}] Not exist static library pods: \n #{empty_binary_list.inspect}")
140
143
 
144
+ Logger.warning("[cmd:#{cmd_type}] Not exist static library pods:")
145
+ empty_binary_list.each do |item|
146
+ puts item.colorize(:yellow)
147
+ end
141
148
 
142
149
  result_hash[:binary] = has_binary_list
143
150
  result_hash[:package] = can_package_list
@@ -0,0 +1,28 @@
1
+ # require "podsorz/core/PodsOrz/pods_check_merge"
2
+ # require "../../PodsOrz/lib/podsorz/core/PodsOrz/pods_check_merge.rb"
3
+ require "podsorz/core/PodsOrz/pods_check_merge"
4
+
5
+ module PodsOrz
6
+ def self.check_command
7
+ desc "Check Pods not merge"
8
+ command :check do |check|
9
+ check.action do |global_options, options, args|
10
+ dir_path = global_options[:path]
11
+
12
+ is_directory = File.directory?(dir_path)
13
+
14
+ unless is_directory
15
+ Logger.error("Check failure, it is not a directory path: #{dir_path}")
16
+ exit()
17
+ end
18
+
19
+ kx_pods_path = File.expand_path("../kx_pods", dir_path)
20
+ # puts "kx_pods_path #{kx_pods_path}"
21
+ checkManger = PodsOrz::PodsCheckMerge.new()
22
+ checkManger.branchList(kx_pods_path)
23
+
24
+ end
25
+ end
26
+ end
27
+
28
+ end
@@ -0,0 +1,33 @@
1
+ require "podsorz/core/PodsOrz/pods_sort"
2
+ require "podsorz/core/Config/pod_orzconfig_parse"
3
+
4
+ module PodsOrz
5
+ def self.sort_command
6
+ desc "Prioritize the pods to be released and check for loops. Output the number of dependency"
7
+ command :sort do |sort|
8
+ sort.action do |global_options, options, args|
9
+ dir_path = global_options[:path]
10
+
11
+ is_directory = File.directory?(dir_path)
12
+
13
+ unless is_directory
14
+ Logger.error("Check failure, it is not a directory path: #{dir_path}")
15
+ exit()
16
+ end
17
+
18
+ kx_pods_path = File.expand_path("../kx_pods", dir_path)
19
+ @orzconfig_parse = PodsOrz::PodOrzconfigParse.new(dir_path)
20
+ pods_list = @orzconfig_parse.fix_pod_list
21
+ if pods_list.empty?
22
+ Logger.warning("fix_pods is empty nothing to do")
23
+ else
24
+ pods_sort = PodsOrz::PodsSort.new()
25
+ pods_list = pods_sort.sort(pods_list,kx_pods_path)
26
+
27
+ end
28
+
29
+ end
30
+ end
31
+ end
32
+
33
+ end
@@ -6,7 +6,7 @@ require "open3"
6
6
 
7
7
  module PodsOrz
8
8
  class BinaryBuilder
9
- attr_accessor :main_path, :kx_binary_path, :podfile_io, :pod_repo, :http_host
9
+ attr_accessor :main_path, :kx_binary_path, :podfile_io, :pod_repo, :http_host, :remote_binary_directory
10
10
 
11
11
  def initialize(main_path, podfile_io)
12
12
  @main_path = main_path
@@ -15,7 +15,8 @@ module PodsOrz
15
15
  @podfile_io = podfile_io
16
16
  @pod_repo = PodsOrz::PodsRepo.new()
17
17
 
18
- @http_host = "http://192.168.6.23:8080"
18
+ @http_host = "http://192.168.6.127:8899"
19
+ @remote_binary_directory = "binary_pod"
19
20
  end
20
21
 
21
22
  def start_package_pod(pod)
@@ -82,7 +83,7 @@ module PodsOrz
82
83
  binary_result = File.directory?(@kx_binary_path)
83
84
  unless binary_result
84
85
  Logger.warning("kx_binary directory not exist, generate default 'kx_binary' directory")
85
- Dir.mkdir(@kx_pods_path)
86
+ FileUtils.mkdir_p(@kx_binary_path, :mode => 0777)
86
87
  end
87
88
  end
88
89
  end
@@ -99,7 +100,7 @@ module PodsOrz
99
100
  pod_result = File.directory?(pod_path)
100
101
  unless pod_result
101
102
  Logger.warning("#{pod_path} directory not exist, generate default '#{pod_path}' directory")
102
- Dir.mkdir(pod_path)
103
+ FileUtils.mkdir_p(pod_path, :mode => 0777)
103
104
  end
104
105
  end
105
106
 
@@ -107,8 +108,8 @@ module PodsOrz
107
108
  pod_version_path = File.expand_path("#{pod}/#{pod_version}", @kx_binary_path)
108
109
  pod_version_result = File.directory?(pod_version_path)
109
110
  unless pod_version_result
110
- Logger.warning("#{pod_version_path} directory not exist, generate default '#{pod_version_path}' directory")
111
- Dir.mkdir(pod_version_path)
111
+ Logger.warning("#{pod_version_path} directory not exist, generate default '#{pod_version_path}' directory")
112
+ FileUtils.mkdir_p(pod_version_path, :mode => 0777)
112
113
  end
113
114
 
114
115
  pod_version_path
@@ -241,7 +242,7 @@ module PodsOrz
241
242
  unless sentence_content.start_with?("#")
242
243
  mt = /.*s.source = /.match(sentence)
243
244
  unless mt.nil?
244
- sentence = mt[0] + "{:http => \'#{http_host}/#{pod}/#{pod_version}/#{pod}.framework.zip\'}"
245
+ sentence = mt[0] + "{:http => \'#{@http_host}/#{remote_binary_directory}/#{pod}/#{pod_version}/#{pod}.framework.zip\'}"
245
246
  end
246
247
 
247
248
  mt = /.*s.ios.vendored_framework = /.match(sentence)
@@ -150,7 +150,11 @@ module PodsOrz
150
150
  dest_dir = @binary_builder.detect_version_directory(pod, pod_version)
151
151
 
152
152
  each_result = @binary_repo.push_binary_remote(pod, dest_dir, pod_version, false)
153
- is_publish_success = false unless each_result
153
+ unless each_result
154
+ is_publish_success = false
155
+ Logger.error("#{pod}(#{pod_version}) publish failure!")
156
+ end
157
+
154
158
  end
155
159
 
156
160
  command.join
@@ -1,14 +1,16 @@
1
1
  require "podsorz/util/logger"
2
2
  require 'open3'
3
+ require "podsorz/core/Binary/binary_server"
3
4
 
4
5
  module PodsOrz
5
6
  class BinaryRepo
6
- attr_accessor :repo_name, :repo_url
7
+ attr_accessor :repo_name, :repo_url, :binary_server
7
8
 
8
9
  def initialize()
9
10
  @repo_name = "kuxiu_binary_specs"
10
11
  @repo_url = "git@gitlab.91banban.com:ios_pods/binary-specs.git"
11
12
  @source_code_repo_url = "git@gitlab.91banban.com:ios_pods/Specs.git"
13
+ @binary_server = PodsOrz::BinaryServer.new()
12
14
  end
13
15
 
14
16
  def check_binary_repo_exist()
@@ -132,6 +134,19 @@ module PodsOrz
132
134
  def push_binary_remote(pod, file_path, pod_version, is_swift)
133
135
  is_push_success = false
134
136
 
137
+ #1.上传文件到服务器
138
+ is_push_success = @binary_server.upload_pod_file(pod, file_path, pod_version)
139
+ return is_push_success unless is_push_success
140
+
141
+ #2.发布到binary_repo
142
+ is_push_success = start_publish_binary(pod, file_path, pod_version, is_swift)
143
+
144
+ is_push_success
145
+ end
146
+
147
+ def start_publish_binary(pod, file_path, pod_version, is_swift)
148
+ is_push_success = false
149
+
135
150
  command = Thread.new do
136
151
  repo_push_cmd = []
137
152
  repo_push_cmd << "cd #{file_path}"
@@ -168,9 +183,6 @@ module PodsOrz
168
183
  is_push_success
169
184
  end
170
185
 
171
-
172
-
173
-
174
186
  #Class End
175
187
 
176
188
  end
@@ -1,21 +1,120 @@
1
1
  require "podsorz/util/logger"
2
+ require "open3"
3
+ require "thread"
2
4
 
3
5
 
4
6
  module PodsOrz
5
7
  class BinaryServer
6
- attr_accessor :remote_host
8
+ attr_accessor :http_host
7
9
 
8
10
  def initialize()
9
- @remote_host = "http://192.168.6.23:8080"
11
+ @http_host = "http://192.168.6.127:8899"
10
12
  end
11
13
 
14
+ def upload_pod_file(pod, file_path, pod_version)
15
+ is_upload_success = false
12
16
 
13
- def has_remote_source(pod, version)
14
-
17
+ # uplaod zip
18
+ is_upload_success = __action_upload(pod,file_path,pod_version,".framework.zip")
19
+ return is_upload_success unless is_upload_success
20
+
21
+ # upload .podspec
22
+ is_upload_success = __action_upload(pod,file_path,pod_version,".podspec")
15
23
 
24
+ is_upload_success
25
+ end
26
+
27
+ def __action_upload(pod, file_path, pod_version, extension)
28
+ is_upload_success = false
29
+
30
+ file_name = "#{pod}#{extension}"
31
+ file_name_path = File.expand_path(file_name, file_path)
32
+
33
+ unless File.exist?(file_name_path)
34
+ Logger.error("#{file_name_path} not exist!")
35
+ is_upload_success = false
36
+ return is_upload_success
37
+ end
38
+
39
+ mutex = Mutex.new()
40
+ condition_var = ConditionVariable.new
41
+
42
+ wait_thread = Thread.new do
43
+ mutex.synchronize {
44
+ condition_var.wait(mutex, 30)
45
+ }
46
+ end
47
+
48
+ command = Thread.new do
49
+ mutex.synchronize {
50
+ upload_cmd = "curl #{@http_host}/upload -F \"podname=#{pod}\" -F \"version=#{pod_version}\" -F \"file=@#{file_name_path};filename=#{file_name}\""
51
+
52
+ Logger.warning("upload #{file_name}...\n #{upload_cmd}")
53
+
54
+ IO.popen(upload_cmd) do |io|
55
+ io_lines = io.readlines
56
+ io_lines.each do |line|
57
+ puts line
58
+ if line.include? "\"success\":"
59
+ is_upload_success = true if line.include? "true"
60
+ condition_var.signal
61
+ end
62
+ end
63
+ io.close
64
+ end
65
+ }
66
+ end
67
+
68
+ wait_thread.join()
69
+
70
+ Logger.error("upload #{file_name} failure!") unless is_upload_success
71
+
72
+ is_upload_success
16
73
  end
17
74
 
75
+ def delete_pod_file(pod, pod_version)
76
+ is_delete_success = false
77
+
78
+ mutex = Mutex.new()
79
+ condition_var = ConditionVariable.new
80
+
81
+ wait_thread = Thread.new do
82
+ mutex.synchronize {
83
+ condition_var.wait(mutex, 2)
84
+ }
85
+ end
86
+
87
+ command = Thread.new do
88
+ mutex.synchronize {
89
+ delete_cmd = ""
90
+ if pod_version && pod_version.length > 0
91
+ delete_cmd = "curl #{@http_host}/delete -d \"podname=#{pod}\";\"version=#{pod_version}\""
92
+ else
93
+ delete_cmd = "curl #{@http_host}/delete -d \"podname=#{pod}\""
94
+ end
95
+
96
+ Logger.warning("delete #{pod}...\n #{delete_cmd}")
97
+
98
+ Open3.popen3(delete_cmd) do |stdin , stdout , stderr, wait_thr|
99
+ while line = stdout.gets
100
+ puts line
101
+ if line.include? "\"success\":"
102
+ is_delete_success = true if line.include? "true"
103
+ condition_var.signal
104
+ end
105
+ end
106
+ end
107
+ }
108
+ end
109
+
110
+ wait_thread.join()
111
+
112
+ Logger.error("delete #{pod} failure!") unless is_delete_success
113
+
114
+ is_delete_success
115
+ end
18
116
 
117
+ #Class end
19
118
  end
20
119
 
21
120
  end
@@ -4,11 +4,12 @@ require "podsorz/core/PodFile/podfile_model"
4
4
  module PodsOrz
5
5
 
6
6
  class PodfileIO
7
- attr_accessor :main_path, :total_sentences, :usable_sentences, :total_pod_models, :http_host
7
+ attr_accessor :main_path, :total_sentences, :usable_sentences, :total_pod_models, :http_host, :remote_binary_directory
8
8
 
9
9
  def initialize(main_path)
10
10
  @main_path = main_path
11
- @http_host = "http://192.168.6.23:8080"
11
+ @http_host = "http://192.168.6.127:8899"
12
+ @remote_binary_directory = "binary_pod"
12
13
 
13
14
  self.parse_podfile_orz
14
15
  end
@@ -314,7 +315,7 @@ module PodsOrz
314
315
  pod_name_list.each do |podname|
315
316
  @total_pod_models.map { |model|
316
317
  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
+ model.podspec = "#{@http_host}/#{remote_binary_directory}/#{model.name}/#{model.version}/#{model.name}.podspec" unless model.version.nil?
318
319
  end
319
320
  }
320
321
  end
@@ -0,0 +1,160 @@
1
+ require 'open3'
2
+ require 'pathname'
3
+ require "podsorz/util/git_operator"
4
+
5
+ module PodsOrz
6
+
7
+ class PodsCheckMerge
8
+
9
+ # def check_Podfile(filePath)
10
+ # # 返回 path 的绝对路径,扩展 ~ 为进程所有者的主目录,~user 为用户的主目录。相对路径是相对于 dir 指定的目录,如果 dir 被省略则相对于当前工作目录
11
+ # tempPath = File.expand_path("Podfile",filePath)
12
+ # result = File::exist?tempPath
13
+ # if result
14
+ # puts("存在-- #{tempPath}")
15
+ # else
16
+ # puts("不存在-- #{tempPath}")
17
+ # end
18
+ # tempPath
19
+ # end
20
+
21
+ def branchList(path)
22
+ list = []
23
+ # IO.popen("cd '#{path}';git branch -r") do |io|
24
+ # io.each do |line|
25
+ # puts("branch -- #{line}")
26
+ # # has_branch = true if line.include? branch_name
27
+ # end
28
+ # end
29
+
30
+ # Open3.popen3("cd '#{File.dirname(__FILE__ )}';git branch -r"){|stdin, stdout, stderr, wait_thr|
31
+ # while line = stdout.gets
32
+ # puts("branch- #{line}")
33
+ # end
34
+ # }
35
+ # @kx_pods_directory = File.expand_path("../kx_pods", File.dirname(__FILE__))
36
+ # puts "里层 #{@kx_pods_directory}"
37
+
38
+ # kx_pods_path /Users/yuyutao/Desktop/rubyGem/kx_pods
39
+ # 里层 /Library/Ruby/Gems/2.6.0/gems/podsorz-0.0.5/lib/podsorz/core/kx_pods
40
+
41
+ # dir = Dir.open("#{@kx_pods_directory}")
42
+ # while name = dir.read
43
+ # p name
44
+ # end
45
+ # dir.close
46
+
47
+ # @kx_pods_directory = "/Users/yuyutao/Desktop/rubyGem/kx_pods"
48
+
49
+ Dir.open("#{path}") do |dir|
50
+ tempAry = ['.','..']
51
+ dirAry = dir.to_a
52
+ ary = dirAry-tempAry
53
+ ary.each do |name|
54
+ dir_path = "#{path}/#{name}"
55
+ is_directory = File.directory?(dir_path)
56
+
57
+ if is_directory
58
+ localBranch("#{dir_path}",name)
59
+ else
60
+ # puts "#{name} 空文件"
61
+ end
62
+ end
63
+
64
+ end
65
+
66
+
67
+ end
68
+
69
+ # git log -n1 --format=format:"%H"
70
+ def localBranch(filePath,fileName)
71
+
72
+ @git_operator = PodsOrz::GitOperator.new()
73
+ has_changes = @git_operator.has_changes(filePath)
74
+ if has_changes
75
+ branch = @git_operator.current_branch(filePath)
76
+ Logger.error("【#{filePath}】 on branch: \"#{branch}\" has unstaged/uncommit changes, please staged and commit local first")
77
+ return
78
+ end
79
+
80
+ is_merge_all = true
81
+ branch = ""
82
+ Open3.popen3("cd '#{filePath}';git branch -l"){|stdin, stdout, stderr, wait_thr|
83
+ if stdout.gets
84
+ while line = stdout.gets
85
+
86
+ if line.include? "master"
87
+ # puts("master分支-#{fileName}")
88
+ elsif line.include? "develop"
89
+ # puts("develop分支-#{fileName}")
90
+ elsif line.include? "release"
91
+ # puts("release分支-#{fileName}")
92
+ else
93
+ # puts("#{fileName} branch- #{line}")
94
+ branch = line.strip
95
+ if branch.include? "*"
96
+ branch.delete!("*",)
97
+ end
98
+ is_merge_all = git_isMerged("#{branch}",filePath)
99
+ end
100
+
101
+ end
102
+
103
+ else
104
+ # puts("未发现本地分支-#{fileName}")
105
+ end
106
+ }
107
+
108
+ # puts("all commit success!") if is_merge_all
109
+ if is_merge_all
110
+
111
+ puts("check result: all commit success! #{filePath}")
112
+ else
113
+ Logger.warning("#{filePath} - #{branch} commit not merge")
114
+ end
115
+
116
+ end
117
+
118
+ def git_isMerged(branch,path)
119
+ merge_destination_branch = "origin/develop"
120
+ merge_source_branch = "#{branch}"
121
+ merge_base = ""
122
+ merge_current_commit = ""
123
+ is_merge_all = true
124
+ cmd = "cd '#{path}';git merge-base #{merge_destination_branch} #{branch}"
125
+ IO.popen(cmd) do |io|
126
+ io.each do |line|
127
+ if line
128
+ merge_base = line
129
+ else
130
+ puts("git merge-base 无hash值 #{path}")
131
+ end
132
+
133
+ end
134
+
135
+ end
136
+ cmd = "git rev-parse #{branch}"
137
+ IO.popen("cd '#{path}';#{cmd}") do |io|
138
+ io.each do |line|
139
+ if line
140
+ merge_current_commit = line
141
+ else
142
+ puts("git rev-parse 无hash值 #{path}")
143
+ end
144
+
145
+ end
146
+
147
+ end
148
+
149
+ if merge_base == merge_current_commit
150
+
151
+ else
152
+ is_merge_all = false
153
+ end
154
+
155
+ is_merge_all
156
+ end
157
+
158
+ end
159
+
160
+ end
@@ -27,7 +27,7 @@ module PodsOrz
27
27
  pods_result = File.directory?(@kx_pods_path)
28
28
  unless pods_result
29
29
  Logger.warning("kx_pods directory not exist, generate default 'kx_pods' directory")
30
- Dir.mkdir(@kx_pods_path)
30
+ FileUtils.mkdir_p(@kx_pods_path, :mode => 0777)
31
31
  end
32
32
  end
33
33
  end
@@ -3,6 +3,7 @@ require "podsorz/core/PodsOrz/pods_git_operator"
3
3
  require "podsorz/core/PodFile/podfile_io"
4
4
  require "podsorz/core/PodsOrz/pods_version"
5
5
  require "podsorz/core/PodsOrz/pods_repo"
6
+ require "podsorz/core/PodsOrz/pods_sort"
6
7
  require 'open3'
7
8
 
8
9
  module PodsOrz
@@ -199,8 +200,8 @@ module PodsOrz
199
200
  end
200
201
 
201
202
 
202
- #1.判断 release 是否存在新的commit内容
203
- newContent_pod_list = filter_newContent_pods()
203
+ #1.判断 release 和master 比较是否存在新的commit内容
204
+ newContent_pod_list = filter_master_newContent()
204
205
 
205
206
  if newContent_pod_list.empty?
206
207
  Logger.warning("All pods do not have new content to publish")
@@ -228,17 +229,37 @@ module PodsOrz
228
229
  #6.Update Podfile_orz
229
230
  update_publish_podfile_orz
230
231
 
231
- #7.Merge into develop
232
+ #7.diff content from develop branch
233
+ newContent_pod_list = filter_develop_newContent()
234
+
235
+ #8.Merge into develop
232
236
  publish_develop_branch(newContent_pod_list)
233
237
  end
234
238
 
235
- def filter_newContent_pods()
239
+ def filter_master_newContent()
240
+ newContent_pod_list = []
241
+ #filter action
242
+ pods_list = @orzconfig_parse.fix_pod_list
243
+ pods_list.each {|pod|
244
+ command = Thread.new do
245
+ is_new_publish = @pods_git_operator.has_new_publish(pod, "master")
246
+ newContent_pod_list << pod if is_new_publish
247
+ end
248
+
249
+ command.join
250
+ Logger.separator
251
+ }
252
+
253
+ newContent_pod_list
254
+ end
255
+
256
+ def filter_develop_newContent()
236
257
  newContent_pod_list = []
237
258
  #filter action
238
259
  pods_list = @orzconfig_parse.fix_pod_list
239
260
  pods_list.each {|pod|
240
261
  command = Thread.new do
241
- is_new_publish = @pods_git_operator.has_new_publish(pod)
262
+ is_new_publish = @pods_git_operator.has_new_publish(pod, "develop")
242
263
  newContent_pod_list << pod if is_new_publish
243
264
  end
244
265
 
@@ -355,8 +376,16 @@ module PodsOrz
355
376
 
356
377
  def pods_repo_push(is_swift)
357
378
  is_push_success = true
358
-
359
379
  pods_list = @orzconfig_parse.fix_pod_list
380
+
381
+ if pods_list.empty?
382
+ Logger.warning("fix_pods is empty nothing to do")
383
+ else
384
+ pods_sort = PodsOrz::PodsSort.new()
385
+ kx_pods_subPath = @pods_git_operator.get_pod_file_path("")
386
+ pods_list = pods_sort.sort(pods_list,kx_pods_subPath)
387
+ end
388
+
360
389
  pods_list.each {|pod|
361
390
  Logger.default("【#{pod}】check pod_version, git_tag, remote_version...")
362
391
 
@@ -425,7 +425,7 @@ module PodsOrz
425
425
 
426
426
  #Publish
427
427
 
428
- def has_new_publish(pod)
428
+ def has_new_publish(pod, branch_name)
429
429
  is_new_content = true
430
430
 
431
431
  is_new_content = is_publish_ready(pod)
@@ -437,7 +437,7 @@ module PodsOrz
437
437
 
438
438
  fetch_cmd_list = []
439
439
  fetch_cmd_list << "cd #{pod_file_path}"
440
- fetch_cmd_list << "git fetch origin master"
440
+ fetch_cmd_list << "git fetch origin #{branch_name}"
441
441
  IO.popen(fetch_cmd_list.join(";")) do |io|
442
442
  io.each do |line|
443
443
  puts line
@@ -446,16 +446,21 @@ module PodsOrz
446
446
  end
447
447
 
448
448
  diff_lines_list = []
449
- diff_lines_list = @git_operator.compare_branch(pod_file_path, current_branch, "origin/master")
449
+ diff_lines_list = @git_operator.compare_branch(pod_file_path, current_branch, "origin/#{branch_name}")
450
450
 
451
451
  if diff_lines_list.empty?
452
452
  is_new_content = false
453
453
  return is_new_content
454
454
  end
455
455
 
456
+ #filter Merge branch
457
+ diff_lines_list.delete_if {|item|
458
+ item.to_s.include? "Merge branch"
459
+ }
460
+
456
461
  is_new_content = false
457
462
 
458
- Logger.warning("#{pod} on branch:\'#{current_branch}\' -- compare branch:\'origin/master\'")
463
+ Logger.warning("#{pod} on branch:\'#{current_branch}\' -- compare branch:\'origin/#{branch_name}\'")
459
464
 
460
465
  should_show_detail = true
461
466
  limit_count = 10
@@ -190,9 +190,9 @@ module PodsOrz
190
190
  repo_push_cmd = []
191
191
  repo_push_cmd << "cd #{file_path}"
192
192
  if is_swift
193
- repo_push_cmd << "pod repo push #{@repo_name} #{pod}.podspec --sources=#{@repo_url} --allow-warnings --use-libraries --skip-import-validation --use-modular-headers --swift-version=5.0 --skip-tests --platforms=ios"
193
+ repo_push_cmd << "pod repo push #{@repo_name} #{pod}.podspec --sources=#{@repo_url} --allow-warnings --use-libraries --skip-import-validation --use-modular-headers --swift-version=5.0 --skip-tests"
194
194
  else
195
- repo_push_cmd << "pod repo push #{@repo_name} #{pod}.podspec --sources=#{@repo_url} --allow-warnings --use-libraries --skip-import-validation --skip-tests --platforms=ios"
195
+ repo_push_cmd << "pod repo push #{@repo_name} #{pod}.podspec --sources=#{@repo_url} --allow-warnings --use-libraries --skip-import-validation --skip-tests"
196
196
  end
197
197
 
198
198
 
@@ -212,10 +212,9 @@ module PodsOrz
212
212
  unless is_push_success
213
213
  puts error_info
214
214
  Logger.error("Fail: \'#{pod}\':#{pod_version} push repo remote fail")
215
- return is_push_success
215
+ else
216
+ Logger.highlight(%Q(#{pod}:#{pod_version} push repo success))
216
217
  end
217
-
218
- Logger.highlight(%Q(#{pod}:#{pod_version} push repo success))
219
218
  end
220
219
 
221
220
  command.join
@@ -0,0 +1,155 @@
1
+ require 'open3'
2
+ require 'pathname'
3
+
4
+ module PodsOrz
5
+
6
+ class PodsSort
7
+
8
+ def sort(pods_list,kx_pods_subPath)
9
+ # file priority 1 hash
10
+ @@fileHash = {}
11
+ # podspec hash
12
+ @@podspecHash = {}
13
+
14
+ @@filterHash = {}
15
+ pods_list.each { |fileName|
16
+ @@fileHash[fileName] = 1
17
+ }
18
+
19
+ pods_list.each { |fileName|
20
+ filePath = "#{kx_pods_subPath}/#{fileName}"
21
+ is_directory = File.directory?(filePath)
22
+ if is_directory
23
+ spec_with_path("#{filePath}/#{fileName}.podspec",fileName)
24
+ else
25
+ Logger.warning("#{filePath} is an empty file")
26
+ end
27
+ }
28
+ sort_with_hash()
29
+ @resultHash = {}
30
+
31
+ @@filterHash.each { |fileName,array|
32
+ # puts ("#{fileName},#{array}")
33
+ recursive_puts(fileName,array,[fileName])
34
+
35
+ }
36
+
37
+ @@fileHash.each {|file,priority|
38
+ # puts ("#{file} #{priority}")
39
+ if @resultHash.key?(priority)
40
+ array = @resultHash[priority]
41
+ array << file
42
+ @resultHash[priority] = array
43
+ else
44
+ @resultHash[priority] = [file]
45
+ end
46
+ }
47
+ sortList = []
48
+ checkHash = {}
49
+ # puts @resultHash
50
+ @resultHash.sort.sort!.each { |priority,array|
51
+ # puts ("#{priority},#{array}")
52
+ array.each { |line|
53
+ puts ("#{priority} -- #{line}")
54
+ checkHash[line] = priority
55
+ sortList << line
56
+ }
57
+ }
58
+
59
+ sortList.reverse!
60
+
61
+ end
62
+
63
+
64
+ def recursive_puts(key,array,pathArray)
65
+ # pathArray << key
66
+ totalArray = []
67
+ if array.empty?
68
+ # puts ("kong - #{key}")
69
+
70
+ else
71
+ array.each {|line|
72
+ pathArray << line
73
+ priority = @@fileHash[line] + 1
74
+ @@fileHash[line] = priority
75
+ tempArray = @@filterHash[line]
76
+ if tempArray.empty?
77
+ pathArray.pop
78
+ else
79
+
80
+ cycle = false
81
+ tempArray.each {|podsName|
82
+ if pathArray.include?(podsName)
83
+ cycle = true
84
+ Logger.error("path:#{pathArray} pod:#{podsName} has dependence cycle, please fix cycle")
85
+ exit()
86
+ end
87
+ # priorityN = @@fileHash[podsName] + 1
88
+ # puts("次数 podsName #{podsName} #{priorityN}")
89
+ # @@fileHash[podsName] = priorityN
90
+ }
91
+
92
+ if cycle
93
+ #包含
94
+ # puts pathArray
95
+
96
+ else
97
+ # puts ("#{key} #{line} #{pathArray}")
98
+ recursive_puts(line,tempArray,pathArray)
99
+ pathArray.pop
100
+ end
101
+
102
+ end
103
+
104
+ }
105
+
106
+ end
107
+
108
+
109
+ end
110
+
111
+ def sort_with_hash()
112
+
113
+ @@podspecHash.each { |fileName,specArray|
114
+ # puts "#{fileName} #{specArray}"
115
+ tempArray = []
116
+ @@fileHash.each {|file,priority|
117
+
118
+ specArray.each { |line|
119
+ if line.include? "dependency"
120
+
121
+ if line.include? file and file != fileName
122
+
123
+ priority += 1
124
+
125
+ # @@fileHash[file] = priority
126
+ tempArray << file
127
+ # puts "#{fileName},#{file},#{line}"
128
+
129
+ end
130
+ end
131
+ }
132
+
133
+ }
134
+ @@filterHash[fileName] = tempArray
135
+
136
+ }
137
+
138
+ end
139
+
140
+ def spec_with_path(path,fileName)
141
+ return if path.nil?
142
+ path = Pathname.new(path)
143
+ path = Pathname.new(Dir.pwd).join(path) unless path.absolute?
144
+ return unless path.exist?
145
+
146
+ @path = path.expand_path
147
+
148
+ arr = IO.readlines("#{@path}")
149
+ @@podspecHash[fileName] = arr
150
+
151
+ end
152
+
153
+ end
154
+
155
+ end
@@ -1,7 +1,7 @@
1
1
  require 'colorize'
2
2
 
3
3
  module Logger
4
- def self.default(sentence)
4
+ def self.default(sentence)
5
5
  puts format_output(sentence).colorize(:default)
6
6
  end
7
7
 
@@ -1,3 +1,3 @@
1
1
  module PodsOrz
2
- VERSION = "0.0.6"
2
+ VERSION = "0.0.12"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: podsorz
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Xiangqi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-03-01 00:00:00.000000000 Z
11
+ date: 2021-04-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gli
@@ -77,18 +77,22 @@ extensions: []
77
77
  extra_rdoc_files: []
78
78
  files:
79
79
  - ".gitignore"
80
+ - ".rspec"
80
81
  - Gemfile
81
82
  - Gemfile.lock
82
83
  - LICENSE.txt
84
+ - Podfile
83
85
  - README.md
84
86
  - Rakefile
85
87
  - bin/podsorz
86
88
  - lib/podsorz.rb
87
89
  - lib/podsorz/command/binary.rb
90
+ - lib/podsorz/command/check.rb
88
91
  - lib/podsorz/command/commit.rb
89
92
  - lib/podsorz/command/install.rb
90
93
  - lib/podsorz/command/publish.rb
91
94
  - lib/podsorz/command/setup.rb
95
+ - lib/podsorz/command/sort.rb
92
96
  - lib/podsorz/command/switch.rb
93
97
  - lib/podsorz/command/sync.rb
94
98
  - lib/podsorz/core/Binary/binary_builder.rb
@@ -100,10 +104,12 @@ files:
100
104
  - lib/podsorz/core/Config/pod_orzconfig_parse.rb
101
105
  - lib/podsorz/core/PodFile/podfile_io.rb
102
106
  - lib/podsorz/core/PodFile/podfile_model.rb
107
+ - lib/podsorz/core/PodsOrz/pods_check_merge.rb
103
108
  - lib/podsorz/core/PodsOrz/pods_detector.rb
104
109
  - lib/podsorz/core/PodsOrz/pods_git_manager.rb
105
110
  - lib/podsorz/core/PodsOrz/pods_git_operator.rb
106
111
  - lib/podsorz/core/PodsOrz/pods_repo.rb
112
+ - lib/podsorz/core/PodsOrz/pods_sort.rb
107
113
  - lib/podsorz/core/PodsOrz/pods_version.rb
108
114
  - lib/podsorz/core/Specs/podspec_model.rb
109
115
  - lib/podsorz/util/git_operator.rb