gct 0.3.5 → 0.3.6

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: c4c7ac5d299bdcd12bcf268d4f7d703d3cc928ec1bdf68a6a7607eb88776bfa1
4
- data.tar.gz: ec3a3e19a4934758f25b7782b18033a6b5ae7b4011fe7f72a9a0600c6e31ca52
3
+ metadata.gz: 055d14cb22dd17241143aa9e423db5a5a1adbb5cfd7a86696989aa0d6f305cf7
4
+ data.tar.gz: 89dcaf76ca8b178ddfcf87bc89249a1064f1f4fd2647dce364416870fd957d88
5
5
  SHA512:
6
- metadata.gz: 8ee1ec1276911016661047a4e3b85a78e51fbc8fee6d08531075bd26c43d598e4cf066a33712e9af51e9c6a317b5621e76d964a4c931a131f4952295696b4a2d
7
- data.tar.gz: 3a10b473568f55e49de457f50f367010db7742eaf2ecde4684703a66835cbc7a7d10b1dcf8f33c41721a286c660b0aa9c682018e8db0585d4043f5b43f57ff3e
6
+ metadata.gz: e546f36acd76bd852755a04d432f8612c5ea7736a81d6d886fefd500ea6b8248e73e1b7a751bf3dcf6003c74610ce29fe7e44d864e0362955b2abdde240f42ab
7
+ data.tar.gz: b5d76987185599b11c99c2c79ee293cabcef4d59281808540835287114eed7cf261b18bd2882602fee076e1ee7481b636a2ada0b5095865a034441c0196e2cfd
@@ -68,7 +68,7 @@ module Gct
68
68
  config.private_token = token
69
69
  end
70
70
  else
71
- raise "请先运行命令:gct set token xxx,参考文档:http://febase.crgt.xyz/docs/app_ios/base".red
71
+ raise "请先运行命令:gct config set token GITLAB_TOKEN,参考文档:http://febase.crgt.xyz/docs/app_ios/base".red
72
72
  end
73
73
  end
74
74
  end
@@ -14,6 +14,20 @@ module Gct
14
14
  super
15
15
  config_gitlab
16
16
  end
17
+
18
+ def current_branch
19
+ branch = "#{`git branch | awk '$1 == "*" {print $2}'`}".rstrip
20
+ raise "该文件夹不是一个git仓库".red if branch.empty?
21
+ branch
22
+ end
23
+
24
+ def check_branch_can_be_update(branch)
25
+ can_be_update = current_branch.include?(branch)
26
+
27
+ puts "当前不是#{branch}分支".red if !can_be_update
28
+
29
+ can_be_update
30
+ end
17
31
  end
18
32
  end
19
33
  end
@@ -14,6 +14,9 @@ module Gct
14
14
 
15
15
  def initialize(argv)
16
16
  @tag = argv.shift_argument
17
+ @update_version_branch = 'develop'
18
+ @file = get_spec_file
19
+ @project_id = "#{Constant.NameSpace}#{@spec.name}"
17
20
  super
18
21
  end
19
22
 
@@ -22,28 +25,60 @@ module Gct
22
25
  end
23
26
 
24
27
  def run
25
- get_now_tag
26
- add_push_new_tag
28
+ update_podspec_version
27
29
  end
28
30
 
29
- def update_tag_podspec
30
- # 更新podspec的版本号 @new_tag 创建MR推送到远端
31
-
32
- end
33
-
34
- def get_now_tag
31
+ def get_spec_file
35
32
  spec_file = Pathname.glob('*.podspec').first
36
33
  raise "在 #{Dir.pwd} 目录下找不到podspec文件".red if spec_file.nil?
37
34
 
38
- spec = Pod::Specification.from_file(spec_file)
39
- @now_tag = spec.version
35
+ @spec = Pod::Specification.from_file(spec_file)
36
+ spec_file
37
+ end
38
+
39
+ def update_podspec_version
40
+ puts "开始读取podspec文件...".green
41
+ podspec_content = file_contents(@project_id, @file, @update_version_branch)
42
+ version_regex = /.*version.*/
43
+ version_match = version_regex.match(podspec_content).to_s
44
+ tag_regex = /(?<=')\w.*(?=')/
45
+ tag = tag_regex.match(version_match)
46
+ @now_tag = tag
47
+ @new_tag = @tag || auto_add_tag(tag.to_s)
48
+ replace_string = version_match.gsub(tag_regex, @new_tag)
49
+ @updated_podspec_content = podspec_content.gsub(version_match, replace_string)
50
+ puts "修改podpsec版本号成功!版本号为:#{@now_tag}".green
51
+ edit_file
52
+ mr_to_master
53
+ end
54
+
55
+ def edit_file
56
+ Gitlab.edit_file(@project_id, @file, @update_version_branch, @updated_podspec_content, "@config 更新版本号:#{@new_tag}")
57
+ end
58
+
59
+ def mr_to_master
60
+ puts "正在创建MR请求将develop分支合并到master!".green
61
+ mr = Gitlab.create_merge_request("#{Constant.NameSpace}#{@spec.name}", "更新版本podpesc版本号", { source_branch: "#{@update_version_branch}", target_branch: 'master' })
62
+ @id = mr.iid
63
+ puts mr.merge_status
64
+ if mr.merge_status == 'cannot_be_merged'
65
+ raise "Merge有冲突,请前往 https://gi-dev.ccrgt.com/#{Constant.NameSpace}#{@spec.name}/merge_requests/#{@id} 解决".red
66
+ end
67
+
68
+ mr_result = accept_merge_request
69
+ if mr_result.state == 'merged'
70
+ puts "成功合并到master分支".green
71
+ create_tag
72
+ end
73
+ end
74
+
75
+ def accept_merge_request
76
+ Gitlab.accept_merge_request("#{@project_id}", @id)
40
77
  end
