gct 0.5.5 → 0.5.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/gct/command.rb +1 -1
- data/lib/gct/command/autotag.rb +21 -10
- data/lib/gct/command/init/ci.rb +1 -1
- data/lib/gct/command/init/{gitlab-ci.rb → ios-ci.rb} +0 -0
- data/lib/gct/command/init/ios-thirdpart-ci.rb +29 -0
- data/lib/gct/command/robot/podfile.rb +11 -1
- data/lib/gct/command/update/tag.rb +15 -7
- data/lib/gct/gct_version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4e318b5c37b33f5817c365674563b449e2621357cc69f89baf3d4e4e32938d62
|
4
|
+
data.tar.gz: 205fe7fae1b93d40edb9ca032f3e39cf5f616351e2ea84df7bef4f246bbc882d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 91b755107f0c6e1c72d1b6d00318e20b6b0af5dd85f1a1e8216f6c8b242921f107b1b0979aad893d95c09ba0883aef86f7aca8ef7a2e3bfeb4f4660cf783e634
|
7
|
+
data.tar.gz: 413d382f1fd3c33c1fa753011f484105123028440ac91af06427466c975636cf069103854fa82970418c7f5dbdb32c4433cd59d95aa93eb43c90979b0def09c1
|
data/lib/gct/command.rb
CHANGED
@@ -94,8 +94,8 @@ module Gct
|
|
94
94
|
end
|
95
95
|
|
96
96
|
def auto_add_tag(tag)
|
97
|
-
puts "current tag = #{tag}"
|
98
97
|
tag_points = tag.to_s.split('.')
|
98
|
+
raise "tag is nil" if tag_points.length <= 0
|
99
99
|
index = tag_points.length - 1
|
100
100
|
need_add_point = tag_points[index].to_i + 1
|
101
101
|
tag_points[index] = need_add_point == 10 ? 0 : need_add_point
|
data/lib/gct/command/autotag.rb
CHANGED
@@ -74,11 +74,6 @@ module Gct
|
|
74
74
|
raise "#{@project_name} #{@version} 版本已经打完tag了!!!".red
|
75
75
|
end
|
76
76
|
else
|
77
|
-
keys = "(version, name, branch" + (@pre ? ", is_pre)" : ")")
|
78
|
-
values = "('#{@version}', '#{@project_name}', '#{@branch}'" + (@pre ? ", 1)" : ")")
|
79
|
-
db = Database::Data.new
|
80
|
-
sql = "insert into project #{keys} values #{values}"
|
81
|
-
res = db.query(sql)
|
82
77
|
untagged_specs = analyze_dependencies
|
83
78
|
priority_rank(untagged_specs)
|
84
79
|
create_tag_by_priority()
|
@@ -115,7 +110,16 @@ module Gct
|
|
115
110
|
raise "没有需要打tag的库".red if untagged_git_dependencies.count == 0
|
116
111
|
|
117
112
|
spec_files = Parallel.map(untagged_git_dependencies, in_threads: 1) do |dep|
|
118
|
-
|
113
|
+
# 取出组名
|
114
|
+
source = dep.external_source[:git]
|
115
|
+
left1 = "https://gi-dev.ccrgt.com/"
|
116
|
+
left2 = "http://gi-dev.ccrgt.com/"
|
117
|
+
right = "/"
|
118
|
+
source_regex = /(?<=#{left1}|#{left2}).*(?=#{right})/
|
119
|
+
group_name = source_regex.match(source).to_s
|
120
|
+
raise "gitlab中找不到#{dep.name}所在的group".red if group_name.nil? || group_name.empty?
|
121
|
+
|
122
|
+
project_name = "#{group_name}/#{dep.name}"
|
119
123
|
branch = Constant.DefaultTagFromBranch
|
120
124
|
if @pre
|
121
125
|
branch = Constant.PreTagFromBranch
|
@@ -246,7 +250,9 @@ module Gct
|
|
246
250
|
end
|
247
251
|
end
|
248
252
|
end
|
249
|
-
|
253
|
+
# 写入project
|
254
|
+
write_project
|
255
|
+
# 写入tag
|
250
256
|
values = ""
|
251
257
|
temp_spec_map.each do |key, value|
|
252
258
|
values.concat("('#{@version}', '#{key}', '#{@project_name}', '#{value.tag}', '#{value.status}', #{value.priority}" + (@pre ? ", 1)," : "),"))
|
@@ -258,6 +264,14 @@ module Gct
|
|
258
264
|
db.query(sql)
|
259
265
|
end
|
260
266
|
|
267
|
+
def write_project
|
268
|
+
keys = "(version, name, branch" + (@pre ? ", is_pre)" : ")")
|
269
|
+
values = "('#{@version}', '#{@project_name}', '#{@branch}'" + (@pre ? ", 1)" : ")")
|
270
|
+
db = Database::Data.new
|
271
|
+
sql = "insert into project #{keys} values #{values}"
|
272
|
+
res = db.query(sql)
|
273
|
+
end
|
274
|
+
|
261
275
|
# 按优先级打tag, 触发第一个优先级,其他的上一优先级打完之后自动触发
|
262
276
|
def create_tag_by_priority()
|
263
277
|
db = Database::Data.new
|
@@ -272,11 +286,8 @@ module Gct
|
|
272
286
|
if row["tag_status"].eql?(SpecPublishStatus::WAITING) || row["tag_status"].eql?(SpecPublishStatus::CANCELED) || row["tag_status"].eql?(SpecPublishStatus::FAILED)
|
273
287
|
status = SpecPublishStatus::PENDING
|
274
288
|
name = row["pod_name"]
|
275
|
-
puts "pod name is " + name
|
276
289
|
vals.concat("when pod_name = '#{name}' then '#{status}' ")
|
277
|
-
puts vals
|
278
290
|
ins.concat("'#{name}',")
|
279
|
-
puts ins
|
280
291
|
system "gct update dependency #{name} tag_status #{status}"
|
281
292
|
skip_tag = ""
|
282
293
|
if row["is_tag"].to_i == 1
|
data/lib/gct/command/init/ci.rb
CHANGED
File without changes
|
@@ -0,0 +1,29 @@
|
|
1
|
+
stages:
|
2
|
+
- push
|
3
|
+
- failure
|
4
|
+
|
5
|
+
push_pod:
|
6
|
+
stage: push
|
7
|
+
script:
|
8
|
+
- echo "开始lint 和 push podspec"
|
9
|
+
- gct update dependency $CI_PROJECT_NAME "tag_status" "deploying"
|
10
|
+
- gct clean lint $CI_PROJECT_NAME
|
11
|
+
- gct repo update
|
12
|
+
- gct repo push $CI_PROJECT_NAME
|
13
|
+
- gct update dependency $CI_PROJECT_NAME "tag_version" $CI_COMMIT_REF_NAME
|
14
|
+
- gct update next
|
15
|
+
only:
|
16
|
+
- tags
|
17
|
+
tags:
|
18
|
+
- ios-third
|
19
|
+
|
20
|
+
on_failure:
|
21
|
+
stage: failure
|
22
|
+
script:
|
23
|
+
- gct robot finish false
|
24
|
+
- gct update dependency $CI_PROJECT_NAME "tag_status" "failed"
|
25
|
+
when: on_failure
|
26
|
+
only:
|
27
|
+
- tags
|
28
|
+
tags:
|
29
|
+
- ios-third
|
@@ -28,7 +28,17 @@ module Gct
|
|
28
28
|
end
|
29
29
|
|
30
30
|
def run
|
31
|
-
|
31
|
+
db = Database::Data.new
|
32
|
+
sql = "select * from project where is_done = 1 order by create_time DESC limit 1"
|
33
|
+
res = db.query(sql)
|
34
|
+
message = "<font color=\"info\">podfile 更新完毕</font>"
|
35
|
+
if !res.nil? && res.count > 0
|
36
|
+
res.each do |row|
|
37
|
+
branch = row["branch"]
|
38
|
+
message = "<font color=\"info\">#{branch} podfile 更新完毕</font>"
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
32
42
|
content = "#{message}"
|
33
43
|
robot_send(content)
|
34
44
|
end
|
@@ -37,7 +37,7 @@ module Gct
|
|
37
37
|
if @name.nil?
|
38
38
|
@name = @spec.name
|
39
39
|
end
|
40
|
-
@project_id = "#{
|
40
|
+
@project_id = "#{@group_name}/#{@name}"
|
41
41
|
super
|
42
42
|
end
|
43
43
|
|
@@ -80,7 +80,7 @@ module Gct
|
|
80
80
|
|
81
81
|
def check_ci
|
82
82
|
is_exist_ci = false
|
83
|
-
res = Gitlab.tree("#{
|
83
|
+
res = Gitlab.tree("#{@group_name}/#{@name}")
|
84
84
|
res.each do |g|
|
85
85
|
if g["name"].eql?('.gitlab-ci.yml')
|
86
86
|
is_exist_ci = true
|
@@ -94,10 +94,10 @@ module Gct
|
|
94
94
|
puts "正在检查CI文件".green
|
95
95
|
temp_local_file = TempLocalFile.new()
|
96
96
|
path = File.expand_path("../../init", __FILE__)
|
97
|
-
ci_content = temp_local_file.read_path_file(path, "
|
97
|
+
ci_content = temp_local_file.read_path_file(path, "#{@group_name}-ci.rb")
|
98
98
|
if check_ci
|
99
99
|
# 检查 ci 文件是否有变化
|
100
|
-
remote_content = file_contents("#{
|
100
|
+
remote_content = file_contents("#{@group_name}/#{@name}", '.gitlab-ci.yml', @update_version_branch)
|
101
101
|
remote_content.force_encoding('UTF-8')
|
102
102
|
strip_remote_content = remote_content.gsub(/\s/,'')
|
103
103
|
ci_content.force_encoding('UTF-8')
|
@@ -139,6 +139,14 @@ module Gct
|
|
139
139
|
raise "在 #{Dir.pwd} 目录下找不到podspec文件".red if spec_file.nil?
|
140
140
|
end
|
141
141
|
@spec = Pod::Specification.from_file(full_path)
|
142
|
+
# 取出组名
|
143
|
+
source = @spec.source[:git]
|
144
|
+
left1 = "https://gi-dev.ccrgt.com/"
|
145
|
+
left2 = "http://gi-dev.ccrgt.com/"
|
146
|
+
right = "/"
|
147
|
+
source_regex = /(?<=#{left1}|#{left2}).*(?=#{right})/
|
148
|
+
@group_name = source_regex.match(source).to_s
|
149
|
+
raise "gitlab中找不到#{@spec.name}所在的group".red if @group_name.nil? || @group_name.empty?
|
142
150
|
spec_file
|
143
151
|
end
|
144
152
|
|
@@ -147,7 +155,7 @@ module Gct
|
|
147
155
|
podspec_content = file_contents(@project_id, @file, @update_version_branch)
|
148
156
|
version_regex = /.*version.*/
|
149
157
|
version_match = version_regex.match(podspec_content).to_s
|
150
|
-
tag_regex = /(?<=')\w.*(?=')/
|
158
|
+
tag_regex = /(?<="|')\w.*(?="|')/
|
151
159
|
tag = tag_regex.match(version_match)
|
152
160
|
@now_tag = tag
|
153
161
|
@new_tag = @tag || auto_add_tag(tag.to_s)
|
@@ -173,13 +181,13 @@ module Gct
|
|
173
181
|
|
174
182
|
def mr_to_master
|
175
183
|
puts "正在创建MR请求将#{@update_version_branch}分支合并到#{@update_to_branch}分支!".green
|
176
|
-
mr = Gitlab.create_merge_request("#{
|
184
|
+
mr = Gitlab.create_merge_request("#{@group_name}/#{@name}", "mr", { source_branch: "#{@update_version_branch}", target_branch: "#{@update_to_branch}" })
|
177
185
|
@id = mr.iid
|
178
186
|
puts mr.merge_status
|
179
187
|
isEmptyMR = mr.diff_refs.base_sha.eql?(mr.diff_refs.head_sha)
|
180
188
|
close_mr if isEmptyMR
|
181
189
|
if mr.merge_status == 'cannot_be_merged' && !isEmptyMR
|
182
|
-
raise "Merge有冲突,请前往 https://gi-dev.ccrgt.com/#{
|
190
|
+
raise "Merge有冲突,请前往 https://gi-dev.ccrgt.com/#{@group_name}/#{@name}/merge_requests/#{@id} 解决".red
|
183
191
|
end
|
184
192
|
isEmptyMR
|
185
193
|
end
|
data/lib/gct/gct_version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gct
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- jieming
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-12-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -176,7 +176,8 @@ files:
|
|
176
176
|
- lib/gct/command/create/third.rb
|
177
177
|
- lib/gct/command/init.rb
|
178
178
|
- lib/gct/command/init/ci.rb
|
179
|
-
- lib/gct/command/init/
|
179
|
+
- lib/gct/command/init/ios-ci.rb
|
180
|
+
- lib/gct/command/init/ios-thirdpart-ci.rb
|
180
181
|
- lib/gct/command/init/unit.rb
|
181
182
|
- lib/gct/command/op.rb
|
182
183
|
- lib/gct/command/op/gems.rb
|