gct 0.1.8 → 0.1.9

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: 6e18bb9c83c63a7d74ae25f4daad3c587bfefa34b075f5ca86d4215364a5b439
4
- data.tar.gz: 1d042cfe7f8e377d80dfe519edde7ea234a146335e545b09d460c661126031ca
3
+ metadata.gz: c06014224ab0efd5c15476793d97d566c7089bbc11b52a5aed2550c30655e8b7
4
+ data.tar.gz: 3d58f23f04cbf4a618dc8a9810fa4a49d3e41078fe8b0ce84d06181e1fbd69ce
5
5
  SHA512:
6
- metadata.gz: a46115162428815439183e1c394568553cb35ee695819f6b800b89e0899ed3bf7dc5707ea317ed83867e1146c62464b68a302ee3081d237f3a672a5a30db2fe3
7
- data.tar.gz: 4c9b1c2717007e576ab04e1a3293c8c0fef91e504a8d56d04ee88094477ab02641e9575614cfffeffc2165d8ab47e730445f612fe279aebbe9b9a9af71026393
6
+ metadata.gz: a43586d042e87cf2ee7640c902f84a1e64caa9a3779a50dfcde6094f0fbfecb57da288de2ebd28dbd90a0f1ebea9bf87482457bb6b31eae1b6ab3d63f5c663e9
7
+ data.tar.gz: 7115bddc78ff2a5c9b74610c5c3b3a0b6e17dd486f9dcadd8ae46ee1643b8ce4cf7bb8fabe1f01d19e1ede541acbe6eda6ec789e43a9d243520cda10b20b74c2
@@ -10,12 +10,13 @@ module Gct
10
10
 
11
11
  self.arguments = [
12
12
  CLAide::Argument.new('URL', true),
13
+ CLAide::Argument.new('BRANCH', false),
13
14
  ]
14
15
 
15
16
  def initialize(argv)
16
17
  @url = argv.shift_argument
18
+ @branch = argv.shift_argument
17
19
  super
18
- @additional_args = argv.remainder!
19
20
  end
20
21
 
21
22
  def validate!
@@ -24,16 +25,38 @@ module Gct
24
25
  end
25
26
 
26
27
  def run
27
- # fork 第三方仓库流程
28
- `git clone #{@url}`
29
- dir = @url.match(/[a-z|\-]+(?=\.git)/)
30
- `cd dir`
31
- `git remote set-url origin #{Constant.GitURL}#{dir}.git`
32
- `git push origin master`
33
- `git push --tags`
34
- # TODO 将podspec上传到私有specs上
28
+ if @url.include? '.git'
29
+ fork_third_pod_to_gitlab
30
+ else
31
+ puts "该链接不是一个Git仓库".red
32
+ end
33
+ end
35
34
 
36
- puts "fork 第三方库成功!".green
35
+ def fork_third_pod_to_gitlab
36
+ reg = /[a-zA-Z|\-|_|0-9]+(?=\.git)/
37
+ dir = reg.match(@url)
38
+ path = "#{Dir.pwd}/#{dir}"
39
+ if File::exist?(path)
40
+ puts "#{dir}文件夹已存在!".red
41
+ else
42
+ branch = @branch.to_s.empty? ? '' : "-b #{@branch}"
43
+ `git clone #{branch} #{@url}`
44
+ puts "git命令为:<-- git clone #{branch} #{@url} -->".green
45
+ Dir.chdir(path) do
46
+ git_url = "#{Constant.GitURL}#{dir}"
47
+ `git init`
48
+ `git remote set-url origin #{git_url}.git`
49
+ `git add .`
50
+ `git commit -m "First commit"`
51
+ `git push -u origin master`
52
+ `git push --tags`
53
+ # TODO 将podspec上传到私有specs上
54
+
55
+ puts "fork 第三方库成功!".green
56
+ puts "git 地址为:#{git_url}".green
57
+ system "open #{git_url}"
58
+ end
59
+ end
37
60
  end
38
61
  end
39
62
  end
@@ -24,8 +24,16 @@ module Gct
24
24
  end
25
25
 
26
26
  def openGems
27
- puts 'gem路径为:/Library/Ruby/Gems/'.green
28
- system 'open /Library/Ruby/Gems/'
27
+ last_version_file = "0"
28
+ Dir.foreach('/Library/Ruby/Gems/') do |file|
29
+ if file.to_s > last_version_file
30
+ last_version_file = file.to_s
31
+ end
32
+ end
33
+ version = last_version_file
34
+ path = "/Library/Ruby/Gems/#{version}/gems"
35
+ puts "gem路径为:#{path}".green
36
+ system "open #{path}"
29
37
  end
30
38
  end
31
39
  end
data/lib/gct/version.rb CHANGED
@@ -2,5 +2,5 @@ module Gct
2
2
  # freeze 冻结对象,将对象变成一个常量
3
3
  # unless 右边的代码块成立,才会运行左边的代码块
4
4
  # defined? 是用来判断本地变量是否存在,也可用来判断是否存在方法
5
- VERSION = "0.1.8".freeze unless defined? Gct::VERSION
5
+ VERSION = "0.1.9".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.1.8
4
+ version: 0.1.9
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-08 00:00:00.000000000 Z
11
+ date: 2020-05-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler