gct 0.3.95 → 0.4.3
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 +4 -4
- data/lib/gct.rb +4 -0
- data/lib/gct/command.rb +1 -3
- data/lib/gct/command/autotag.rb +158 -32
- data/lib/gct/command/init/gitlab-ci.rb +4 -0
- data/lib/gct/command/robot.rb +40 -0
- data/lib/gct/command/robot/finish.rb +10 -27
- data/lib/gct/command/robot/podfile.rb +38 -0
- data/lib/gct/command/robot/start.rb +2 -23
- data/lib/gct/command/setup.rb +9 -0
- data/lib/gct/command/spec/lint.rb +2 -2
- data/lib/gct/command/update.rb +4 -1
- data/lib/gct/command/update/analyze.rb +22 -0
- data/lib/gct/command/update/dependency.rb +43 -0
- data/lib/gct/command/update/next.rb +66 -0
- data/lib/gct/command/update/podfile.rb +83 -0
- data/lib/gct/command/update/tag.rb +87 -19
- data/lib/gct/command/update/version.rb +1 -0
- data/lib/gct/constant.rb +17 -1
- data/lib/gct/database/data.rb +28 -0
- data/lib/gct/file_base.rb +45 -0
- data/lib/gct/gct_version.rb +1 -1
- data/lib/gct/generator/gct_file.rb +4 -0
- data/lib/gct/specification.rb +8 -11
- metadata +22 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 706538e61e101d63b9718a329ba5fd7102b04b136bafe4c7fda01bc6c1d02ca9
|
4
|
+
data.tar.gz: bcba7c7cfef559c1fccf0c583a6c2a2bcf6f775eca9be2463812b1621bc81cc7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1247a36c962b9fea025ba28ec47b8a27dbd3fd7d4e1da0b9e9ff4db14436961ab4fcd738b508c9e801e34f06f3746375f86b58c987eb179070087fdea6f55620
|
7
|
+
data.tar.gz: 7c715cec4e38bbc0150d1c5ebd658a2edb485ed15a72af7269e23b4f9912bddd7635b07d7f83566e9226eec89d9e887555c802ec54b4ae8d46fdb2bc3f7e52fa
|
data/lib/gct.rb
CHANGED
data/lib/gct/command.rb
CHANGED
@@ -52,8 +52,6 @@ module Gct
|
|
52
52
|
Colored2.disable!
|
53
53
|
String.send(:define_method, :colorize) { |string, _| string }
|
54
54
|
end
|
55
|
-
|
56
|
-
config_gitlab
|
57
55
|
end
|
58
56
|
|
59
57
|
def file_contents(project_id, file, branch)
|
@@ -63,7 +61,7 @@ module Gct
|
|
63
61
|
end
|
64
62
|
|
65
63
|
def config_gitlab
|
66
|
-
if FileBase.exist_root and token
|
64
|
+
if FileBase.exist_root and token
|
67
65
|
Gitlab.configure do |config|
|
68
66
|
config.endpoint = 'https://gi-dev.ccrgt.com/api/v4'
|
69
67
|
config.private_token = token
|
data/lib/gct/command/autotag.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'pathname'
|
2
2
|
require 'tmpdir'
|
3
3
|
require 'parallel'
|
4
|
+
require 'pp'
|
4
5
|
|
5
6
|
module Gct
|
6
7
|
class Command
|
@@ -13,20 +14,27 @@ module Gct
|
|
13
14
|
self.arguments = [
|
14
15
|
CLAide::Argument.new('PROJECT_ID', true),
|
15
16
|
CLAide::Argument.new('BRANCH', true),
|
17
|
+
CLAide::Argument.new('VERSION', true),
|
16
18
|
]
|
17
19
|
|
18
20
|
def initialize(argv)
|
19
21
|
gitlab_error
|
22
|
+
config_gitlab
|
20
23
|
@update_ci = argv.flag?('update-ci', false)
|
21
|
-
@
|
24
|
+
@pre = argv.flag?('pre', false)
|
25
|
+
name = argv.shift_argument
|
26
|
+
@project_id = "ios/#{name}"
|
27
|
+
@project_name = name
|
22
28
|
@branch = argv.shift_argument
|
29
|
+
@version = argv.shift_argument
|
23
30
|
@file = 'Podfile'
|
24
31
|
super
|
25
32
|
end
|
26
33
|
|
27
34
|
def self.options
|
28
35
|
[
|
29
|
-
['--update-ci', '是否更新CI']
|
36
|
+
['--update-ci', '是否更新CI'],
|
37
|
+
['--pre', '是否为预发tag'],
|
30
38
|
].concat(super)
|
31
39
|
end
|
32
40
|
|
@@ -34,11 +42,40 @@ module Gct
|
|
34
42
|
super
|
35
43
|
help! '请输入项目名.' unless @project_id
|
36
44
|
help! '请输入分支名.' unless @branch
|
45
|
+
help! '请输入版本号.' unless @version
|
37
46
|
end
|
38
47
|
|
39
48
|
def run
|
40
49
|
FileBase.root_err
|
41
|
-
|
50
|
+
puts "开始分析podfile文件".green
|
51
|
+
puts ""
|
52
|
+
where_statement = "and is_pre = #{@pre ? 1 : 0}"
|
53
|
+
p_db = Database::Data.new
|
54
|
+
p_sql = "select * from project where version = '#{@version}' #{where_statement}"
|
55
|
+
p_res = p_db.query(p_sql)
|
56
|
+
|
57
|
+
if !p_res.nil? && p_res.count > 0
|
58
|
+
res_first = nil
|
59
|
+
p_res.each do |row|
|
60
|
+
res_first = row
|
61
|
+
break
|
62
|
+
end
|
63
|
+
if res_first["is_done"].to_i == 0
|
64
|
+
tmp_podspecs
|
65
|
+
create_tag_by_priority()
|
66
|
+
else
|
67
|
+
raise "#{@project_name} #{@version} 版本已经打完tag了!!!".red
|
68
|
+
end
|
69
|
+
else
|
70
|
+
keys = "(version, name, branch" + (@pre ? ", is_pre)" : ")")
|
71
|
+
values = "('#{@version}', '#{@project_name}', '#{@branch}'" + (@pre ? ", 1)" : ")")
|
72
|
+
db = Database::Data.new
|
73
|
+
sql = "insert into project #{keys} values #{values}"
|
74
|
+
res = db.query(sql)
|
75
|
+
untagged_specs = analyze_dependencies
|
76
|
+
priority_rank(untagged_specs)
|
77
|
+
create_tag_by_priority()
|
78
|
+
end
|
42
79
|
end
|
43
80
|
|
44
81
|
def check_branch(branch)
|
@@ -47,38 +84,85 @@ module Gct
|
|
47
84
|
end
|
48
85
|
|
49
86
|
def podfile
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
@podfile ||= begin
|
60
|
-
podfile = Pod::Podfile.from_ruby(full_path, contents)
|
61
|
-
podfile
|
62
|
-
end
|
87
|
+
contents = file_contents(@project_id, @file, @branch)
|
88
|
+
contents.force_encoding('UTF-8')
|
89
|
+
temp_local_file = TempLocalFile.new(contents, @file)
|
90
|
+
temp_local_file.write
|
91
|
+
full_path = temp_local_file.full_path
|
92
|
+
|
93
|
+
@podfile ||= begin
|
94
|
+
podfile = Pod::Podfile.from_ruby(full_path, contents)
|
95
|
+
podfile
|
63
96
|
end
|
64
97
|
end
|
65
98
|
|
66
|
-
def
|
67
|
-
untagged_git_dependencies = podfile.dependencies.select { |dependency| dependency.external? && dependency.external_source[:tag].nil? && dependency.external_source[:branch] == Constant.
|
99
|
+
def tmp_podspecs
|
100
|
+
untagged_git_dependencies = podfile.dependencies.select { |dependency| dependency.external? && dependency.external_source[:tag].nil? && dependency.external_source[:branch] == Constant.DefaultTagFromBranch}
|
101
|
+
raise "没有需要打tag的库".red if untagged_git_dependencies.count == 0
|
68
102
|
|
69
|
-
|
103
|
+
spec_files = Parallel.map(untagged_git_dependencies, in_threads: 1) do |dep|
|
104
|
+
project_name = "#{Constant.NameSpace}#{dep.name}"
|
105
|
+
branch = Constant.DefaultTagFromBranch
|
106
|
+
if @pre
|
107
|
+
branch = Constant.PreTagFromBranch
|
108
|
+
create_pre_branch(branch, project_name)
|
109
|
+
end
|
70
110
|
file_name = "#{dep.name}.podspec"
|
71
|
-
podspec_contents = file_contents(
|
111
|
+
podspec_contents = file_contents(project_name, file_name, branch)
|
72
112
|
temp_local_spec_file = TempLocalFile.new(podspec_contents, file_name)
|
73
113
|
temp_local_spec_file.write
|
74
|
-
|
114
|
+
path = temp_local_spec_file.full_path
|
115
|
+
spec = Pod::Specification.from_file(path)
|
116
|
+
remove_tag(auto_add_tag(spec.version.to_s), project_name)
|
117
|
+
path
|
118
|
+
end
|
119
|
+
spec_files
|
120
|
+
end
|
121
|
+
|
122
|
+
def create_pre_branch(branch, project_name)
|
123
|
+
puts "正在创建#{project_name}预发分支!".green
|
124
|
+
bs = Gitlab.branches(project_name)
|
125
|
+
to_b = Constant.DefaultTagToBranch
|
126
|
+
pre_to_b = Constant.PreTagToBranch
|
127
|
+
from_b = Constant.DefaultTagFromBranch
|
128
|
+
bs.each do |b|
|
129
|
+
if b["name"].eql?(branch)
|
130
|
+
Gitlab.delete_branch(project_name, branch)
|
131
|
+
end
|
132
|
+
if b["name"].eql?(pre_to_b)
|
133
|
+
Gitlab.delete_branch(project_name, pre_to_b)
|
134
|
+
end
|
135
|
+
end
|
136
|
+
Gitlab.create_branch(project_name, branch, from_b)
|
137
|
+
Gitlab.create_branch(project_name, pre_to_b, to_b)
|
138
|
+
end
|
75
139
|
|
140
|
+
def remove_tag(tag, name)
|
141
|
+
# 判断是否有这个tag
|
142
|
+
tag = "#{tag}#{Constant.PreHuffix}"
|
143
|
+
command = `git rev-parse --is-inside-work-tree`
|
144
|
+
if command.eql?("true")
|
145
|
+
`git tag -d #{tag}`
|
146
|
+
`git push origin :refs/tags/#{tag}`
|
147
|
+
else
|
148
|
+
tags = Gitlab.tags("#{name}")
|
149
|
+
tags.each do |t|
|
150
|
+
if t["name"].eql?("#{tag}")
|
151
|
+
Gitlab.delete_tag("#{name}", "#{tag}")
|
152
|
+
break
|
153
|
+
end
|
154
|
+
end
|
155
|
+
end
|
156
|
+
end
|
157
|
+
|
158
|
+
def analyze_dependencies
|
159
|
+
untagged_specs = tmp_podspecs.map do |spec_file|
|
76
160
|
# 创建podspec对象
|
77
161
|
spec = Pod::Specification.from_file(spec_file)
|
78
162
|
gct_spec = Specification.new()
|
79
163
|
gct_spec.name = spec.name
|
80
164
|
gct_spec.priority = 1000
|
81
|
-
gct_spec.status = SpecPublishStatus::
|
165
|
+
gct_spec.status = SpecPublishStatus::WAITING
|
82
166
|
gct_spec.tag = "0"
|
83
167
|
dependencySpecs = Array.new()
|
84
168
|
if spec.subspecs.length == 0
|
@@ -86,7 +170,7 @@ module Gct
|
|
86
170
|
sub_spec = Specification.new()
|
87
171
|
sub_spec.name = dep.root_name
|
88
172
|
sub_spec.priority = 1000
|
89
|
-
sub_spec.status = SpecPublishStatus::
|
173
|
+
sub_spec.status = SpecPublishStatus::WAITING
|
90
174
|
sub_spec.tag = "0"
|
91
175
|
sub_spec
|
92
176
|
end
|
@@ -97,7 +181,7 @@ module Gct
|
|
97
181
|
sub_spec = Specification.new()
|
98
182
|
sub_spec.name = dep.root_name
|
99
183
|
sub_spec.priority = 1000
|
100
|
-
sub_spec.status = SpecPublishStatus::
|
184
|
+
sub_spec.status = SpecPublishStatus::WAITING
|
101
185
|
sub_spec.tag = "0"
|
102
186
|
sub_spec
|
103
187
|
end
|
@@ -108,8 +192,7 @@ module Gct
|
|
108
192
|
gct_spec.dependencySpecs = dependencySpecs
|
109
193
|
gct_spec
|
110
194
|
end
|
111
|
-
|
112
|
-
priority_rank(untagged_specs)
|
195
|
+
untagged_specs
|
113
196
|
end
|
114
197
|
|
115
198
|
def eqlBetweenHash(hash1, hash2)
|
@@ -133,12 +216,10 @@ module Gct
|
|
133
216
|
temp_spec_map[spec.name] = spec
|
134
217
|
end
|
135
218
|
temp_spec_map_copy = Hash.new()
|
136
|
-
count = 1
|
137
219
|
|
138
220
|
while !(eqlBetweenHash(temp_spec_map, temp_spec_map_copy)) do
|
139
221
|
# 深拷贝
|
140
222
|
temp_spec_map_copy = Marshal.load(Marshal.dump(temp_spec_map))
|
141
|
-
puts "--- times == #{count} ---"
|
142
223
|
specs.map do |spec|
|
143
224
|
temp_spec = temp_spec_map[spec.name]
|
144
225
|
spec.dependencySpecs.map do |subspec|
|
@@ -150,10 +231,55 @@ module Gct
|
|
150
231
|
end
|
151
232
|
end
|
152
233
|
end
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
234
|
+
end
|
235
|
+
|
236
|
+
values = ""
|
237
|
+
temp_spec_map.each do |key, value|
|
238
|
+
values.concat("('#{@version}', '#{key}', '#{@project_name}', '#{value.tag}', '#{value.status}', #{value.priority}" + (@pre ? ", 1)," : "),"))
|
239
|
+
end
|
240
|
+
val = values[0, values.length - 1]
|
241
|
+
keys = "(project_version, pod_name, project_name, tag_version, tag_status, priority" + (@pre ? ", is_pre)" : ")")
|
242
|
+
sql = "insert into tag #{keys} values #{val}"
|
243
|
+
db = Database::Data.new
|
244
|
+
db.query(sql)
|
245
|
+
end
|
246
|
+
|
247
|
+
# 按优先级打tag, 触发第一个优先级,其他的上一优先级打完之后自动触发
|
248
|
+
def create_tag_by_priority()
|
249
|
+
db = Database::Data.new
|
250
|
+
# 查询优先级最高的为完成打tag的数据
|
251
|
+
where_statement = "and is_pre = " + (@pre ? "1" : "0")
|
252
|
+
sql = "select * from tag where priority = (select MAX(priority) from tag where project_version = '#{@version}' and tag_status != '#{SpecPublishStatus::SUCCESS}' #{where_statement})"
|
253
|
+
result = db.query(sql)
|
254
|
+
vals = ""
|
255
|
+
ins = ""
|
256
|
+
if !result.nil? && result.count > 0
|
257
|
+
result.each do |row|
|
258
|
+
if row["tag_status"].eql?(SpecPublishStatus::WAITING) || row["tag_status"].eql?(SpecPublishStatus::CANCELED) || row["tag_status"].eql?(SpecPublishStatus::FAILED)
|
259
|
+
status = SpecPublishStatus::PENDING
|
260
|
+
name = row["pod_name"]
|
261
|
+
vals.concat("when pod_name = '#{name}' then '#{status}' ")
|
262
|
+
ins.concat("'#{name}',")
|
263
|
+
system "gct update dependency #{name} tag_status #{status}"
|
264
|
+
skip_tag = ""
|
265
|
+
if row["is_tag"].to_i == 1
|
266
|
+
skip_tag = "--skip-tag"
|
267
|
+
end
|
268
|
+
pre = ""
|
269
|
+
if row["is_pre"].to_i == 1
|
270
|
+
pre = "--pre"
|
271
|
+
end
|
272
|
+
system "gct update tag #{name} --auto-tag --update-ci #{skip_tag} #{pre}"
|
273
|
+
end
|
274
|
+
end
|
275
|
+
f_ins = ins[0, ins.length - 1]
|
276
|
+
sql = "update tag set tag_status = (
|
277
|
+
case
|
278
|
+
#{vals}
|
279
|
+
end
|
280
|
+
) where pod_name in (#{f_ins}) and project_version = '#{@version}'"
|
281
|
+
update_db = Database::Data.new
|
282
|
+
update_db.query(sql)
|
157
283
|
end
|
158
284
|
end
|
159
285
|
end
|
@@ -7,10 +7,13 @@ push_pod:
|
|
7
7
|
script:
|
8
8
|
- gct robot start
|
9
9
|
- echo "开始lint 和 push podspec"
|
10
|
+
- gct update dependency $CI_PROJECT_NAME "tag_status" "deploying"
|
10
11
|
- gct clean lint $CI_PROJECT_NAME
|
11
12
|
- gct repo update
|
12
13
|
- gct repo push
|
13
14
|
- gct robot finish true
|
15
|
+
- gct update dependency $CI_PROJECT_NAME "tag_version" $CI_COMMIT_REF_NAME
|
16
|
+
- gct update next
|
14
17
|
only:
|
15
18
|
- tags
|
16
19
|
tags:
|
@@ -20,6 +23,7 @@ on_failure:
|
|
20
23
|
stage: failure
|
21
24
|
script:
|
22
25
|
- gct robot finish false
|
26
|
+
- gct update dependency $CI_PROJECT_NAME "tag_status" "failed"
|
23
27
|
when: on_failure
|
24
28
|
only:
|
25
29
|
- tags
|
data/lib/gct/command/robot.rb
CHANGED
@@ -1,5 +1,8 @@
|
|
1
1
|
require 'gct/command/robot/start'
|
2
2
|
require 'gct/command/robot/finish'
|
3
|
+
require 'gct/command/robot/podfile'
|
4
|
+
require 'net/https'
|
5
|
+
require 'json'
|
3
6
|
|
4
7
|
module Gct
|
5
8
|
class Command
|
@@ -9,6 +12,43 @@ module Gct
|
|
9
12
|
self.description = <<-DESC
|
10
13
|
发送jenkins和gitlab机器人消息
|
11
14
|
DESC
|
15
|
+
|
16
|
+
def self.options
|
17
|
+
[
|
18
|
+
['--test', '测试机器人,测试webhook'],
|
19
|
+
].concat(super)
|
20
|
+
end
|
21
|
+
|
22
|
+
def initialize(argv)
|
23
|
+
@test = argv.flag?('test', false)
|
24
|
+
super
|
25
|
+
end
|
26
|
+
|
27
|
+
def robot_send(content)
|
28
|
+
if @test
|
29
|
+
webhook = FileBase.get_config("gitlab-robot-webhook-test")
|
30
|
+
else
|
31
|
+
webhook = FileBase.get_config("gitlab-robot-webhook")
|
32
|
+
end
|
33
|
+
raise "请先设置webhook --> gct config set gitlab-robot-webhook WEBHOOK_URL" if webhook.nil? || webhook.empty?
|
34
|
+
url = URI(webhook)
|
35
|
+
|
36
|
+
http = Net::HTTP.new(url.host, url.port)
|
37
|
+
if url.scheme == "https"
|
38
|
+
http.use_ssl = true
|
39
|
+
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
40
|
+
end
|
41
|
+
|
42
|
+
data = {
|
43
|
+
"msgtype": "markdown",
|
44
|
+
"markdown": {
|
45
|
+
"content": "#{content}"
|
46
|
+
}
|
47
|
+
}.to_json
|
48
|
+
|
49
|
+
header = {'content-type':'application/json'}
|
50
|
+
response = http.post(url, data, header)
|
51
|
+
end
|
12
52
|
end
|
13
53
|
end
|
14
54
|
end
|
@@ -1,5 +1,4 @@
|
|
1
|
-
|
2
|
-
require 'json'
|
1
|
+
|
3
2
|
|
4
3
|
module Gct
|
5
4
|
class Command
|
@@ -33,33 +32,17 @@ module Gct
|
|
33
32
|
end
|
34
33
|
|
35
34
|
def run
|
35
|
+
puts @build_status.class
|
36
36
|
puts "build_status == #{@build_status}"
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
webhook = FileBase.get_config("gitlab-robot-webhook-test")
|
42
|
-
elsif
|
43
|
-
webhook = FileBase.get_config("gitlab-robot-webhook")
|
44
|
-
end
|
45
|
-
raise "请先设置webhook --> gct config set gitlab-robot-webhook WEBHOOK_URL" if webhook.nil? || webhook.empty?
|
46
|
-
url = URI(webhook)
|
47
|
-
|
48
|
-
http = Net::HTTP.new(url.host, url.port)
|
49
|
-
if url.scheme == "https"
|
50
|
-
http.use_ssl = true
|
51
|
-
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
37
|
+
if @build_status.eql?("false")
|
38
|
+
build_text = "<font color=\"comment\">CI运行失败</font>,请相关人员注意"
|
39
|
+
elsif @build_status.eql?("true")
|
40
|
+
build_text = "<font color=\"info\">CI运行成功</font>"
|
52
41
|
end
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
"content": "**#{@project_name} #{build_text}**\n\n\n>触发人:#{@user_name}\n\n>tag:#{@tag}\n\n>commitid:#{@commit_sha}\n\n>流水线地址:#{ci_text}"
|
58
|
-
}
|
59
|
-
}.to_json
|
60
|
-
|
61
|
-
header = {'content-type':'application/json'}
|
62
|
-
response = http.post(url, data, header)
|
42
|
+
ci_text = "[点击跳转](#{@ci_url})"
|
43
|
+
|
44
|
+
content = "**#{@project_name} #{build_text}**\n\n\n>触发人:#{@user_name}\n\n>tag:#{@tag}\n\n>commitid:#{@commit_sha}\n\n>流水线地址:#{ci_text}"
|
45
|
+
robot_send(content)
|
63
46
|
end
|
64
47
|
end
|
65
48
|
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'net/https'
|
2
|
+
require 'json'
|
3
|
+
|
4
|
+
module Gct
|
5
|
+
class Command
|
6
|
+
class Robot < Command
|
7
|
+
class Podfile < Robot
|
8
|
+
|
9
|
+
self.summary = 'podfile更新通知'
|
10
|
+
self.description = <<-DESC
|
11
|
+
podfile更新通知
|
12
|
+
DESC
|
13
|
+
|
14
|
+
self.arguments = [
|
15
|
+
]
|
16
|
+
|
17
|
+
def self.options
|
18
|
+
[
|
19
|
+
['--test', '测试机器人,测试webhook'],
|
20
|
+
].concat(super)
|
21
|
+
end
|
22
|
+
|
23
|
+
def initialize(argv)
|
24
|
+
@project_name = ENV['CI_PROJECT_NAME']
|
25
|
+
@tag = ENV['CI_COMMIT_REF_NAME']
|
26
|
+
@test = argv.flag?('test', false)
|
27
|
+
super
|
28
|
+
end
|
29
|
+
|
30
|
+
def run
|
31
|
+
message = " <font color=\"info\">podfile 更新完毕</font>"
|
32
|
+
content = "#{message}"
|
33
|
+
robot_send(content)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -28,30 +28,9 @@ module Gct
|
|
28
28
|
end
|
29
29
|
|
30
30
|
def run
|
31
|
-
if @test
|
32
|
-
webhook = FileBase.get_config("gitlab-robot-webhook-test")
|
33
|
-
elsif
|
34
|
-
webhook = FileBase.get_config("gitlab-robot-webhook")
|
35
|
-
end
|
36
|
-
raise "请先设置webhook --> gct config set gitlab-robot-webhook WEBHOOK_URL" if webhook.nil? || webhook.empty?
|
37
|
-
url = URI(webhook)
|
38
|
-
|
39
|
-
http = Net::HTTP.new(url.host, url.port)
|
40
|
-
if url.scheme == "https"
|
41
|
-
http.use_ssl = true
|
42
|
-
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
43
|
-
end
|
44
|
-
|
45
31
|
message = " <font color=\"info\">#{@tag}</font> 开始打tag"
|
46
|
-
|
47
|
-
|
48
|
-
"markdown": {
|
49
|
-
"content": "**#{@project_name}** #{message}"
|
50
|
-
}
|
51
|
-
}.to_json
|
52
|
-
|
53
|
-
header = {'content-type':'application/json'}
|
54
|
-
response = http.post(url, data, header)
|
32
|
+
content = "**#{@project_name}** #{message}"
|
33
|
+
robot_send(content)
|
55
34
|
end
|
56
35
|
end
|
57
36
|
end
|
data/lib/gct/command/setup.rb
CHANGED
@@ -15,9 +15,18 @@ module Gct
|
|
15
15
|
create_root_folder
|
16
16
|
create_temp_folder
|
17
17
|
create_config_file
|
18
|
+
create_backup_folder
|
18
19
|
puts "setup success!".green
|
19
20
|
end
|
20
21
|
|
22
|
+
def create_backup_folder
|
23
|
+
backup_path = Generator::GctFile.backup_folder_path
|
24
|
+
if !File.exist?(backup_path)
|
25
|
+
system "mkdir #{backup_path}", exception: true
|
26
|
+
puts "#{backup_path} 创建成功!".green
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
21
30
|
def create_root_folder
|
22
31
|
gct_path = Generator::GctFile.root_folder_path
|
23
32
|
if !File.exist?(gct_path)
|
@@ -22,8 +22,8 @@ module Gct
|
|
22
22
|
end
|
23
23
|
|
24
24
|
def run
|
25
|
-
system "pod lib lint --sources=#{Constant.GitURL}iOSCRGTPodSource.git --allow-warnings --verbose --skip-import-validation --use-libraries", exception: true
|
26
|
-
|
25
|
+
# system "pod lib lint --sources=#{Constant.GitURL}iOSCRGTPodSource.git --allow-warnings --verbose --skip-import-validation --use-libraries", exception: true
|
26
|
+
lint_spec
|
27
27
|
end
|
28
28
|
|
29
29
|
def generate_podfile(pod_name, spec_path)
|
data/lib/gct/command/update.rb
CHANGED
@@ -0,0 +1,22 @@
|
|
1
|
+
module Gct
|
2
|
+
class Command
|
3
|
+
class Update < Command
|
4
|
+
class Analyze < Update
|
5
|
+
self.summary = '编译'
|
6
|
+
self.description = <<-DESC
|
7
|
+
下一个优先级打tag
|
8
|
+
DESC
|
9
|
+
|
10
|
+
def initialize(argv)
|
11
|
+
|
12
|
+
super
|
13
|
+
end
|
14
|
+
|
15
|
+
def run
|
16
|
+
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'mysql2'
|
2
|
+
module Gct
|
3
|
+
class Command
|
4
|
+
class Update < Command
|
5
|
+
class Dependency < Update
|
6
|
+
|
7
|
+
self.summary = '更新依赖文件'
|
8
|
+
self.description = <<-DESC
|
9
|
+
更新依赖文件
|
10
|
+
DESC
|
11
|
+
|
12
|
+
self.arguments = [
|
13
|
+
CLAide::Argument.new('POD_NAME', false),
|
14
|
+
CLAide::Argument.new('FIELD', false),
|
15
|
+
CLAide::Argument.new('VALUE', false),
|
16
|
+
]
|
17
|
+
|
18
|
+
def initialize(argv)
|
19
|
+
@pod_name = argv.shift_argument
|
20
|
+
@field = argv.shift_argument
|
21
|
+
@value = argv.shift_argument
|
22
|
+
super
|
23
|
+
end
|
24
|
+
|
25
|
+
def validate!
|
26
|
+
super
|
27
|
+
end
|
28
|
+
|
29
|
+
def run
|
30
|
+
db = Database::Data.new
|
31
|
+
set_val = ""
|
32
|
+
if (@field.eql?("tag_version"))
|
33
|
+
set_val = "t.#{@field} = '#{@value}', t.tag_status = '#{SpecPublishStatus::SUCCESS}'"
|
34
|
+
else
|
35
|
+
set_val = "t.#{@field} = '#{@value}'"
|
36
|
+
end
|
37
|
+
sql = "update tag t left join project p on t.project_version = p.version set #{set_val} where t.pod_name = '#{@pod_name}' and p.is_done = 0"
|
38
|
+
db.query(sql)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
module Gct
|
2
|
+
class Command
|
3
|
+
class Update < Command
|
4
|
+
class Next < Update
|
5
|
+
self.summary = '编译'
|
6
|
+
self.description = <<-DESC
|
7
|
+
下一个优先级打tag
|
8
|
+
DESC
|
9
|
+
|
10
|
+
def initialize(argv)
|
11
|
+
config_gitlab
|
12
|
+
@project_name = ENV['CI_PROJECT_NAME']
|
13
|
+
super
|
14
|
+
end
|
15
|
+
|
16
|
+
def run
|
17
|
+
db = Database::Data.new
|
18
|
+
sql = "select * from project where is_done = 0 limit 1"
|
19
|
+
res = db.query(sql)
|
20
|
+
if !res.nil? && res.count > 0
|
21
|
+
res.each do |row|
|
22
|
+
@project_name = row["name"]
|
23
|
+
@branch = row["branch"]
|
24
|
+
@version = row["version"]
|
25
|
+
puts "pre is #{row["is_pre"].to_i == 1}"
|
26
|
+
@pre = row["is_pre"].to_i == 1
|
27
|
+
break
|
28
|
+
end
|
29
|
+
batch_tag
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def batch_tag
|
34
|
+
db = Database::Data.new
|
35
|
+
# 查询优先级最高的为完成打tag的数据
|
36
|
+
where_statement = "and is_pre = " + (@pre ? "1" : "0")
|
37
|
+
sql = "select * from tag where priority = (select MAX(priority) from tag where project_version = '#{@version}' and tag_status != '#{SpecPublishStatus::SUCCESS}' #{where_statement})"
|
38
|
+
result = db.query(sql)
|
39
|
+
puts result.count
|
40
|
+
if result.count == 0
|
41
|
+
puts "tag已全部打完!!!".green
|
42
|
+
# 执行更新podfile的操作
|
43
|
+
system "gct update podfile"
|
44
|
+
else
|
45
|
+
result.each do |row|
|
46
|
+
if row["tag_status"].eql?(SpecPublishStatus::WAITING) || row["tag_status"].eql?(SpecPublishStatus::CANCELED)
|
47
|
+
status = SpecPublishStatus::PENDING
|
48
|
+
name = row["pod_name"]
|
49
|
+
skip_tag = ""
|
50
|
+
if row["is_tag"].to_i == 1
|
51
|
+
skip_tag = "--skip-tag"
|
52
|
+
end
|
53
|
+
pre = ""
|
54
|
+
if row["is_pre"].to_i == 1
|
55
|
+
pre = "--pre"
|
56
|
+
end
|
57
|
+
system "gct update dependency #{name} status #{status}"
|
58
|
+
system "gct update tag #{name} --auto-tag --update-ci #{skip_tag} #{pre}"
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
@@ -0,0 +1,83 @@
|
|
1
|
+
module Gct
|
2
|
+
class Command
|
3
|
+
class Update < Command
|
4
|
+
class Podfile < Update
|
5
|
+
|
6
|
+
self.summary = '更新podfile文件'
|
7
|
+
self.description = <<-DESC
|
8
|
+
更新podfile文件
|
9
|
+
DESC
|
10
|
+
|
11
|
+
self.arguments = [
|
12
|
+
]
|
13
|
+
|
14
|
+
def initialize(argv)
|
15
|
+
config_gitlab
|
16
|
+
@version = argv.shift_argument
|
17
|
+
super
|
18
|
+
end
|
19
|
+
|
20
|
+
def validate!
|
21
|
+
super
|
22
|
+
end
|
23
|
+
|
24
|
+
def run
|
25
|
+
initParams
|
26
|
+
update_podfile
|
27
|
+
end
|
28
|
+
|
29
|
+
def initParams
|
30
|
+
db = Database::Data.new
|
31
|
+
sql = "select * from project where is_done = 0 order by 'create_time' desc"
|
32
|
+
result = db.query(sql)
|
33
|
+
result.each do |row|
|
34
|
+
@name = "ios/#{row["name"]}"
|
35
|
+
@branch = row["branch"]
|
36
|
+
@version = row["version"]
|
37
|
+
@file = "Podfile"
|
38
|
+
break
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def update_podfile
|
43
|
+
podspec_content = file_contents(@name, @file, @branch)
|
44
|
+
remove_regex = /dev_pod .*/
|
45
|
+
podspec_content = podspec_content.gsub!(remove_regex, "")
|
46
|
+
|
47
|
+
db = Database::Data.new
|
48
|
+
sql = "select * from tag where project_version = '#{@version}'"
|
49
|
+
result = db.query(sql)
|
50
|
+
if result.count == 0
|
51
|
+
puts "ERROR: 没有tag库".red
|
52
|
+
return
|
53
|
+
end
|
54
|
+
result.each do |row|
|
55
|
+
name = row["pod_name"]
|
56
|
+
tag = row["tag_version"]
|
57
|
+
update_regex = /.*#{name}.*/
|
58
|
+
update_match = update_regex.match(podspec_content).to_s
|
59
|
+
update_str = " pod '#{name}', '#{tag}'"
|
60
|
+
if update_match.empty?
|
61
|
+
empty_match = "# Pods for iLife"
|
62
|
+
podspec_content = podspec_content.gsub!(empty_match, "#{empty_match} \n#{update_str}") # Pods for iLife
|
63
|
+
else
|
64
|
+
podspec_content = podspec_content.gsub!(update_match, update_str)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
edit_file(podspec_content)
|
69
|
+
|
70
|
+
u_db = Database::Data.new
|
71
|
+
u_sql = "update project set is_done = 1 where version = '#{@version}'"
|
72
|
+
u_db.query(u_sql)
|
73
|
+
|
74
|
+
system "gct robot podfile"
|
75
|
+
end
|
76
|
+
|
77
|
+
def edit_file(content)
|
78
|
+
Gitlab.edit_file(@name, @file, @branch, content, "@config #{@version}版本 podfile更新")
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
@@ -17,17 +17,26 @@ module Gct
|
|
17
17
|
[
|
18
18
|
['--skip-tag', '是否忽略tag,直接触发ci'],
|
19
19
|
['--update-ci', '是否更新CI'],
|
20
|
+
['--auto-tag', '自动化'],
|
21
|
+
['--pre', '是否预发tag']
|
20
22
|
].concat(super)
|
21
23
|
end
|
22
24
|
|
23
25
|
def initialize(argv)
|
24
|
-
|
26
|
+
config_gitlab
|
25
27
|
@skip_tag = argv.flag?('skip-tag', false)
|
26
28
|
@update_ci = argv.flag?('update-ci', false)
|
27
|
-
@
|
28
|
-
|
29
|
-
@name =
|
29
|
+
@auto_tag = argv.flag?('auto-tag', false)
|
30
|
+
@pre = argv.flag?('pre', false)
|
31
|
+
@name = argv.shift_argument
|
30
32
|
@tag = argv.shift_argument
|
33
|
+
@pre_tag_suffix = Constant.PreHuffix
|
34
|
+
@update_version_branch = @pre ? Constant.PreTagFromBranch : Constant.DefaultTagFromBranch
|
35
|
+
@update_to_branch = @pre ? Constant.PreTagToBranch : Constant.DefaultTagToBranch
|
36
|
+
@file = get_spec_file
|
37
|
+
if @name.nil?
|
38
|
+
@name = @spec.name
|
39
|
+
end
|
31
40
|
@project_id = "#{Constant.NameSpace}#{@name}"
|
32
41
|
super
|
33
42
|
end
|
@@ -42,27 +51,57 @@ module Gct
|
|
42
51
|
end
|
43
52
|
|
44
53
|
def skip_tag_method
|
45
|
-
@new_tag = @spec.version
|
46
|
-
puts "tag == #{@new_tag}"
|
47
54
|
if !@update_ci
|
48
55
|
isEmptyMR = mr_to_master
|
49
56
|
if !isEmptyMR
|
50
57
|
accept_merge_request
|
51
58
|
end
|
52
59
|
end
|
60
|
+
remove_and_create_tag
|
61
|
+
end
|
62
|
+
|
63
|
+
def remove_and_create_tag
|
64
|
+
@new_tag = @spec.version
|
65
|
+
puts "new tag"
|
66
|
+
puts @new_tag
|
67
|
+
if @pre
|
68
|
+
@new_tag = "#{@new_tag}" + @pre_tag_suffix
|
69
|
+
end
|
70
|
+
puts "tag == #{@new_tag}"
|
53
71
|
# remove tag
|
54
|
-
`git
|
55
|
-
|
72
|
+
command = `git rev-parse --is-inside-work-tree`
|
73
|
+
if command.eql?("true")
|
74
|
+
`git tag -d #{@new_tag}`
|
75
|
+
`git push origin :refs/tags/#{@new_tag}`
|
76
|
+
else
|
77
|
+
remove_tag
|
78
|
+
end
|
56
79
|
# create tag
|
57
80
|
create_tag
|
58
81
|
end
|
59
82
|
|
83
|
+
def check_ci
|
84
|
+
is_exist_ci = false
|
85
|
+
res = Gitlab.tree("#{Constant.NameSpace}#{@name}")
|
86
|
+
res.each do |g|
|
87
|
+
if g["name"].eql?('.gitlab-ci.yml')
|
88
|
+
is_exist_ci = true
|
89
|
+
break
|
90
|
+
end
|
91
|
+
end
|
92
|
+
is_exist_ci
|
93
|
+
end
|
94
|
+
|
60
95
|
def update_ci_method
|
61
96
|
puts "更新ci文件".green
|
62
97
|
temp_local_file = TempLocalFile.new()
|
63
98
|
path = File.expand_path("../../init", __FILE__)
|
64
99
|
ci_content = temp_local_file.read_path_file(path, "gitlab-ci.rb")
|
65
|
-
|
100
|
+
if check_ci
|
101
|
+
edit_file('.gitlab-ci.yml', ci_content, 'update ci')
|
102
|
+
else
|
103
|
+
create_file('.gitlab-ci.yml', ci_content, 'init ci')
|
104
|
+
end
|
66
105
|
isEmptyMR = mr_to_master
|
67
106
|
if !isEmptyMR
|
68
107
|
accept_merge_request
|
@@ -70,11 +109,22 @@ module Gct
|
|
70
109
|
end
|
71
110
|
|
72
111
|
def get_spec_file
|
112
|
+
spec_file = nil
|
113
|
+
full_path = nil
|
114
|
+
if @auto_tag
|
115
|
+
raise "podspec名不能为空!!!".red if spec_file.nil? if @name.nil?
|
116
|
+
Dir.chdir(FileBase.tmp_path) do
|
117
|
+
spec_file = Pathname.glob("#{@name}.podspec").first
|
118
|
+
full_path = spec_file.realpath
|
119
|
+
raise "在 #{Dir.pwd} 目录下找不到podspec文件".red if spec_file.nil?
|
120
|
+
end
|
121
|
+
else
|
73
122
|
spec_file = Pathname.glob('*.podspec').first
|
123
|
+
full_path = spec_file
|
74
124
|
raise "在 #{Dir.pwd} 目录下找不到podspec文件".red if spec_file.nil?
|
75
|
-
|
76
|
-
|
77
|
-
|
125
|
+
end
|
126
|
+
@spec = Pod::Specification.from_file(full_path)
|
127
|
+
spec_file
|
78
128
|
end
|
79
129
|
|
80
130
|
def update_podspec_version
|
@@ -86,6 +136,9 @@ module Gct
|
|
86
136
|
tag = tag_regex.match(version_match)
|
87
137
|
@now_tag = tag
|
88
138
|
@new_tag = @tag || auto_add_tag(tag.to_s)
|
139
|
+
if @pre
|
140
|
+
@new_tag = "#{@new_tag}" + @pre_tag_suffix
|
141
|
+
end
|
89
142
|
replace_string = version_match.gsub(tag_regex, @new_tag)
|
90
143
|
updated_podspec_content = podspec_content.gsub(version_match, replace_string)
|
91
144
|
puts "修改podpsec版本号成功!版本号为:#{@new_tag}".green
|
@@ -99,15 +152,16 @@ module Gct
|
|
99
152
|
Gitlab.edit_file(@project_id, file, @update_version_branch, content, commit_message)
|
100
153
|
end
|
101
154
|
|
155
|
+
def create_file(file, content, commit_message)
|
156
|
+
Gitlab.create_file(@project_id, file, @update_version_branch, content, commit_message)
|
157
|
+
end
|
158
|
+
|
102
159
|
def mr_to_master
|
103
|
-
puts "正在创建MR
|
104
|
-
mr = Gitlab.create_merge_request("#{Constant.NameSpace}#{@name}", "mr", { source_branch: "#{@update_version_branch}", target_branch:
|
105
|
-
# puts mr.to_hash
|
160
|
+
puts "正在创建MR请求将#{@update_version_branch}分支合并到#{@update_to_branch}分支!".green
|
161
|
+
mr = Gitlab.create_merge_request("#{Constant.NameSpace}#{@name}", "mr", { source_branch: "#{@update_version_branch}", target_branch: "#{@update_to_branch}" })
|
106
162
|
@id = mr.iid
|
107
163
|
puts mr.merge_status
|
108
164
|
isEmptyMR = mr.diff_refs.base_sha.eql?(mr.diff_refs.head_sha)
|
109
|
-
# puts mr.diff_refs.base_sha
|
110
|
-
# puts mr.diff_refs.head_sha
|
111
165
|
close_mr if isEmptyMR
|
112
166
|
if mr.merge_status == 'cannot_be_merged' && !isEmptyMR
|
113
167
|
raise "Merge有冲突,请前往 https://gi-dev.ccrgt.com/#{Constant.NameSpace}#{@name}/merge_requests/#{@id} 解决".red
|
@@ -118,7 +172,7 @@ module Gct
|
|
118
172
|
def accept_merge_request
|
119
173
|
mr_result = Gitlab.accept_merge_request("#{@project_id}", @id)
|
120
174
|
if mr_result.state == 'merged'
|
121
|
-
puts "
|
175
|
+
puts "成功合并到#{@update_to_branch}分支".green
|
122
176
|
end
|
123
177
|
end
|
124
178
|
|
@@ -126,8 +180,22 @@ module Gct
|
|
126
180
|
Gitlab.update_merge_request("#{@project_id}", @id, {state_event: 'close'})
|
127
181
|
end
|
128
182
|
|
183
|
+
def remove_tag
|
184
|
+
tags = Gitlab.tags("#{@project_id}")
|
185
|
+
puts "remove tag is " + "#{@new_tag}"
|
186
|
+
tags.each do |t|
|
187
|
+
if t["name"].eql?("#{@new_tag}")
|
188
|
+
Gitlab.delete_tag("#{@project_id}", "#{@new_tag}")
|
189
|
+
break
|
190
|
+
end
|
191
|
+
end
|
192
|
+
end
|
193
|
+
|
129
194
|
def create_tag
|
130
|
-
Gitlab.create_tag("#{@project_id}", "#{@new_tag}", "
|
195
|
+
Gitlab.create_tag("#{@project_id}", "#{@new_tag}", "#{@update_to_branch}")
|
196
|
+
db = Database::Data.new
|
197
|
+
sql = "update tag t left join project p on t.project_version = p.version set t.is_tag = 1 where t.pod_name = '#{@name}' and t.is_tag != 1 and p.is_done = 0"
|
198
|
+
db.query(sql)
|
131
199
|
puts "打tag成功,开始上传podspec...".green
|
132
200
|
end
|
133
201
|
end
|
data/lib/gct/constant.rb
CHANGED
@@ -21,9 +21,25 @@ module Gct
|
|
21
21
|
"ios-third/"
|
22
22
|
end
|
23
23
|
|
24
|
-
def
|
24
|
+
def DefaultTagFromBranch
|
25
25
|
"develop"
|
26
26
|
end
|
27
|
+
|
28
|
+
def PreTagFromBranch
|
29
|
+
"pre_develop"
|
30
|
+
end
|
31
|
+
|
32
|
+
def DefaultTagToBranch
|
33
|
+
"master"
|
34
|
+
end
|
35
|
+
|
36
|
+
def PreTagToBranch
|
37
|
+
"pre_master"
|
38
|
+
end
|
39
|
+
|
40
|
+
def PreHuffix
|
41
|
+
"-pre"
|
42
|
+
end
|
27
43
|
end
|
28
44
|
end
|
29
45
|
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'mysql2'
|
2
|
+
|
3
|
+
module Gct
|
4
|
+
module Database
|
5
|
+
class Data
|
6
|
+
def initialize
|
7
|
+
@host = FileBase.get_config("host")
|
8
|
+
@password = FileBase.get_config("password")
|
9
|
+
raise "请设置数据库ip地址!".red if @host.nil?
|
10
|
+
raise "请设置数据库密码!".red if @password.nil?
|
11
|
+
end
|
12
|
+
|
13
|
+
def query(sql)
|
14
|
+
client = nil
|
15
|
+
puts "current sql is 👇👇👇"
|
16
|
+
puts sql
|
17
|
+
begin
|
18
|
+
client = Mysql2::Client.new(:host => @host, :username => "root", :database => "ios_db", :password => @password, :encoding => "utf8")
|
19
|
+
client.query(sql)
|
20
|
+
rescue => exception
|
21
|
+
puts exception
|
22
|
+
ensure
|
23
|
+
client.close
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
data/lib/gct/file_base.rb
CHANGED
@@ -7,6 +7,21 @@ module Gct
|
|
7
7
|
@path = path
|
8
8
|
end
|
9
9
|
|
10
|
+
def read_version
|
11
|
+
path = version_path
|
12
|
+
if !File.exist?(path)
|
13
|
+
return nil
|
14
|
+
end
|
15
|
+
config_map = YAML.load(File.open(path, "r"))
|
16
|
+
config_map
|
17
|
+
end
|
18
|
+
|
19
|
+
def write_version_message(verison, name, branch)
|
20
|
+
yaml_path = "#{Generator::GctFile.temp_folder_path}/version"
|
21
|
+
content_map = {"version" => verison, "name" => name, "branch" => branch}
|
22
|
+
yaml_write_map(yaml_path, content_map)
|
23
|
+
end
|
24
|
+
|
10
25
|
def yaml_write(key, value)
|
11
26
|
begin
|
12
27
|
config_map = YAML.load(File.open(@path, "r"))
|
@@ -21,6 +36,28 @@ module Gct
|
|
21
36
|
end
|
22
37
|
end
|
23
38
|
|
39
|
+
def yaml_write_map(path, content)
|
40
|
+
begin
|
41
|
+
yaml_file = File.open(path, "w")
|
42
|
+
YAML::dump(content, yaml_file)
|
43
|
+
rescue IOError => e
|
44
|
+
raise e.message
|
45
|
+
ensure
|
46
|
+
yaml_file.close unless yaml_file.nil?
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def yaml_read_map(path, key)
|
51
|
+
begin
|
52
|
+
yaml_file = YAML.load(File.open(path, "r"))
|
53
|
+
if yaml_file
|
54
|
+
yaml_file[key]
|
55
|
+
end
|
56
|
+
rescue IOError => e
|
57
|
+
raise e.message
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
24
61
|
def yaml_read(key)
|
25
62
|
begin
|
26
63
|
yaml_file = YAML.load(File.open(@path, "r"))
|
@@ -48,6 +85,14 @@ module Gct
|
|
48
85
|
"#{Generator::GctFile.config_file_path}"
|
49
86
|
end
|
50
87
|
|
88
|
+
def version_path
|
89
|
+
"#{Generator::GctFile.temp_folder_path}/version"
|
90
|
+
end
|
91
|
+
|
92
|
+
def tmp_path
|
93
|
+
"#{Generator::GctFile.temp_folder_path}"
|
94
|
+
end
|
95
|
+
|
51
96
|
def exist_root
|
52
97
|
root_exist = File.exist?(Generator::GctFile.root_folder_path)
|
53
98
|
root_exist
|
data/lib/gct/gct_version.rb
CHANGED
data/lib/gct/specification.rb
CHANGED
@@ -30,15 +30,12 @@ module Gct
|
|
30
30
|
end
|
31
31
|
|
32
32
|
module SpecPublishStatus
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
SUCCESS = '发布成功'
|
42
|
-
FAILED = '发布失败'
|
43
|
-
CANCELED = '已取消'
|
33
|
+
PENDING = 'pending'
|
34
|
+
WAITING = 'waiting'
|
35
|
+
SKIPPED = 'skipped'
|
36
|
+
MERGED = 'merged'
|
37
|
+
DEPLOYING = 'deploying'
|
38
|
+
SUCCESS = 'success'
|
39
|
+
FAILED = 'failed'
|
40
|
+
CANCELED = 'canceled'
|
44
41
|
end
|
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.3
|
4
|
+
version: 0.4.3
|
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-09-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -134,6 +134,20 @@ dependencies:
|
|
134
134
|
- - ">="
|
135
135
|
- !ruby/object:Gem::Version
|
136
136
|
version: '0'
|
137
|
+
- !ruby/object:Gem::Dependency
|
138
|
+
name: mysql2
|
139
|
+
requirement: !ruby/object:Gem::Requirement
|
140
|
+
requirements:
|
141
|
+
- - ">="
|
142
|
+
- !ruby/object:Gem::Version
|
143
|
+
version: '0'
|
144
|
+
type: :runtime
|
145
|
+
prerelease: false
|
146
|
+
version_requirements: !ruby/object:Gem::Requirement
|
147
|
+
requirements:
|
148
|
+
- - ">="
|
149
|
+
- !ruby/object:Gem::Version
|
150
|
+
version: '0'
|
137
151
|
description: '"gct ios 自动化脚本工具"'
|
138
152
|
email:
|
139
153
|
- 307113345@qq.com
|
@@ -176,14 +190,20 @@ files:
|
|
176
190
|
- lib/gct/command/repo/update.rb
|
177
191
|
- lib/gct/command/robot.rb
|
178
192
|
- lib/gct/command/robot/finish.rb
|
193
|
+
- lib/gct/command/robot/podfile.rb
|
179
194
|
- lib/gct/command/robot/start.rb
|
180
195
|
- lib/gct/command/setup.rb
|
181
196
|
- lib/gct/command/spec.rb
|
182
197
|
- lib/gct/command/spec/lint.rb
|
183
198
|
- lib/gct/command/update.rb
|
199
|
+
- lib/gct/command/update/analyze.rb
|
200
|
+
- lib/gct/command/update/dependency.rb
|
201
|
+
- lib/gct/command/update/next.rb
|
202
|
+
- lib/gct/command/update/podfile.rb
|
184
203
|
- lib/gct/command/update/tag.rb
|
185
204
|
- lib/gct/command/update/version.rb
|
186
205
|
- lib/gct/constant.rb
|
206
|
+
- lib/gct/database/data.rb
|
187
207
|
- lib/gct/file_base.rb
|
188
208
|
- lib/gct/gct_version.rb
|
189
209
|
- lib/gct/generator/gct_file.rb
|