gct 0.3.9 → 0.3.96

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: 3916a6b218a57f70b55c78f86fc05ab29bd9c0db6718ba525249a62b6f92b514
4
- data.tar.gz: bffb1a3d12eba75d4ee371c95c1a0145027d75c5d50e399520a4d7d6b9ac16e7
3
+ metadata.gz: fc724b7284f83afb5c5b2d1bc1e4056179d5b88e45d39dd375942649f8ad760b
4
+ data.tar.gz: be50780a0fc37a2bc3fcb5bcf2c403cb8addf005f67ebd2d03ef1d5a28883809
5
5
  SHA512:
6
- metadata.gz: d3e6420ec4067f11b7a72f6406949739abce31b8e0772ecede4dda7653385154dce1e89cb3bc2dc9d0707c8a15c1ff8dfd0639bb84d18d8a2e17f79b235a2c02
7
- data.tar.gz: 2e8d40284080f8a079137afe3e3c44c336d7294603549811608f33e24c91e016ebbff240c0db30a1db3c0c67ad164c74c8f77f9c0251981057a000a0f177f22c
6
+ metadata.gz: 32c305352fa1248ca6587ca5e8e1ef7a2d7bd56bfcf30390e4b769a492f1ef17bffa13df9c3b0c4f3b87bca52ebfaba2b739ccc4b2962a2e4696842943e7479c
7
+ data.tar.gz: 0011f8848cb83ace7603b49cbbc713b905213fbf4a9c837cf5ccfb41419d054423fb62ff7b7e97bad919f85fc2c2685e01cf9fa7c35e3dd346a7f92f3acb8134
@@ -27,6 +27,7 @@ module Gct
27
27
  require 'gct/command/setup'
28
28
  require 'gct/command/update'
29
29
  require 'gct/command/robot'
30
+ require 'gct/command/clean'
30
31
 
31
32
  self.abstract_command = true
32
33
  self.command = 'gct'
@@ -0,0 +1,15 @@
1
+ require 'gct/command/clean/cache'
2
+ require 'gct/command/clean/ci'
3
+ require 'gct/command/clean/lint'
4
+
5
+ module Gct
6
+ class Command
7
+ class Clean < Command
8
+ self.abstract_command = true
9
+ self.summary = '清理缓存的相关操作'
10
+ self.description = <<-DESC
11
+ 清理lint缓存,Xcode build缓存,ci build 缓存
12
+ DESC
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,26 @@
1
+ module Gct
2
+ class Command
3
+ class Clean < Command
4
+ class Cache < Clean
5
+
6
+ self.summary = '清理Xcode build缓存'
7
+ self.description = <<-DESC
8
+ 清理Xcode build缓存
9
+ DESC
10
+
11
+ def initialize(argv)
12
+
13
+ super
14
+ end
15
+
16
+ def run
17
+ home_path = Generator::GctFile.get_system_home_path().rstrip
18
+ xcache_path = "#{home_path}/Library/Developer/Xcode/DerivedData/"
19
+ `rm -rf #{xcache_path}`
20
+ end
21
+
22
+
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,23 @@
1
+ module Gct
2
+ class Command
3
+ class Clean < Command
4
+ class Ci < Clean
5
+
6
+ self.summary = '清除ci缓存'
7
+ self.description = <<-DESC
8
+ 清除ci缓存,默认清除所有
9
+ DESC
10
+
11
+ self.arguments = [
12
+ CLAide::Argument.new('POD_NAME', false),
13
+ ]
14
+
15
+ def initialize(argv)
16
+ super
17
+ end
18
+
19
+
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,28 @@
1
+ module Gct
2
+ class Command
3
+ class Clean < Command
4
+ class Lint < Clean
5
+
6
+ self.summary = '清除lint缓存'
7
+ self.description = <<-DESC
8
+ 清除lint缓存,默认清除所有
9
+ DESC
10
+
11
+ self.arguments = [
12
+ CLAide::Argument.new('POD_NAME', false),
13
+ ]
14
+
15
+ def initialize(argv)
16
+ @pod_name = argv.shift_argument
17
+ super
18
+ end
19
+
20
+ def run
21
+ home_path = Generator::GctFile.get_system_home_path().rstrip
22
+ lintcahce_path = "#{home_path}/Library/Caches/CocoaPods/Pods/External/#{@pod_name}"
23
+ `rm -rf #{lintcahce_path}`
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
@@ -7,6 +7,7 @@ push_pod:
7
7
  script:
8
8
  - gct robot start
9
9
  - echo "开始lint 和 push podspec"
10
+ - gct clean lint $CI_PROJECT_NAME
10
11
  - gct repo update
11
12
  - gct repo push
12
13
  - gct robot finish true
@@ -20,5 +21,7 @@ on_failure:
20
21
  script:
