pindo 4.6.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/bin/pindo +35 -0
- data/lib/pindo/base/aeshelper.rb +31 -0
- data/lib/pindo/base/deviceinfo.rb +90 -0
- data/lib/pindo/base/executable.rb +224 -0
- data/lib/pindo/base/githelper.rb +489 -0
- data/lib/pindo/base/hashhelper.rb +134 -0
- data/lib/pindo/base/plaininformative.rb +15 -0
- data/lib/pindo/base/plistbuddyexecutable.rb +121 -0
- data/lib/pindo/base/standarderror.rb +14 -0
- data/lib/pindo/client/applovinclient.rb +156 -0
- data/lib/pindo/client/aws3sclient.rb +183 -0
- data/lib/pindo/client/bossclient.rb +229 -0
- data/lib/pindo/client/bossconfigclient.rb +175 -0
- data/lib/pindo/client/giteeclient.rb +65 -0
- data/lib/pindo/client/httpclient.rb +40 -0
- data/lib/pindo/client/pgyerclient.rb +439 -0
- data/lib/pindo/client/tgateclient.rb +103 -0
- data/lib/pindo/command.rb +101 -0
- data/lib/pindo/config/pindoconfig.rb +439 -0
- data/lib/pindo/config/pindouserlocalconfig.rb +81 -0
- data/lib/pindo/deploy/Fastfile +233 -0
- data/lib/pindo/deploy/build.rb +167 -0
- data/lib/pindo/deploy/bundleid.rb +245 -0
- data/lib/pindo/deploy/cert.rb +508 -0
- data/lib/pindo/deploy/check.rb +79 -0
- data/lib/pindo/deploy/configproj.rb +89 -0
- data/lib/pindo/deploy/confusecode.rb +248 -0
- data/lib/pindo/deploy/confuseproj.rb +112 -0
- data/lib/pindo/deploy/fabric.rb +58 -0
- data/lib/pindo/deploy/getitcinfo.rb +248 -0
- data/lib/pindo/deploy/iap.rb +796 -0
- data/lib/pindo/deploy/initconfig.rb +128 -0
- data/lib/pindo/deploy/itcapp.rb +147 -0
- data/lib/pindo/deploy/itcinfo.rb +369 -0
- data/lib/pindo/deploy/pem.rb +55 -0
- data/lib/pindo/deploy/pullconfig.rb +46 -0
- data/lib/pindo/deploy/pushconfig.rb +83 -0
- data/lib/pindo/deploy/quswark.rb +146 -0
- data/lib/pindo/deploy/quswauth.rb +67 -0
- data/lib/pindo/deploy/reportbug.rb +135 -0
- data/lib/pindo/deploy/resign.rb +338 -0
- data/lib/pindo/deploy/tag.rb +108 -0
- data/lib/pindo/deploy/updateconfig.rb +129 -0
- data/lib/pindo/deploy/uploadipa.rb +63 -0
- data/lib/pindo/deploy.rb +44 -0
- data/lib/pindo/dev/autobuild.rb +204 -0
- data/lib/pindo/dev/autoresign.rb +186 -0
- data/lib/pindo/dev/confusecode.rb +127 -0
- data/lib/pindo/dev/confuseproj.rb +111 -0
- data/lib/pindo/dev/createbuild.rb +159 -0
- data/lib/pindo/dev/debug.rb +141 -0
- data/lib/pindo/dev/pub.rb +171 -0
- data/lib/pindo/dev/renewcert.rb +142 -0
- data/lib/pindo/dev.rb +23 -0
- data/lib/pindo/env/dreamstudio.rb +53 -0
- data/lib/pindo/env/flutter.rb +59 -0
- data/lib/pindo/env/flutter.sh +116 -0
- data/lib/pindo/env/quarkenv.rb +58 -0
- data/lib/pindo/env/swarkenv.rb +62 -0
- data/lib/pindo/env/workhard.rb +56 -0
- data/lib/pindo/env.rb +17 -0
- data/lib/pindo/ipa/autoresign.rb +188 -0
- data/lib/pindo/ipa/import.rb +261 -0
- data/lib/pindo/ipa/output.rb +396 -0
- data/lib/pindo/ipa.rb +22 -0
- data/lib/pindo/lib/forcepush.rb +159 -0
- data/lib/pindo/lib/lint.rb +115 -0
- data/lib/pindo/lib/push.rb +143 -0
- data/lib/pindo/lib/update.rb +75 -0
- data/lib/pindo/lib.rb +18 -0
- data/lib/pindo/module/appselect.rb +200 -0
- data/lib/pindo/module/appstore_in_app_purchase.rb +1803 -0
- data/lib/pindo/module/appstore_metadata_connect_api_helper.rb +12 -0
- data/lib/pindo/module/appstore_metadata_fastlane_helper.rb +922 -0
- data/lib/pindo/module/buildconfighelper.rb +13 -0
- data/lib/pindo/module/buildhelper.rb +76 -0
- data/lib/pindo/module/commonconfuseproj.rb +271 -0
- data/lib/pindo/module/config_project.sh +143 -0
- data/lib/pindo/module/configprojhelper.rb +631 -0
- data/lib/pindo/module/iap_tier.json +813 -0
- data/lib/pindo/module/icon_contents.json +116 -0
- data/lib/pindo/module/imessage_icon.json +91 -0
- data/lib/pindo/module/imgset_contents.json +21 -0
- data/lib/pindo/module/launchimg_contents.json +21 -0
- data/lib/pindo/module/pemcreate.rb +63 -0
- data/lib/pindo/module/pgyerhelper.rb +339 -0
- data/lib/pindo/module/xcodebuildpre.rb +258 -0
- data/lib/pindo/module/xcodehelper.rb +521 -0
- data/lib/pindo/options/appconfigoptions.rb +23 -0
- data/lib/pindo/options/deployoptions.rb +363 -0
- data/lib/pindo/pgyer/apptest.rb +104 -0
- data/lib/pindo/pgyer/comment.rb +95 -0
- data/lib/pindo/pgyer/download.rb +105 -0
- data/lib/pindo/pgyer/login.rb +61 -0
- data/lib/pindo/pgyer/upload.rb +234 -0
- data/lib/pindo/pgyer.rb +17 -0
- data/lib/pindo/repo/clone.rb +78 -0
- data/lib/pindo/repo/create.rb +55 -0
- data/lib/pindo/repo/login.rb +64 -0
- data/lib/pindo/repo/search.rb +60 -0
- data/lib/pindo/repo.rb +16 -0
- data/lib/pindo/setup.rb +60 -0
- data/lib/pindo/upgrade.rb +56 -0
- data/lib/pindo/utils/applovin.rb +213 -0
- data/lib/pindo/utils/boss.rb +209 -0
- data/lib/pindo/utils/clearcert.rb +60 -0
- data/lib/pindo/utils/device.rb +279 -0
- data/lib/pindo/utils/icon.rb +91 -0
- data/lib/pindo/utils/icon.sh +133 -0
- data/lib/pindo/utils/podindex.rb +56 -0
- data/lib/pindo/utils/podindex.sh +30 -0
- data/lib/pindo/utils/renewproj.rb +146 -0
- data/lib/pindo/utils/tgate.rb +159 -0
- data/lib/pindo/utils/xcassets.rb +46 -0
- data/lib/pindo/utils/xcassets.sh +88 -0
- data/lib/pindo/utils.rb +29 -0
- data/lib/pindo/version.rb +110 -0
- data/lib/pindo.rb +34 -0
- metadata +364 -0
@@ -0,0 +1,489 @@
|
|
1
|
+
|
2
|
+
require 'fileutils'
|
3
|
+
require 'pindo/base/executable'
|
4
|
+
require 'etc'
|
5
|
+
|
6
|
+
module Pindo
|
7
|
+
module Githelper
|
8
|
+
|
9
|
+
extend Executable
|
10
|
+
executable :git
|
11
|
+
|
12
|
+
def prepare_gitenv()
|
13
|
+
|
14
|
+
usrname = Etc.getlogin
|
15
|
+
command = "git config --global user.email #{usrname}@example.com"
|
16
|
+
system command
|
17
|
+
command = "git config --global user.name #{usrname}"
|
18
|
+
system command
|
19
|
+
|
20
|
+
end
|
21
|
+
|
22
|
+
def add_branch(local_repo_dir: nil, branch: nil)
|
23
|
+
|
24
|
+
current=Dir.pwd
|
25
|
+
result = false
|
26
|
+
|
27
|
+
puts local_branch_exists?(local_repo_dir: local_repo_dir, branch: branch)
|
28
|
+
if !local_branch_exists?(local_repo_dir: local_repo_dir, branch: branch)
|
29
|
+
git!(%W(-C #{local_repo_dir} checkout -b #{branch}))
|
30
|
+
result = true
|
31
|
+
end
|
32
|
+
|
33
|
+
git!(%W(-C #{local_repo_dir} push origin #{branch}:#{branch}))
|
34
|
+
|
35
|
+
Dir.chdir(current)
|
36
|
+
return result
|
37
|
+
end
|
38
|
+
|
39
|
+
def remove_branch(local_repo_dir: nil, branch: nil)
|
40
|
+
current=Dir.pwd
|
41
|
+
|
42
|
+
result = false
|
43
|
+
if File.exist?(local_repo_dir)
|
44
|
+
current_branch = git!(%W(-C #{local_repo_dir} rev-parse --abbrev-ref HEAD)).strip
|
45
|
+
if local_branch_exists?(local_repo_dir: local_repo_dir, branch: branch)
|
46
|
+
git!(%W(-C #{local_repo_dir} branch -D #{branch}))
|
47
|
+
result = true
|
48
|
+
end
|
49
|
+
|
50
|
+
if remote_branch_exists?(local_repo_dir: local_repo_dir, branch: branch)
|
51
|
+
git!(%W(-C #{local_repo_dir} push origin :#{branch}))
|
52
|
+
result = true
|
53
|
+
end
|
54
|
+
|
55
|
+
else
|
56
|
+
result = false
|
57
|
+
end
|
58
|
+
Dir.chdir(current)
|
59
|
+
return result
|
60
|
+
end
|
61
|
+
|
62
|
+
|
63
|
+
def local_branch_exists?(local_repo_dir: nil, branch: nil)
|
64
|
+
current=Dir.pwd
|
65
|
+
result = false
|
66
|
+
|
67
|
+
if File.exist?(local_repo_dir)
|
68
|
+
Dir.chdir(local_repo_dir)
|
69
|
+
|
70
|
+
res_data = Executable.capture_command('git', %W(rev-parse --verify #{branch}), :capture => :out)
|
71
|
+
# puts "=====1"
|
72
|
+
# puts res_data
|
73
|
+
# res_data = git!(%W(-C #{local_repo_dir} --no-pager branch --list origin/#{branch} --no-color -r))
|
74
|
+
result = !res_data.nil? && !res_data.empty?
|
75
|
+
else
|
76
|
+
result = false
|
77
|
+
end
|
78
|
+
Dir.chdir(current)
|
79
|
+
return result
|
80
|
+
end
|
81
|
+
|
82
|
+
def remote_branch_exists?(local_repo_dir: nil, branch: nil)
|
83
|
+
current=Dir.pwd
|
84
|
+
result = false
|
85
|
+
if File.exist?(local_repo_dir)
|
86
|
+
Dir.chdir(local_repo_dir)
|
87
|
+
res_data = git!(%W(-C #{local_repo_dir} ls-remote --heads origin refs/heads/#{branch}))
|
88
|
+
result = !res_data.nil? && !res_data.empty?
|
89
|
+
else
|
90
|
+
result = false
|
91
|
+
end
|
92
|
+
Dir.chdir(current)
|
93
|
+
return result
|
94
|
+
end
|
95
|
+
|
96
|
+
|
97
|
+
def add_tag(local_repo_dir: nil, tag_name: nil)
|
98
|
+
|
99
|
+
current=Dir.pwd
|
100
|
+
result = false
|
101
|
+
if File.exist?(local_repo_dir)
|
102
|
+
Dir.chdir(local_repo_dir)
|
103
|
+
if !local_tag_exists?(local_repo_dir: local_repo_dir, tag_name: tag_name)
|
104
|
+
git!(%W(-C #{local_repo_dir} tag #{tag_name}))
|
105
|
+
result = true
|
106
|
+
end
|
107
|
+
git!(%W(-C #{local_repo_dir} push origin #{tag_name}))
|
108
|
+
else
|
109
|
+
result = false
|
110
|
+
end
|
111
|
+
Dir.chdir(current)
|
112
|
+
return result
|
113
|
+
end
|
114
|
+
|
115
|
+
def add_tag_with_check(local_repo_dir:nil, tag_name:nil)
|
116
|
+
|
117
|
+
if remote_tag_exists?(local_repo_dir: local_repo_dir, tag_name: tag_name)
|
118
|
+
puts
|
119
|
+
puts "路径: #{local_repo_dir}"
|
120
|
+
puts "Tag: #{tag_name}"
|
121
|
+
puts
|
122
|
+
puts "仓库已经存在同样tag:#{tag_name} !!!"
|
123
|
+
|
124
|
+
answer = agree("确定删除远程仓库的tag, 重新添加tag:#{tag_name}吗(Y/n)?:")
|
125
|
+
unless answer
|
126
|
+
raise Informative, "添加tag异常!!!"
|
127
|
+
end
|
128
|
+
if local_tag_exists?(local_repo_dir: local_repo_dir, tag_name: tag_name)
|
129
|
+
git!(%W(-C #{local_repo_dir} tag -d #{tag_name}))
|
130
|
+
end
|
131
|
+
git!(%W(-C #{local_repo_dir} push origin :#{tag_name}))
|
132
|
+
add_tag(local_repo_dir:local_repo_dir, tag_name:tag_name)
|
133
|
+
else
|
134
|
+
if local_tag_exists?(local_repo_dir: local_repo_dir, tag_name: tag_name)
|
135
|
+
git!(%W(-C #{local_repo_dir} tag -d #{tag_name}))
|
136
|
+
end
|
137
|
+
add_tag(local_repo_dir:local_repo_dir, tag_name:tag_name)
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
def remove_tag(local_repo_dir: nil, tag_name: nil)
|
142
|
+
|
143
|
+
result = false
|
144
|
+
current=Dir.pwd
|
145
|
+
if File.exist?(local_repo_dir)
|
146
|
+
Dir.chdir(local_repo_dir)
|
147
|
+
if local_tag_exists?(local_repo_dir: local_repo_dir, tag_name: tag_name)
|
148
|
+
git!(%W(-C #{local_repo_dir} tag -d #{tag_name}))
|
149
|
+
result = true
|
150
|
+
end
|
151
|
+
if remote_tag_exists?(local_repo_dir: local_repo_dir, tag_name: tag_name)
|
152
|
+
git!(%W(-C #{local_repo_dir} push origin :#{tag_name}))
|
153
|
+
result = true
|
154
|
+
end
|
155
|
+
else
|
156
|
+
result = false
|
157
|
+
end
|
158
|
+
Dir.chdir(current)
|
159
|
+
return result
|
160
|
+
|
161
|
+
end
|
162
|
+
|
163
|
+
|
164
|
+
def remote_tag_exists?(local_repo_dir: nil, tag_name: nil)
|
165
|
+
|
166
|
+
result = false
|
167
|
+
current=Dir.pwd
|
168
|
+
|
169
|
+
if File.exist?(local_repo_dir)
|
170
|
+
Dir.chdir(local_repo_dir)
|
171
|
+
tag_ref = "refs/tags/#{tag_name}"
|
172
|
+
res_data = git!(%W(-C #{local_repo_dir} ls-remote --tags origin #{tag_ref}))
|
173
|
+
result = !res_data.nil? && !res_data.empty?
|
174
|
+
else
|
175
|
+
result = false
|
176
|
+
end
|
177
|
+
Dir.chdir(current)
|
178
|
+
return result
|
179
|
+
|
180
|
+
|
181
|
+
end
|
182
|
+
|
183
|
+
def local_tag_exists?(local_repo_dir: nil, tag_name: nil)
|
184
|
+
# tag_ref = "refs/tags/#{tag_name}"
|
185
|
+
result = false
|
186
|
+
current=Dir.pwd
|
187
|
+
|
188
|
+
if File.exist? (local_repo_dir)
|
189
|
+
Dir.chdir(local_repo_dir)
|
190
|
+
res_data = git!(%W(-C #{local_repo_dir} tag --list #{tag_name}))
|
191
|
+
result = !res_data.nil? && !res_data.empty?
|
192
|
+
else
|
193
|
+
result = false
|
194
|
+
end
|
195
|
+
Dir.chdir(current)
|
196
|
+
return result
|
197
|
+
end
|
198
|
+
|
199
|
+
def git_latest_commit_id(local_repo_dir:nil)
|
200
|
+
|
201
|
+
current=Dir.pwd
|
202
|
+
commit_id = nil
|
203
|
+
|
204
|
+
if File.exist?(local_repo_dir)
|
205
|
+
Dir.chdir(local_repo_dir)
|
206
|
+
current_branch = git!(%W(-C #{local_repo_dir} rev-parse --abbrev-ref HEAD)).strip
|
207
|
+
# puts "current_branch: #{current_branch}"
|
208
|
+
|
209
|
+
# git log -n 1 --pretty=format:"commit %H"
|
210
|
+
# format_str = "commit %H"
|
211
|
+
# latest_log_info = git!(%W(-C #{current} log -n 1 --pretty=#{format_str} #{current_branch})).strip
|
212
|
+
commit_id = git!(%W(-C #{local_repo_dir} rev-parse #{current_branch})).strip
|
213
|
+
end
|
214
|
+
Dir.chdir(current)
|
215
|
+
|
216
|
+
return commit_id
|
217
|
+
end
|
218
|
+
|
219
|
+
def getcode_to_dir(reponame:nil, remote_url:nil, path: nil, new_branch:"master", new_tag: nil)
|
220
|
+
|
221
|
+
current=Dir.pwd
|
222
|
+
# puts reponame
|
223
|
+
# puts remote_url
|
224
|
+
# puts path
|
225
|
+
|
226
|
+
local_repo_dir = File::join(path, reponame)
|
227
|
+
puts "正在更新仓库: #{local_repo_dir}"
|
228
|
+
if !reponame.empty? && !remote_url.empty? && !path.empty?
|
229
|
+
|
230
|
+
if File.exist?(local_repo_dir)
|
231
|
+
Dir.chdir(local_repo_dir)
|
232
|
+
|
233
|
+
remote_info = git!(%W(remote -v))
|
234
|
+
if remote_info.include?("git.coding.net")
|
235
|
+
current_branch = git!(%W(-C #{local_repo_dir} rev-parse --abbrev-ref HEAD)).strip
|
236
|
+
git!(%W(remote remove origin))
|
237
|
+
git!(%W(remote add origin #{remote_url}))
|
238
|
+
args = %W(-C #{local_repo_dir} fetch origin)
|
239
|
+
args.push('--progress')
|
240
|
+
git!(args)
|
241
|
+
git!(%W(-C #{local_repo_dir} branch --set-upstream-to=origin/#{current_branch} #{current_branch}))
|
242
|
+
end
|
243
|
+
|
244
|
+
git!(%W(-C #{local_repo_dir} fetch origin --progress))
|
245
|
+
else
|
246
|
+
puts "Cloning `#{remote_url}` into `#{local_repo_dir}`."
|
247
|
+
git! ['clone', remote_url, local_repo_dir]
|
248
|
+
end
|
249
|
+
|
250
|
+
Dir.chdir(local_repo_dir)
|
251
|
+
if !remote_branch_exists?(local_repo_dir:local_repo_dir, branch:new_branch)
|
252
|
+
raise Informative, "仓库中的#{new_branch}分支不存在 !!!"
|
253
|
+
end
|
254
|
+
|
255
|
+
current_branch = git!(%W(-C #{local_repo_dir} rev-parse --abbrev-ref HEAD)).strip
|
256
|
+
if current_branch.eql?(new_branch)
|
257
|
+
git!(%W(-C #{local_repo_dir} reset --hard origin/#{new_branch}))
|
258
|
+
git!(%W(-C #{local_repo_dir} branch --set-upstream-to=origin/#{new_branch} #{new_branch}))
|
259
|
+
git!(%W(-C #{local_repo_dir} pull))
|
260
|
+
|
261
|
+
else
|
262
|
+
git!(%W(-C #{local_repo_dir} clean -fd))
|
263
|
+
if local_branch_exists?(local_repo_dir:local_repo_dir, branch:new_branch)
|
264
|
+
git!(%W(-C #{local_repo_dir} checkout #{new_branch}))
|
265
|
+
else
|
266
|
+
git!(%W(-C #{local_repo_dir} checkout -b #{new_branch}))
|
267
|
+
end
|
268
|
+
git!(%W(-C #{local_repo_dir} branch --set-upstream-to=origin/#{new_branch} #{new_branch}))
|
269
|
+
git!(%W(-C #{local_repo_dir} pull))
|
270
|
+
end
|
271
|
+
|
272
|
+
if !new_tag.nil? && new_tag != ""
|
273
|
+
if !new_tag.nil? && new_tag != "" && local_tag_exists?(local_repo_dir:local_repo_dir, tag_name:new_tag)
|
274
|
+
puts "tag : #{new_tag} is exist !!!"
|
275
|
+
git!(%W(-C #{local_repo_dir} checkout #{new_tag}))
|
276
|
+
else
|
277
|
+
raise Informative, "tag #{new_tag} is not exist !!!"
|
278
|
+
end
|
279
|
+
end
|
280
|
+
|
281
|
+
end
|
282
|
+
|
283
|
+
Dir.chdir(current)
|
284
|
+
return local_repo_dir
|
285
|
+
end
|
286
|
+
|
287
|
+
def get_repo_base_name(repo_url:nil)
|
288
|
+
temp_url = String.new(repo_url)
|
289
|
+
index = temp_url.rindex('/')
|
290
|
+
temp_url = temp_url.slice(index + 1, temp_url.length)
|
291
|
+
base_name = temp_url.gsub!(/\.git/, "")
|
292
|
+
return base_name
|
293
|
+
end
|
294
|
+
|
295
|
+
def clong_buildconfig_repo(repo_name:nil)
|
296
|
+
|
297
|
+
pindo_dir = File::expand_path(Pindoconfig.instance.pindo_dir)
|
298
|
+
if !File.exist?(pindo_dir)
|
299
|
+
FileUtils.mkdir(pindo_dir)
|
300
|
+
end
|
301
|
+
|
302
|
+
repo_org_name = Pindoconfig.instance.build_deploy_org
|
303
|
+
|
304
|
+
git_repo_file = File.join(Pindoconfig.instance.pindo_env_configdir, "git_base_url.json")
|
305
|
+
git_repo_json = JSON.parse(File.read(git_repo_file))
|
306
|
+
if repo_name && git_repo_json && git_repo_json[repo_name]
|
307
|
+
repo_org_name = git_repo_json[repo_name]
|
308
|
+
end
|
309
|
+
|
310
|
+
url = File.join("https://gitee.com", repo_org_name, repo_name + ".git")
|
311
|
+
getcode_to_dir(reponame:repo_name, remote_url: url, path:pindo_dir)
|
312
|
+
config_repo_dir = File.join(pindo_dir, repo_name)
|
313
|
+
return config_repo_dir
|
314
|
+
end
|
315
|
+
|
316
|
+
def clone_pindo_common_config_repo(force_delete:false)
|
317
|
+
pindo_dir = File::expand_path(Pindoconfig.instance.pindo_dir)
|
318
|
+
if !File.exist?(pindo_dir)
|
319
|
+
FileUtils.mkdir(pindo_dir)
|
320
|
+
end
|
321
|
+
|
322
|
+
common_config_dir_basename = get_repo_base_name(repo_url:Pindoconfig.instance.pindo_common_config_giturl)
|
323
|
+
config_repo_dir = File.join(pindo_dir, common_config_dir_basename)
|
324
|
+
if force_delete
|
325
|
+
if File.exist?(config_repo_dir)
|
326
|
+
FileUtils.rm_rf(config_repo_dir)
|
327
|
+
end
|
328
|
+
end
|
329
|
+
getcode_to_dir(reponame:common_config_dir_basename, remote_url:Pindoconfig.instance.pindo_common_config_giturl, path:pindo_dir)
|
330
|
+
|
331
|
+
return config_repo_dir
|
332
|
+
end
|
333
|
+
|
334
|
+
def clone_pindo_env_config_repo(force_delete:false)
|
335
|
+
pindo_dir = File::expand_path(Pindoconfig.instance.pindo_dir)
|
336
|
+
if !File.exist?(pindo_dir)
|
337
|
+
FileUtils.mkdir(pindo_dir)
|
338
|
+
end
|
339
|
+
|
340
|
+
env_config_dir_basename = get_repo_base_name(repo_url:Pindoconfig.instance.pindo_env_config_giturl)
|
341
|
+
config_repo_dir = File.join(pindo_dir, env_config_dir_basename)
|
342
|
+
if force_delete
|
343
|
+
if File.exist?(config_repo_dir)
|
344
|
+
FileUtils.rm_rf(config_repo_dir)
|
345
|
+
end
|
346
|
+
end
|
347
|
+
getcode_to_dir(reponame:env_config_dir_basename, remote_url:Pindoconfig.instance.pindo_env_config_giturl, path:pindo_dir)
|
348
|
+
return config_repo_dir
|
349
|
+
end
|
350
|
+
|
351
|
+
def clone_devclang_repo
|
352
|
+
pindo_dir = File::expand_path(Pindoconfig.instance.pindo_dir)
|
353
|
+
if !File.exist?(pindo_dir)
|
354
|
+
FileUtils.mkdir(pindo_dir)
|
355
|
+
end
|
356
|
+
|
357
|
+
getcode_to_dir(reponame:"confuseclang", remote_url:Pindoconfig.instance.dev_clang_giturl, path:pindo_dir)
|
358
|
+
|
359
|
+
config_repo_dir = File.join(pindo_dir, "confuseclang")
|
360
|
+
return config_repo_dir
|
361
|
+
end
|
362
|
+
|
363
|
+
def clone_clang_repo
|
364
|
+
pindo_dir = File::expand_path(Pindoconfig.instance.pindo_dir)
|
365
|
+
if !File.exist?(pindo_dir)
|
366
|
+
FileUtils.mkdir(pindo_dir)
|
367
|
+
end
|
368
|
+
|
369
|
+
getcode_to_dir(reponame:"deployclang", remote_url:Pindoconfig.instance.deploy_clang_giturl, path:pindo_dir)
|
370
|
+
|
371
|
+
config_repo_dir = File.join(pindo_dir, "deployclang")
|
372
|
+
return config_repo_dir
|
373
|
+
end
|
374
|
+
|
375
|
+
def git_addpush_repo(path:nil, message:"res", commit_file_params:nil)
|
376
|
+
current=Dir.pwd
|
377
|
+
Dir.chdir(path)
|
378
|
+
begin
|
379
|
+
if !commit_file_params.nil? && !commit_file_params.empty?
|
380
|
+
files_list = git! ['ls-files', '--other', '--modified', '--exclude-standard'] || []
|
381
|
+
|
382
|
+
need_commit = false
|
383
|
+
commit_file_params.each do |file_name|
|
384
|
+
if !files_list.nil? && files_list.size > 0 && files_list.include?(file_name)
|
385
|
+
need_commit = true
|
386
|
+
git! ['add', file_name]
|
387
|
+
end
|
388
|
+
end
|
389
|
+
if need_commit
|
390
|
+
git! ['commit', '-m ' + "#{message}"]
|
391
|
+
git! ['push']
|
392
|
+
else
|
393
|
+
puts "\n#{path}\n!!!仓库中文件未发生变化,无需提交!!!\n"
|
394
|
+
end
|
395
|
+
else
|
396
|
+
files_list = git! ['ls-files', '--other', '--modified', '--exclude-standard'] || []
|
397
|
+
puts "提交如下内容:"
|
398
|
+
puts files_list
|
399
|
+
if !files_list.nil? && files_list.size > 0
|
400
|
+
git! ['add', '-A']
|
401
|
+
git! ['commit', '-m ' + "#{message}"]
|
402
|
+
git! ['push']
|
403
|
+
else
|
404
|
+
puts "\n#{path}\n!!!仓库中文件未发生变化,无需提交!!!\n"
|
405
|
+
end
|
406
|
+
end
|
407
|
+
|
408
|
+
rescue => error
|
409
|
+
puts(error.to_s)
|
410
|
+
raise Informative, "\n#{path}\n 仓库失败 !!!"
|
411
|
+
end
|
412
|
+
|
413
|
+
|
414
|
+
Dir.chdir(current)
|
415
|
+
end
|
416
|
+
|
417
|
+
|
418
|
+
|
419
|
+
def process_need_add_files(project_dir:nil)
|
420
|
+
|
421
|
+
current_project_dir = project_dir
|
422
|
+
origin_path=Dir.pwd
|
423
|
+
Dir.chdir(current_project_dir)
|
424
|
+
coding_branch = git!(%W(-C #{current_project_dir} rev-parse --abbrev-ref HEAD)).strip
|
425
|
+
git!(%W(-C #{current_project_dir} restore --staged #{current_project_dir}))
|
426
|
+
|
427
|
+
files_list = git!(%W(-C #{current_project_dir} ls-files --other --modified --exclude-standard)) || []
|
428
|
+
if !files_list.nil? && files_list.size > 0
|
429
|
+
|
430
|
+
process_types = ["全部提交", "全部删除", "退出"]
|
431
|
+
puts
|
432
|
+
puts "当前所在分支:#{coding_branch}有下面这些文件没有提交:"
|
433
|
+
puts
|
434
|
+
puts files_list
|
435
|
+
puts
|
436
|
+
|
437
|
+
|
438
|
+
cli = HighLine.new
|
439
|
+
menu_choice="None"
|
440
|
+
cli.choose do |menu| # you can also use constants like :blue
|
441
|
+
menu.header = "对以上未提交的文件, 有下列处理方式"
|
442
|
+
menu.prompt = "请选择如何处理(1/2/3...):"
|
443
|
+
if !process_types.nil? && process_types.length > 0
|
444
|
+
for index_item in process_types do
|
445
|
+
menu.choice(index_item) do |details|
|
446
|
+
# puts index_item
|
447
|
+
menu_choice="#{details}"
|
448
|
+
end
|
449
|
+
end
|
450
|
+
end
|
451
|
+
end
|
452
|
+
|
453
|
+
puts "选择的处理方式为: #{menu_choice}"
|
454
|
+
if menu_choice.eql?("全部提交")
|
455
|
+
message = ask('请输入提交的备注信息: ') || "release code"
|
456
|
+
git! ['add', '-A']
|
457
|
+
git! ['commit', '-m ' + "#{message}"]
|
458
|
+
git!(%W(-C #{current_project_dir} fetch origin))
|
459
|
+
if remote_branch_exists?(local_repo_dir: current_project_dir, branch:coding_branch)
|
460
|
+
git!(%W(-C #{current_project_dir} branch --set-upstream-to=origin/#{coding_branch} #{coding_branch}))
|
461
|
+
git! ['pull']
|
462
|
+
git! ['push']
|
463
|
+
else
|
464
|
+
git!(%W(-C #{current_project_dir} push --set-upstream origin #{coding_branch}))
|
465
|
+
end
|
466
|
+
elsif menu_choice.eql?("全部删除")
|
467
|
+
|
468
|
+
answer = agree("有未提交的文件,确认删除?(Y/n):")
|
469
|
+
unless answer
|
470
|
+
raise Informative, "请手动处理未提交的文件!!!"
|
471
|
+
end
|
472
|
+
git!(%W(-C #{current_project_dir} reset --hard))
|
473
|
+
git!(%W(-C #{current_project_dir} clean -dfx))
|
474
|
+
git!(%W(-C #{current_project_dir} branch --set-upstream-to=origin/#{coding_branch} #{coding_branch}))
|
475
|
+
git!(%W(-C #{current_project_dir} pull))
|
476
|
+
else
|
477
|
+
raise Informative, "请手动处理未提交的文件!!!"
|
478
|
+
end
|
479
|
+
else
|
480
|
+
puts "当前所在分支没有需要提交的文件!!"
|
481
|
+
puts
|
482
|
+
end
|
483
|
+
|
484
|
+
Dir.chdir(origin_path)
|
485
|
+
end
|
486
|
+
|
487
|
+
|
488
|
+
end
|
489
|
+
end
|
@@ -0,0 +1,134 @@
|
|
1
|
+
|
2
|
+
require 'fileutils'
|
3
|
+
require 'json'
|
4
|
+
require 'pindo/base/executable'
|
5
|
+
|
6
|
+
|
7
|
+
module Pindo
|
8
|
+
module Hashhelper
|
9
|
+
|
10
|
+
def deepcopy_hash(des_hash:nil, src_hash:nil)
|
11
|
+
|
12
|
+
des_hash = des_hash || {}
|
13
|
+
if !src_hash.nil? && (src_hash.kind_of? Hash)
|
14
|
+
src_hash.each do |key, value|
|
15
|
+
if !value.nil? && (value.kind_of? Hash)
|
16
|
+
des_hash[key] = {}
|
17
|
+
deepcopy_hash(des_hash:des_hash[key], src_hash:value)
|
18
|
+
elsif !value.nil? && (value.kind_of? Array)
|
19
|
+
des_hash[key] = des_hash[key] || []
|
20
|
+
des_hash[key] = des_hash[key] + value
|
21
|
+
else
|
22
|
+
des_hash[key] = value
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
return des_hash
|
27
|
+
end
|
28
|
+
|
29
|
+
def deepcopy_hash_struct(src_hash:nil, key_value:"")
|
30
|
+
des_hash = des_hash || {}
|
31
|
+
if !src_hash.nil? && (src_hash.kind_of? Hash)
|
32
|
+
src_hash.each do |key, value|
|
33
|
+
if !value.nil? && (value.kind_of? Hash)
|
34
|
+
|
35
|
+
des_hash[key] = deepcopy_hash_struct(src_hash:value, key_value:key_value)
|
36
|
+
elsif !value.nil? && (value.kind_of? Array)
|
37
|
+
des_hash[key] = []
|
38
|
+
else
|
39
|
+
new_value = key_value + key + "__________"
|
40
|
+
des_hash[key] = new_value
|
41
|
+
if key == 'module_git_url' || key == 'module_git_branch' || key == 'module_git_tag'
|
42
|
+
des_hash[key] = ""
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
return des_hash
|
48
|
+
end
|
49
|
+
|
50
|
+
|
51
|
+
def minus_hash(hash1:nil, hash2:nil)
|
52
|
+
minus_hash = {}
|
53
|
+
hash2 = hash2 || {}
|
54
|
+
if !hash1.nil? && (hash1.kind_of? Hash)
|
55
|
+
hash1.each do |key, value1|
|
56
|
+
value2 = hash2[key]
|
57
|
+
if !value1.nil? && (value1.kind_of? Hash)
|
58
|
+
if !value2.nil? && (value2.kind_of? Hash)
|
59
|
+
|
60
|
+
valut_temp = minus_hash(hash1:value1, hash2:value2)
|
61
|
+
if valut_temp.size > 0
|
62
|
+
minus_hash[key] = valut_temp
|
63
|
+
end
|
64
|
+
end
|
65
|
+
elsif !value1.nil? && (value1.kind_of? Array)
|
66
|
+
value1 = value1 || []
|
67
|
+
value2 = value2 || []
|
68
|
+
minus_hash[key] = value1 - value2
|
69
|
+
else
|
70
|
+
|
71
|
+
unless hash2.has_key?(key)
|
72
|
+
minus_hash[key] = hash1[key]
|
73
|
+
end
|
74
|
+
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
return minus_hash
|
79
|
+
end
|
80
|
+
|
81
|
+
def init_hash_value_wihtout_add_key(hash1:nil, hash2:nil)
|
82
|
+
hash2 = hash2 || {}
|
83
|
+
|
84
|
+
if !hash1.nil? && (hash1.kind_of? Hash)
|
85
|
+
hash1.each do |key, value1|
|
86
|
+
value2 = hash2[key]
|
87
|
+
if !value1.nil? && (value1.kind_of? Hash)
|
88
|
+
if hash2.has_key?(key) && (value2.kind_of? Hash)
|
89
|
+
hash1[key] = init_hash_value_wihtout_add_key(hash1:value1, hash2:value2)
|
90
|
+
end
|
91
|
+
elsif !value1.nil? && (value1.kind_of? Array)
|
92
|
+
value1 = value1 || []
|
93
|
+
value2 = value2 || []
|
94
|
+
hash1[key] = value1 | value2
|
95
|
+
else
|
96
|
+
if hash2.has_key?(key)
|
97
|
+
hash1[key] = hash2[key]
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
102
|
+
return hash1
|
103
|
+
end
|
104
|
+
|
105
|
+
def init_hash_value_wihtout_exludekeys(hash1:nil, hash2:nil, exlude_keys:nil)
|
106
|
+
exlude_keys = exlude_keys || []
|
107
|
+
hash2 = hash2 || {}
|
108
|
+
|
109
|
+
if !hash1.nil? && (hash1.kind_of? Hash)
|
110
|
+
hash1.each do |key, value1|
|
111
|
+
value2 = hash2[key]
|
112
|
+
|
113
|
+
if exlude_keys.include?(key)
|
114
|
+
|
115
|
+
elsif (value1.kind_of? Hash)
|
116
|
+
if hash2.has_key?(key) && (value2.kind_of? Hash)
|
117
|
+
hash1[key] = init_hash_value_wihtout_exludekeys(hash1:value1, hash2:value2, exlude_keys:exlude_keys)
|
118
|
+
end
|
119
|
+
elsif (value1.kind_of? Array)
|
120
|
+
value1 = value1 || []
|
121
|
+
value2 = value2 || []
|
122
|
+
hash1[key] = value1 | value2
|
123
|
+
else
|
124
|
+
if hash2.has_key?(key)
|
125
|
+
hash1[key] = hash2[key]
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end
|
129
|
+
end
|
130
|
+
return hash1
|
131
|
+
end
|
132
|
+
|
133
|
+
end
|
134
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Pindo
|
2
|
+
|
3
|
+
require 'claide'
|
4
|
+
require 'pindo/base/standarderror'
|
5
|
+
|
6
|
+
# Indicates a runtime error **not** caused by a bug.
|
7
|
+
#
|
8
|
+
class PlainInformative < StandardError;
|
9
|
+
include CLAide::InformativeError
|
10
|
+
end
|
11
|
+
|
12
|
+
# Indicates a user error.
|
13
|
+
|
14
|
+
end
|
15
|
+
|