fastlane-plugin-git_clone 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +59 -14
- data/lib/fastlane/plugin/git_clone/actions/git_clone_action.rb +125 -37
- data/lib/fastlane/plugin/git_clone/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 64eb120dee35d9d1e1e5e6fae180359223e450afa5d1e838903b9feea5102c2f
|
4
|
+
data.tar.gz: d8a21a8d511c01026c7fc3c42e06af2e9d976e31a29e3262fabfcb985cbd63dd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: acfe0b8f735ae5c78c4ca20d16831526632230d0b7abdb7561ad3334f33e74e8d999d5ca1bee7138260b625c4858c64c54f8e7dc8a33406065d139b3d7916a28
|
7
|
+
data.tar.gz: 7967cd0c99c8813699726b88329193f1af626fbd5647920e0898426e338477ee77c6d8b3f92610dd433d7293eb7c6996bf56d1ecc8078aab8af1c3b1b7fb89e7
|
data/README.md
CHANGED
@@ -21,20 +21,65 @@ a wrapper for git clone command
|
|
21
21
|
Check out the [example `Fastfile`](fastlane/Fastfile) to see how to use this plugin. Try it by cloning the repo, running `fastlane install_plugins` and `bundle exec fastlane test`.
|
22
22
|
|
23
23
|
```ruby
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
ret = git_clone(git:
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
ret
|
37
|
-
|
24
|
+
git = 'git@xx.com:xx/xxx.git'
|
25
|
+
|
26
|
+
# ok
|
27
|
+
ret = git_clone(git: git, path: '/Users/xiongzenghui/Desktop/test')
|
28
|
+
pp ret
|
29
|
+
|
30
|
+
# ok
|
31
|
+
ret = git_clone(
|
32
|
+
git: git,
|
33
|
+
path: '/Users/xiongzenghui/Desktop/test',
|
34
|
+
branch: 'test'
|
35
|
+
)
|
36
|
+
pp ret
|
37
|
+
|
38
|
+
# ok
|
39
|
+
ret = git_clone(
|
40
|
+
git: git,
|
41
|
+
path: '/Users/xiongzenghui/Desktop/test',
|
42
|
+
tag: '1.0.0'
|
43
|
+
)
|
44
|
+
pp ret
|
45
|
+
|
46
|
+
# ok
|
47
|
+
ret = git_clone(
|
48
|
+
git: git,
|
49
|
+
path: '/Users/xiongzenghui/Desktop/test',
|
50
|
+
branch: 'test',
|
51
|
+
depth: 1,
|
52
|
+
single_branch: true
|
53
|
+
)
|
54
|
+
pp ret
|
55
|
+
|
56
|
+
# ok
|
57
|
+
ret = git_clone(
|
58
|
+
git: git,
|
59
|
+
path: '/Users/xiongzenghui/Desktop/test',
|
60
|
+
commit: '2a0eaa52d76a09dca8d12d484f73b3b4debea033'
|
61
|
+
)
|
62
|
+
pp ret
|
63
|
+
|
64
|
+
# ok
|
65
|
+
ret = git_clone(
|
66
|
+
git: git,
|
67
|
+
path: '/Users/xiongzenghui/Desktop/test',
|
68
|
+
commit: '2a0eaa52d76a09dca8d12d484f73b3b4debea033',
|
69
|
+
# branch: 'test' # => error
|
70
|
+
# tag: '1.0.0' # => error
|
71
|
+
# depth: 1 # => error
|
72
|
+
# single_branch: true # => error
|
73
|
+
)
|
74
|
+
pp ret
|
75
|
+
|
76
|
+
# ok
|
77
|
+
ret = git_clone(
|
78
|
+
git: git,
|
79
|
+
path: '/Users/xiongzenghui/Desktop/test',
|
80
|
+
update: true
|
81
|
+
)
|
82
|
+
pp ret
|
38
83
|
```
|
39
84
|
|
40
85
|
## Run tests for this plugin
|
@@ -5,35 +5,89 @@ module Fastlane
|
|
5
5
|
module Actions
|
6
6
|
class GitCloneAction < Action
|
7
7
|
def self.run(params)
|
8
|
-
|
9
|
-
clone_path = params[:path]
|
10
|
-
git_repo_name = File.basename(git, '.git')
|
8
|
+
require 'fileutils'
|
11
9
|
|
12
|
-
|
13
|
-
|
10
|
+
git = params[:git]
|
11
|
+
path = params[:path]
|
12
|
+
update = params[:update] || false
|
13
|
+
|
14
|
+
rm_rf_repo(path) unless update
|
15
|
+
|
16
|
+
if File.exist?(path)
|
17
|
+
# update
|
18
|
+
update(params)
|
14
19
|
else
|
15
|
-
|
20
|
+
# clone
|
21
|
+
clone(params)
|
16
22
|
end
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.rm_rf_repo(path)
|
26
|
+
UI.message "❗️[git_clone] rm -rf #{path}"
|
27
|
+
FileUtils.rm_rf(path)
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.clone(params)
|
31
|
+
UI.message "❗️[git_clone] clone ..."
|
32
|
+
|
33
|
+
git = params[:git]
|
34
|
+
path = params[:path]
|
35
|
+
branch = params[:branch]
|
36
|
+
commit = params[:commit]
|
37
|
+
tag = params[:tag]
|
38
|
+
depth = params[:depth] || 1
|
39
|
+
single_branch = params[:single_branch] || false
|
40
|
+
|
41
|
+
cmd = if commit
|
42
|
+
[
|
43
|
+
"git clone #{git} #{path}",
|
44
|
+
"cd #{path}",
|
45
|
+
"git checkout #{commit}"
|
46
|
+
].join(';')
|
27
47
|
else
|
28
|
-
|
48
|
+
[
|
49
|
+
"git clone #{git} #{path}",
|
50
|
+
("-b #{branch} " if branch),
|
51
|
+
("-b #{tag} " if tag),
|
52
|
+
("--depth=#{depth} " if depth),
|
53
|
+
("--single-branch " if single_branch)
|
54
|
+
].compact.join(' ')
|
29
55
|
end
|
30
56
|
|
31
|
-
|
57
|
+
if sh(cmd) { |s| s.success? }
|
58
|
+
UI.success "✅ clone #{git} to #{path}"
|
59
|
+
true
|
60
|
+
else
|
61
|
+
UI.error "❌ clone #{git}"
|
62
|
+
false
|
63
|
+
end
|
32
64
|
end
|
33
65
|
|
34
|
-
|
35
|
-
|
36
|
-
|
66
|
+
def self.update(params)
|
67
|
+
UI.message "❗️[git_clone] update ..."
|
68
|
+
|
69
|
+
git = params[:git]
|
70
|
+
path = params[:path]
|
71
|
+
branch = params[:branch]
|
72
|
+
origin = params[:origin] || true
|
73
|
+
upstream = params[:upstream] || false
|
74
|
+
|
75
|
+
cmd = [
|
76
|
+
"cd #{path}",
|
77
|
+
"git reset --hard HEAD",
|
78
|
+
"git checkout #{branch}",
|
79
|
+
("git pull origin #{branch}" if origin),
|
80
|
+
("git pull upstream #{branch}" if upstream)
|
81
|
+
].compact.join(';')
|
82
|
+
|
83
|
+
if sh(cmd) { |s| s.success? }
|
84
|
+
UI.success "✅ update #{git} to #{path}"
|
85
|
+
true
|
86
|
+
else
|
87
|
+
UI.error "❌ update #{git}"
|
88
|
+
false
|
89
|
+
end
|
90
|
+
end
|
37
91
|
|
38
92
|
def self.description
|
39
93
|
"this is a wrapper for git clone command"
|
@@ -47,7 +101,6 @@ module Fastlane
|
|
47
101
|
[
|
48
102
|
FastlaneCore::ConfigItem.new(
|
49
103
|
key: :git,
|
50
|
-
env_name: "FL_GIT_CLONE_GIT",
|
51
104
|
description: "where from clone",
|
52
105
|
verify_block: proc do |value|
|
53
106
|
UI.user_error!("No git given, pass using `git: 'git'`") unless (value and not value.empty?)
|
@@ -55,13 +108,37 @@ module Fastlane
|
|
55
108
|
),
|
56
109
|
FastlaneCore::ConfigItem.new(
|
57
110
|
key: :path,
|
58
|
-
env_name: "FL_GIT_CLONE_PATH",
|
59
111
|
description: "where clone to dir",
|
60
|
-
|
112
|
+
verify_block: proc do |value|
|
113
|
+
UI.user_error!("No path given, pass using `path: 'path'`") unless (value and not value.empty?)
|
114
|
+
end
|
115
|
+
),
|
116
|
+
FastlaneCore::ConfigItem.new(
|
117
|
+
key: :update,
|
118
|
+
description: "update when git repo exist ?",
|
119
|
+
optional: true,
|
120
|
+
default_value: false,
|
121
|
+
is_string: false,
|
122
|
+
conflicting_options: [:branch, :tag, :commit, :depth, :single_branch]
|
123
|
+
),
|
124
|
+
FastlaneCore::ConfigItem.new(
|
125
|
+
key: :origin,
|
126
|
+
description: "git pull origin <branch>",
|
127
|
+
optional: true,
|
128
|
+
default_value: false,
|
129
|
+
is_string: false,
|
130
|
+
conflicting_options: [:upstream]
|
131
|
+
),
|
132
|
+
FastlaneCore::ConfigItem.new(
|
133
|
+
key: :upstream,
|
134
|
+
description: "git upstream origin <branch>",
|
135
|
+
optional: true,
|
136
|
+
default_value: false,
|
137
|
+
is_string: false,
|
138
|
+
conflicting_options: [:origin]
|
61
139
|
),
|
62
140
|
FastlaneCore::ConfigItem.new(
|
63
141
|
key: :depth,
|
64
|
-
env_name: "FL_GIT_CLONE_DEPTH",
|
65
142
|
description: "--depth=1",
|
66
143
|
is_string: false,
|
67
144
|
type: Integer,
|
@@ -69,13 +146,24 @@ module Fastlane
|
|
69
146
|
),
|
70
147
|
FastlaneCore::ConfigItem.new(
|
71
148
|
key: :branch,
|
72
|
-
env_name: "FL_GIT_CLONE_BRANCH",
|
73
149
|
description: "-b master",
|
74
|
-
optional: true
|
150
|
+
optional: true,
|
151
|
+
conflicting_options: [:tag, :commit]
|
152
|
+
),
|
153
|
+
FastlaneCore::ConfigItem.new(
|
154
|
+
key: :tag,
|
155
|
+
description: "git tag",
|
156
|
+
optional: true,
|
157
|
+
conflicting_options: [:branch, :commit]
|
158
|
+
),
|
159
|
+
FastlaneCore::ConfigItem.new(
|
160
|
+
key: :commit,
|
161
|
+
description: "git checkout commit",
|
162
|
+
optional: true,
|
163
|
+
conflicting_options: [:branch, :tag, :depth, :single_branch]
|
75
164
|
),
|
76
165
|
FastlaneCore::ConfigItem.new(
|
77
166
|
key: :single_branch,
|
78
|
-
env_name: "FL_GIT_CLONE_SINGLE_BRANCH",
|
79
167
|
description: "--single-branch",
|
80
168
|
optional: true,
|
81
169
|
default_value: false,
|
@@ -102,21 +190,21 @@ module Fastlane
|
|
102
190
|
git: "git@xxx.com:user/app.git"
|
103
191
|
)',
|
104
192
|
'git_clone(
|
105
|
-
git: "git@xxx.com:user/app.git",
|
106
|
-
path: "/Users/xiongzenghui/Desktop/cartool",
|
193
|
+
git: "git@xxx.com:user/app.git",
|
194
|
+
path: "/Users/xiongzenghui/Desktop/cartool",
|
107
195
|
branch: "master"
|
108
196
|
)',
|
109
197
|
'git_clone(
|
110
|
-
git: "git@xxx.com:user/app.git",
|
111
|
-
path: "/Users/xiongzenghui/Desktop/cartool",
|
112
|
-
branch: "master",
|
198
|
+
git: "git@xxx.com:user/app.git",
|
199
|
+
path: "/Users/xiongzenghui/Desktop/cartool",
|
200
|
+
branch: "master",
|
113
201
|
depth: 1
|
114
202
|
)',
|
115
203
|
'git_clone(
|
116
|
-
git: "git@xxx.com:user/app.git",
|
117
|
-
path: "/Users/xiongzenghui/Desktop/cartool",
|
118
|
-
branch: "master",
|
119
|
-
depth: 1,
|
204
|
+
git: "git@xxx.com:user/app.git",
|
205
|
+
path: "/Users/xiongzenghui/Desktop/cartool",
|
206
|
+
branch: "master",
|
207
|
+
depth: 1,
|
120
208
|
single_branch: true
|
121
209
|
)'
|
122
210
|
]
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fastlane-plugin-git_clone
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- xiongzenghui
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-12-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pry
|
@@ -167,7 +167,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
167
167
|
- !ruby/object:Gem::Version
|
168
168
|
version: '0'
|
169
169
|
requirements: []
|
170
|
-
rubygems_version: 3.0.
|
170
|
+
rubygems_version: 3.0.6
|
171
171
|
signing_key:
|
172
172
|
specification_version: 4
|
173
173
|
summary: a wrapper for git clone command
|