21
22
  - gct robot finish false
22
23
  when: on_failure
24
+ only:
25
+ - tags
23
26
  tags:
24
27
  - iOS
@@ -2,6 +2,7 @@ require 'gct/command/op/gems'
2
2
  require 'gct/command/op/gitconf'
3
3
  require 'gct/command/op/xcache'
4
4
  require 'gct/command/op/root'
5
+ require 'gct/command/op/lint'
5
6
 
6
7
  module Gct
7
8
  class Command
@@ -0,0 +1,35 @@
1
+ module Gct
2
+ class Command
3
+ class Op < Command
4
+ class Lint < Op
5
+
6
+ self.summary = '打开lint 缓存文件夹'
7
+ self.description = <<-DESC
8
+ 打开lint 缓存文件夹
9
+ DESC
10
+
11
+ self.arguments = [
12
+ ]
13
+
14
+ def initialize(argv)
15
+ super
16
+ end
17
+
18
+ def validate!
19
+ super
20
+ end
21
+
22
+ def run
23
+ openLintCache
24
+ end
25
+
26
+ def openLintCache
27
+ lintCache = '~/Library/Caches/CocoaPods/Pods/External/'
28
+ puts "Xcode缓存路径为:#{lintCache}".green
29
+ system "open #{lintCache}"
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
35
+
@@ -15,6 +15,12 @@ module Gct
15
15
  CLAide::Argument.new('BUILD_STATUS', true),
16
16
  ]
17
17
 
18
+ def self.options
19
+ [
20
+ ['--test', '测试机器人,测试webhook'],
21
+ ].concat(super)
22
+ end
23
+
18
24
  def initialize(argv)
19
25
  @project_name = ENV['CI_PROJECT_NAME']
20
26
  @user_name = ENV['GITLAB_USER_NAME']
@@ -22,14 +28,26 @@ module Gct
22
28
  @build_status = argv.shift_argument
23
29
  @commit_sha = ENV['CI_COMMIT_SHA']
24
30
  @ci_url = ENV['CI_PIPELINE_URL']
31
+ @test = argv.flag?('test', false)
25
32
  super
26
33
  end
27
34
 
28
35
  def run
29
- build_text = @build_status ? "<font color=\"info\">CI运行成功</font>" : "<font color=\"comment\">CI运行失败</font>,请相关人员注意"
36
+ puts @build_status.class
37
+ puts "build_status == #{@build_status}"
38
+ if @build_status.eql?('false')
39
+ build_text = "<font color=\"comment\">CI运行失败</font>,请相关人员注意"
40
+ elsif @build_status.eql?('true')
41
+ build_text = "<font color=\"info\">CI运行成功</font>"
42
+ end
30
43
  ci_text = "[点击跳转](#{@ci_url})"
31
44
 
32
- webhook = FileBase.get_config("gitlab-robot-webhook")
45
+ if @test
46
+ webhook = FileBase.get_config("gitlab-robot-webhook-test")
47
+ elsif
48
+ webhook = FileBase.get_config("gitlab-robot-webhook")
49
+ end
50
+ raise "请先设置webhook --> gct config set gitlab-robot-webhook WEBHOOK_URL" if webhook.nil? || webhook.empty?
33
51
  url = URI(webhook)
34
52
 
35
53
  http = Net::HTTP.new(url.host, url.port)
@@ -14,14 +14,25 @@ module Gct
14
14
  self.arguments = [
15
15
  ]
16
16
 
17
+ def self.options
18
+ [
19
+ ['--test', '测试机器人,测试webhook'],
20
+ ].concat(super)
21
+ end
22
+
17
23
  def initialize(argv)
18
24
  @project_name = ENV['CI_PROJECT_NAME']
19
25
  @tag = ENV['CI_COMMIT_REF_NAME']
26
+ @test = argv.flag?('test', false)
20
27
  super
21
28
  end
22
29
 
23
30
  def run
24
- webhook = FileBase.get_config("gitlab-robot-webhook")
31
+ if @test
32
+ webhook = FileBase.get_config("gitlab-robot-webhook-test")
33
+ elsif
34
+ webhook = FileBase.get_config("gitlab-robot-webhook")
35
+ end
25
36
  raise "请先设置webhook --> gct config set gitlab-robot-webhook WEBHOOK_URL" if webhook.nil? || webhook.empty?
26
37
  url = URI(webhook)
27
38
 
@@ -31,7 +31,7 @@ module Gct
31
31
  @project_id = "#{Constant.NameSpace}#{@name}"
32
32
  super
33
33
  end
34
-
34
+
35
35
  def run
36
36
  update_ci_method if @update_ci
37
37
  if @skip_tag
@@ -44,8 +44,17 @@ module Gct
44
44
  def skip_tag_method