41
78
 
42
- def add_push_new_tag
43
- @new_tag = @tag || auto_add_tag(@now_tag.to_s)
44
- update_tag_podspec
45
- `git tag #{@new_tag}`
46
- `git push origin #{@new_tag} || { exit 1; }`
79
+ def create_tag
80
+ Gitlab.create_tag("#{@project_id}", "#{@new_tag}", "master")
81
+ puts "打tag成功,开始上传podspec...".green
47
82
  end
48
83
  end
49
84
  end
@@ -9,8 +9,8 @@ module Gct
9
9
  DESC
10
10
 
11
11
  self.arguments = [
12
- CLAide::Argument.new('NAME', false),
13
12
  CLAide::Argument.new('VERSION', false),
13
+ CLAide::Argument.new('NAME', false),
14
14
  ]
15
15
 
16
16
  def initialize(argv)
@@ -32,7 +32,12 @@ module Gct
32
32
  end
33
33
 
34
34
  def update_version
35
- if check_branch_can_be_update
35
+ puts @project_id
36
+ puts @file
37
+ puts @branch
38
+ content = file_contents(@project_id, @file, @branch)
39
+ puts content
40
+ if check_branch_can_be_update('release')
36
41
  content = file_contents(@project_id, @file, @branch)
37
42
  version_var_name = 'MARKETING_VERSION = '
38
43
  version_regex = /(?<=#{version_var_name})\w.*(?=;)/
@@ -40,24 +45,12 @@ module Gct
40
45
  version = @version ||= auto_add_tag(version_match)
41
46
  updated_content = content.gsub(version_regex, version)
42
47
  edit_file(updated_content, version)
43
- else
44
- puts "当前不是release分支".red
45
48
  end
46
49
  end
47
50
 
48
51
  def edit_file(content, version)
49
52
  Gitlab.edit_file(@project_id, @file, @branch, content, "@config 更新版本号:#{version}")
50
53
  end
51
-
52
- def check_branch_can_be_update
53
- current_branch.include?('release')
54
- end
55
-
56
- def current_branch
57
- branch = "#{`git branch | awk '$1 == "*" {print $2}'`}".rstrip
58
- raise "该文件夹不是一个git仓库".red if branch.empty?
59
- branch
60
- end
61
54
  end
62
55
  end
63
56
  end
@@ -2,5 +2,5 @@ module Gct
2
2
  # freeze 冻结对象,将对象变成一个常量
3
3
  # unless 右边的代码块成立,才会运行左边的代码块
4
4
  # defined? 是用来判断本地变量是否存在,也可用来判断是否存在方法
5
- VERSION = "0.3.5".freeze unless defined? Gct::VERSION
5
+ VERSION = "0.3.6".freeze unless defined? Gct::VERSION
6
6
  end
@@ -1,17 +1,16 @@
1
1
  module Gct
2
2
  module Generator
3
3
  class GctFile
4
-
5
4
  def self.root_folder_path
6
- "/Users/#{get_system_user_name.rstrip}/.gct"
5
+ "#{get_system_home_path.rstrip}/.gct"
7
6
  end
8
7
 
9
8
  def self.temp_folder_path
10
- "/Users/#{get_system_user_name.rstrip}/.gct/tmp"
9
+ "#{get_system_home_path.rstrip}/.gct/tmp"
11
10
  end
12
11
 
13
12
  def self.config_file_path
14
- "/Users/#{get_system_user_name.rstrip}/.gct/config"
13
+ "#{get_system_home_path.rstrip}/.gct/config"
15
14
  end
16
15
 
17
16
  # 获取系统用户名
@@ -27,6 +26,10 @@ module Gct
27
26
  end
28
27
  end
29
28
 
29
+ def self.get_system_home_path
30
+ "#{`echo ~`}"
31
+ end
32
+
30
33
  end
31
34
  end
32
35
  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.5
4
+ version: 0.3.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-05-27 00:00:00.000000000 Z
11
+ date: 2020-06-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -201,7 +201,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
201
201
  - !ruby/object:Gem::Version
202
202
  version: '0'
203
203
  requirements: []
204
- rubygems_version: 3.0.3
204
+ rubygems_version: 3.0.8
205
205
  signing_key:
206
206
  specification_version: 4
207
207
  summary: '"gct ios 自动化脚本工具"'