gct 0.3.8 → 0.3.95

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: e11a0e8f6fd269b8140df2ad74d54bdd6a49ecf5d3eabea57c34ecd2e9ab6ad5
4
- data.tar.gz: 478a642ec91c9d3c6af390af83860bc9da92d7ea2bbfdf74c451430c2495717e
3
+ metadata.gz: 3a66d72b82441d12f72050bcb612ada7ed56a250b6f647eb7e8828f126dc1285
4
+ data.tar.gz: 793399e10ac9879a19a6088808f184ba2f1496749bee1b0d113c836bafa71047
5
5
  SHA512:
6
- metadata.gz: a07a78b2eadf6986cfe53fe7eb6c714bd69debace24b84e261143d3723df74d63a02e106b63f5e6754a5723201574d617f552849bcb9d804d5409f7b39db0c0c
7
- data.tar.gz: 0356c696a37c07ef54d5ef99f9d6af1df366c852179051820912295a5af5495a7873adca27cf61ad56d3cb54f67b2d5275563508c890543b9fbef577c8f361f4
6
+ metadata.gz: d9d2b0c7d925ec5f9fcb175615d87c9ca9440b836a003449d9afd70e295c46c6ea3ab91223b2cd4d98bef5c0d326c26c179bd1a9962754665a548aec9ae23138
7
+ data.tar.gz: ea22f65f15803aefaed9e8b447c9d113dc93d78409aa6af4de2c004ca218a1c3057d907af0d17ab6272a25cac976bf8f8a1f83d529e5d05299f5ba66e67b7529
@@ -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,21 @@ 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
36
+ puts "build_status == #{@build_status}"
29
37
  build_text = @build_status ? "<font color=\"info\">CI运行成功</font>" : "<font color=\"comment\">CI运行失败</font>,请相关人员注意"
30
38
  ci_text = "[点击跳转](#{@ci_url})"
31
39
 
32
- webhook = FileBase.get_config("gitlab-robot-webhook")
40
+ if @test
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?
33
46
  url = URI(webhook)
34
47
 
35
48
  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
@@ -9,8 +9,11 @@ module Gct
9
9
 
10
10
  def yaml_write(key, value)
11
11
  begin
12
+ config_map = YAML.load(File.open(@path, "r"))
13
+ config_map = Hash.new() if !config_map
14
+ config_map[key] = value
12
15
  yaml_file = File.open(@path, "w")
13
- YAML::dump({key => value}, yaml_file)
16
+ YAML::dump(config_map, yaml_file)
14
17
  rescue IOError => e
15
18
  raise e.message
16
19
  ensure
@@ -2,5 +2,5 @@ module Gct
2
2
  # freeze 冻结对象,将对象变成一个常量
3
3
  # unless 右边的代码块成立,才会运行左边的代码块
4
4
  # defined? 是用来判断本地变量是否存在,也可用来判断是否存在方法
5
- VERSION = "0.3.8".freeze unless defined? Gct::VERSION
5
+ VERSION = "0.3.95".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.8
4
+ version: 0.3.95
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