45
45
  @new_tag = @spec.version
46
46
  puts "tag == #{@new_tag}"
47
- delete_tag # remove tag
48
- create_tag # create tag
47
+ if !@update_ci
48
+ isEmptyMR = mr_to_master
49
+ if !isEmptyMR
50
+ accept_merge_request
51
+ end
52
+ end
53
+ # remove tag
54
+ `git tag -d #{@new_tag}`
55
+ `git push origin :refs/tags/#{@new_tag}`
56
+ # create tag
57
+ create_tag
49
58
  end
50
59
 
51
60
  def update_ci_method
@@ -54,8 +63,10 @@ module Gct
54
63
  path = File.expand_path("../../init", __FILE__)
55
64
  ci_content = temp_local_file.read_path_file(path, "gitlab-ci.rb")
56
65
  edit_file('.gitlab-ci.yml', ci_content, 'update ci')
57
- mr_to_master
58
- accept_merge_request
66
+ isEmptyMR = mr_to_master
67
+ if !isEmptyMR
68
+ accept_merge_request
69
+ end
59
70
  end
60
71
 
61
72
  def get_spec_file
@@ -90,12 +101,18 @@ module Gct
90
101
 
91
102
  def mr_to_master
92
103
  puts "正在创建MR请求将develop分支合并到master!".green
93
- mr = Gitlab.create_merge_request("#{Constant.NameSpace}#{@name}", "更新版本podpesc版本号", { source_branch: "#{@update_version_branch}", target_branch: 'master' })
104
+ mr = Gitlab.create_merge_request("#{Constant.NameSpace}#{@name}", "mr", { source_branch: "#{@update_version_branch}", target_branch: 'master' })
105
+ # puts mr.to_hash
94
106
  @id = mr.iid
95
107
  puts mr.merge_status
96
- if mr.merge_status == 'cannot_be_merged'
108
+ 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
+ close_mr if isEmptyMR
112
+ if mr.merge_status == 'cannot_be_merged' && !isEmptyMR
97
113
  raise "Merge有冲突,请前往 https://gi-dev.ccrgt.com/#{Constant.NameSpace}#{@name}/merge_requests/#{@id} 解决".red
98
114
  end
115
+ isEmptyMR
99
116
  end
100
117
 
101
118
  def accept_merge_request
@@ -105,8 +122,8 @@ module Gct
105
122
  end
106
123
  end
107
124
 
108
- def delete_tag
109
- Gitlab.delete_tag("#{@project_id}", "#{@new_tag}")
125
+ def close_mr
126
+ Gitlab.update_merge_request("#{@project_id}", @id, {state_event: 'close'})
110
127
  end
111
128
 
112
129
  def create_tag
@@ -10,6 +10,7 @@ module Gct
10
10
  def yaml_write(key, value)
11
11
  begin
12
12
  config_map = YAML.load(File.open(@path, "r"))
13
+ config_map = Hash.new() if !config_map
13
14
  config_map[key] = value
14
15
  yaml_file = File.open(@path, "w")
15
16
  YAML::dump(config_map, yaml_file)
@@ -2,5 +2,5 @@ module Gct
2
2
  # freeze 冻结对象,将对象变成一个常量
3
3
  # unless 右边的代码块成立,才会运行左边的代码块
4
4
  # defined? 是用来判断本地变量是否存在,也可用来判断是否存在方法
5
- VERSION = "0.3.9".freeze unless defined? Gct::VERSION
5
+ VERSION = "0.3.96".freeze unless defined? Gct::VERSION
6
6
  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.9
4
+ version: 0.3.96
5
5
  platform: ruby
6
6
  authors:
7
7
  - jieming
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-07-29 00:00:00.000000000 Z
11
+ date: 2020-07-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -149,6 +149,10 @@ files:
149
149
  - lib/gct/command/autotag.rb
150
150
  - lib/gct/command/build.rb
151
151
  - lib/gct/command/build/r.rb
152
+ - lib/gct/command/clean.rb
153
+ - lib/gct/command/clean/cache.rb
154
+ - lib/gct/command/clean/ci.rb
155
+ - lib/gct/command/clean/lint.rb
152
156
  - lib/gct/command/config.rb
153
157
  - lib/gct/command/config/get.rb
154
158
  - lib/gct/command/config/set.rb
@@ -163,6 +167,7 @@ files:
163
167
  - lib/gct/command/op.rb
164
168
  - lib/gct/command/op/gems.rb
165
169
  - lib/gct/command/op/gitconf.rb
170
+ - lib/gct/command/op/lint.rb
166
171
  - lib/gct/command/op/root.rb
167
172
  - lib/gct/command/op/xcache.rb
168
173
  - lib/gct/command/repo.rb