lg_pod_plugin 1.0.3 → 1.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/git/author.rb +14 -0
- data/lib/git/base/factory.rb +101 -0
- data/lib/git/base.rb +670 -0
- data/lib/git/branch.rb +126 -0
- data/lib/git/branches.rb +71 -0
- data/lib/git/config.rb +22 -0
- data/lib/git/diff.rb +155 -0
- data/lib/git/encoding_utils.rb +33 -0
- data/lib/git/escaped_path.rb +77 -0
- data/lib/git/index.rb +5 -0
- data/lib/git/lib.rb +1215 -0
- data/lib/git/log.rb +135 -0
- data/lib/git/object.rb +312 -0
- data/lib/git/path.rb +31 -0
- data/lib/git/remote.rb +36 -0
- data/lib/git/repository.rb +6 -0
- data/lib/git/stash.rb +27 -0
- data/lib/git/stashes.rb +55 -0
- data/lib/git/status.rb +199 -0
- data/lib/git/url.rb +127 -0
- data/lib/git/version.rb +5 -0
- data/lib/git/working_directory.rb +4 -0
- data/lib/git/worktree.rb +38 -0
- data/lib/git/worktrees.rb +47 -0
- data/lib/git.rb +326 -0
- data/lib/lg_pod_plugin/database.rb +104 -104
- data/lib/lg_pod_plugin/downloader.rb +98 -0
- data/lib/lg_pod_plugin/file_path.rb +8 -4
- data/lib/lg_pod_plugin/git_util.rb +188 -80
- data/lib/lg_pod_plugin/install.rb +61 -80
- data/lib/lg_pod_plugin/l_cache.rb +236 -0
- data/lib/lg_pod_plugin/l_util.rb +39 -0
- data/lib/lg_pod_plugin/log.rb +26 -0
- data/lib/lg_pod_plugin/request.rb +140 -0
- data/lib/lg_pod_plugin/string.rb +33 -0
- data/lib/lg_pod_plugin/version.rb +1 -1
- data/lib/lg_pod_plugin.rb +6 -60
- data/lib/rchardet/big5freq.rb +927 -0
- data/lib/rchardet/big5prober.rb +42 -0
- data/lib/rchardet/chardistribution.rb +250 -0
- data/lib/rchardet/charsetgroupprober.rb +110 -0
- data/lib/rchardet/charsetprober.rb +70 -0
- data/lib/rchardet/codingstatemachine.rb +67 -0
- data/lib/rchardet/constants.rb +42 -0
- data/lib/rchardet/escprober.rb +90 -0
- data/lib/rchardet/escsm.rb +245 -0
- data/lib/rchardet/eucjpprober.rb +88 -0
- data/lib/rchardet/euckrfreq.rb +597 -0
- data/lib/rchardet/euckrprober.rb +42 -0
- data/lib/rchardet/euctwfreq.rb +431 -0
- data/lib/rchardet/euctwprober.rb +42 -0
- data/lib/rchardet/gb18030freq.rb +474 -0
- data/lib/rchardet/gb18030prober.rb +42 -0
- data/lib/rchardet/hebrewprober.rb +289 -0
- data/lib/rchardet/jisfreq.rb +571 -0
- data/lib/rchardet/jpcntx.rb +229 -0
- data/lib/rchardet/langbulgarianmodel.rb +229 -0
- data/lib/rchardet/langcyrillicmodel.rb +330 -0
- data/lib/rchardet/langgreekmodel.rb +227 -0
- data/lib/rchardet/langhebrewmodel.rb +202 -0
- data/lib/rchardet/langhungarianmodel.rb +226 -0
- data/lib/rchardet/langthaimodel.rb +201 -0
- data/lib/rchardet/latin1prober.rb +147 -0
- data/lib/rchardet/mbcharsetprober.rb +89 -0
- data/lib/rchardet/mbcsgroupprober.rb +47 -0
- data/lib/rchardet/mbcssm.rb +542 -0
- data/lib/rchardet/sbcharsetprober.rb +122 -0
- data/lib/rchardet/sbcsgroupprober.rb +58 -0
- data/lib/rchardet/sjisprober.rb +88 -0
- data/lib/rchardet/universaldetector.rb +179 -0
- data/lib/rchardet/utf8prober.rb +87 -0
- data/lib/rchardet/version.rb +3 -0
- data/lib/rchardet.rb +67 -0
- data/lib/zip/central_directory.rb +212 -0
- data/lib/zip/compressor.rb +9 -0
- data/lib/zip/constants.rb +115 -0
- data/lib/zip/crypto/decrypted_io.rb +40 -0
- data/lib/zip/crypto/encryption.rb +11 -0
- data/lib/zip/crypto/null_encryption.rb +43 -0
- data/lib/zip/crypto/traditional_encryption.rb +99 -0
- data/lib/zip/decompressor.rb +31 -0
- data/lib/zip/deflater.rb +34 -0
- data/lib/zip/dos_time.rb +53 -0
- data/lib/zip/entry.rb +719 -0
- data/lib/zip/entry_set.rb +88 -0
- data/lib/zip/errors.rb +19 -0
- data/lib/zip/extra_field/generic.rb +44 -0
- data/lib/zip/extra_field/ntfs.rb +94 -0
- data/lib/zip/extra_field/old_unix.rb +46 -0
- data/lib/zip/extra_field/universal_time.rb +77 -0
- data/lib/zip/extra_field/unix.rb +39 -0
- data/lib/zip/extra_field/zip64.rb +70 -0
- data/lib/zip/extra_field/zip64_placeholder.rb +15 -0
- data/lib/zip/extra_field.rb +103 -0
- data/lib/zip/file.rb +468 -0
- data/lib/zip/filesystem.rb +643 -0
- data/lib/zip/inflater.rb +54 -0
- data/lib/zip/input_stream.rb +180 -0
- data/lib/zip/ioextras/abstract_input_stream.rb +122 -0
- data/lib/zip/ioextras/abstract_output_stream.rb +43 -0
- data/lib/zip/ioextras.rb +36 -0
- data/lib/zip/null_compressor.rb +15 -0
- data/lib/zip/null_decompressor.rb +19 -0
- data/lib/zip/null_input_stream.rb +10 -0
- data/lib/zip/output_stream.rb +198 -0
- data/lib/zip/pass_thru_compressor.rb +23 -0
- data/lib/zip/pass_thru_decompressor.rb +31 -0
- data/lib/zip/streamable_directory.rb +15 -0
- data/lib/zip/streamable_stream.rb +52 -0
- data/lib/zip/version.rb +3 -0
- data/lib/zip.rb +72 -0
- metadata +107 -33
- data/lib/lg_pod_plugin/cache.rb +0 -226
- data/lib/lg_pod_plugin/download.rb +0 -140
- data/lib/lg_pod_plugin/pod_spec.rb +0 -66
@@ -0,0 +1,236 @@
|
|
1
|
+
require 'git'
|
2
|
+
require 'cocoapods/downloader'
|
3
|
+
require 'cocoapods/downloader/cache'
|
4
|
+
require 'cocoapods/downloader/response'
|
5
|
+
require 'cocoapods/downloader/request'
|
6
|
+
|
7
|
+
module LgPodPlugin
|
8
|
+
|
9
|
+
class LCachePodInfo
|
10
|
+
REQUIRED_ATTRS ||= %i[sha tag name path branch timestamp].freeze
|
11
|
+
attr_accessor(*REQUIRED_ATTRS)
|
12
|
+
|
13
|
+
def initialize
|
14
|
+
super
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
|
19
|
+
class LCache
|
20
|
+
REQUIRED_ATTRS ||= %i[workspace cache_root].freeze
|
21
|
+
attr_accessor(*REQUIRED_ATTRS)
|
22
|
+
|
23
|
+
def initialize(workspace)
|
24
|
+
self.workspace = workspace
|
25
|
+
self.cache_root = LFileManager.cache_workspace(self.workspace)
|
26
|
+
end
|
27
|
+
|
28
|
+
#根据git branch commit 返回请求参数用来获取缓存 path
|
29
|
+
def get_request_params(git, branch, tag, commit)
|
30
|
+
options = { :git => git }
|
31
|
+
if git && tag
|
32
|
+
options[:tag] = tag
|
33
|
+
options[:commit] = commit
|
34
|
+
elsif git && branch
|
35
|
+
if commit
|
36
|
+
options[:commit] = commit
|
37
|
+
else
|
38
|
+
new_commit_id = LGitUtil.git_ls_remote_refs(git, branch, nil, commit)
|
39
|
+
options[:commit] = new_commit_id
|
40
|
+
end
|
41
|
+
elsif git && commit
|
42
|
+
options[:commit] = commit
|
43
|
+
end
|
44
|
+
options
|
45
|
+
end
|
46
|
+
#判断缓存是否存在且有效命中缓存
|
47
|
+
def find_pod_cache(name, git, branch, tag, commit, is_update)
|
48
|
+
if is_update
|
49
|
+
hash_map = self.get_request_params(git, branch, tag, commit)
|
50
|
+
else
|
51
|
+
if LRequest.shared.lock_params
|
52
|
+
lock_tag = LRequest.shared.lock_params[:tag]
|
53
|
+
lock_branch = LRequest.shared.lock_params[:branch]
|
54
|
+
lock_commit = LRequest.shared.lock_params[:commit]
|
55
|
+
hash_map = self.get_request_params(git, lock_branch, lock_tag, lock_commit)
|
56
|
+
else
|
57
|
+
hash_map = self.get_request_params(git, branch, tag, commit)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
request = LCache.download_request(name, hash_map)
|
61
|
+
destination = LCache.path_for_pod(request, {})
|
62
|
+
cache_pod_spec = LCache.path_for_spec(request, {})
|
63
|
+
if File.exist?(destination) && File.exist?(cache_pod_spec)
|
64
|
+
false
|
65
|
+
else
|
66
|
+
true
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
def self.root_path
|
71
|
+
path = File.join(Dir.home, "Library/Caches/CocoaPods/Pods")
|
72
|
+
Pathname(path)
|
73
|
+
end
|
74
|
+
|
75
|
+
def self.download_request(name, params)
|
76
|
+
Pod::Downloader::Request.new(spec: nil, released: false, name: name, params: params)
|
77
|
+
end
|
78
|
+
|
79
|
+
def self.path_for_pod(request, slug_opts = {})
|
80
|
+
root = self.root_path
|
81
|
+
root + request.slug(**slug_opts)
|
82
|
+
end
|
83
|
+
|
84
|
+
def self.path_for_spec(request, slug_opts = {})
|
85
|
+
root = self.root_path
|
86
|
+
path = root + 'Specs' + request.slug(**slug_opts)
|
87
|
+
Pathname.new(path.to_path + '.podspec.json')
|
88
|
+
end
|
89
|
+
|
90
|
+
def self.cached_spec(request)
|
91
|
+
path = path_for_spec(request)
|
92
|
+
path.file? && Specification.from_file(path)
|
93
|
+
rescue JSON::ParserError
|
94
|
+
nil
|
95
|
+
end
|
96
|
+
|
97
|
+
def self.get_local_spec(request, target)
|
98
|
+
result = Pod::Downloader::Response.new
|
99
|
+
result.location = target
|
100
|
+
if request.released_pod?
|
101
|
+
result.spec = request.spec
|
102
|
+
local_specs = { request.name => request.spec }
|
103
|
+
return [request, local_specs]
|
104
|
+
else
|
105
|
+
local_specs = {}
|
106
|
+
pods_pecs = Pod::Sandbox::PodspecFinder.new(target).podspecs
|
107
|
+
pods_pecs[request.name] = request.spec if request.spec
|
108
|
+
pods_pecs.each do |name, spec|
|
109
|
+
if request.name == name
|
110
|
+
result.spec = spec
|
111
|
+
local_specs[request.name] = spec
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
[result, local_specs]
|
117
|
+
end
|
118
|
+
|
119
|
+
def self.group_sub_specs_by_platform(spec)
|
120
|
+
specs_by_platform = {}
|
121
|
+
[spec, *spec.recursive_subspecs].each do |ss|
|
122
|
+
ss.available_platforms.each do |platform|
|
123
|
+
specs_by_platform[platform] ||= []
|
124
|
+
specs_by_platform[platform] << ss
|
125
|
+
end
|
126
|
+
end
|
127
|
+
specs_by_platform
|
128
|
+
end
|
129
|
+
|
130
|
+
def self.copy_and_clean(source, destination, spec)
|
131
|
+
specs_by_platform = group_sub_specs_by_platform(spec)
|
132
|
+
destination.parent.mkpath
|
133
|
+
self.write_lock(destination) do
|
134
|
+
FileUtils.rm_rf(destination)
|
135
|
+
FileUtils.cp_r(source, destination)
|
136
|
+
Pod::Installer::PodSourcePreparer.new(spec, destination).prepare!
|
137
|
+
Pod::Sandbox::PodDirCleaner.new(destination, specs_by_platform).clean!
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
def self.write_lock(location, &block)
|
142
|
+
self.lock(location, File::LOCK_EX, &block)
|
143
|
+
end
|
144
|
+
|
145
|
+
def self.lock(location, lock_type)
|
146
|
+
raise ArgumentError, 'no block given' unless block_given?
|
147
|
+
lockfile = "#{location}.lock"
|
148
|
+
f = nil
|
149
|
+
loop do
|
150
|
+
f.close if f
|
151
|
+
f = File.open(lockfile, File::CREAT, 0o644)
|
152
|
+
f.flock(lock_type)
|
153
|
+
break if self.valid_lock?(f, lockfile)
|
154
|
+
end
|
155
|
+
begin
|
156
|
+
yield location
|
157
|
+
ensure
|
158
|
+
if lock_type == File::LOCK_SH
|
159
|
+
f.flock(File::LOCK_EX)
|
160
|
+
File.delete(lockfile) if self.valid_lock?(f, lockfile)
|
161
|
+
else
|
162
|
+
File.delete(lockfile)
|
163
|
+
end
|
164
|
+
f.close
|
165
|
+
end
|
166
|
+
end
|
167
|
+
|
168
|
+
def self.valid_lock?(file, filename)
|
169
|
+
file.stat.ino == File.stat(filename).ino
|
170
|
+
rescue Errno::ENOENT
|
171
|
+
false
|
172
|
+
end
|
173
|
+
|
174
|
+
def self.write_spec(spec, path)
|
175
|
+
path.dirname.mkpath
|
176
|
+
Pod::Downloader::Cache.write_lock(path) do
|
177
|
+
path.open('w') { |f| f.write spec.to_pretty_json }
|
178
|
+
end
|
179
|
+
end
|
180
|
+
|
181
|
+
# 拷贝 pod 缓存文件到 sandbox
|
182
|
+
def self.cache_pod(name, target, options = {})
|
183
|
+
request = LCache.download_request(name, options)
|
184
|
+
result, pods_pecs = get_local_spec(request, target)
|
185
|
+
result.location = nil
|
186
|
+
pods_pecs.each do |s_name, s_spec|
|
187
|
+
destination = path_for_pod(request, {})
|
188
|
+
unless File.exist?(destination)
|
189
|
+
LgPodPlugin.log_green "Copying #{name} from `#{target}` to `#{destination}` "
|
190
|
+
copy_and_clean(target, destination, s_spec)
|
191
|
+
end
|
192
|
+
cache_pod_spec = path_for_spec(request, {})
|
193
|
+
unless File.exist?(cache_pod_spec)
|
194
|
+
write_spec(s_spec, cache_pod_spec)
|
195
|
+
end
|
196
|
+
if request.name == s_name
|
197
|
+
result.location = destination
|
198
|
+
end
|
199
|
+
|
200
|
+
end
|
201
|
+
|
202
|
+
end
|
203
|
+
|
204
|
+
# 根据下载参数生产缓存的路径
|
205
|
+
def get_download_path(name)
|
206
|
+
# hash_map = {:git => git}
|
207
|
+
# if git && tag
|
208
|
+
# hash_map[:tag] = tag
|
209
|
+
# elsif git && commit
|
210
|
+
# hash_map[:commit] = commit
|
211
|
+
# elsif git && branch
|
212
|
+
# hash_map[:commit] = commit
|
213
|
+
# end
|
214
|
+
# request = LCache.download_request(name, hash_map)
|
215
|
+
# self.slug(name, request.params, nil)
|
216
|
+
self.cache_root.join(name)
|
217
|
+
end
|
218
|
+
|
219
|
+
# 根据下载参数生产缓存目录
|
220
|
+
def slug(params, spec)
|
221
|
+
path = ""
|
222
|
+
checksum = spec&.checksum && '-' << spec.checksum[0, 5]
|
223
|
+
opts = params.to_a.sort_by(&:first).map { |k, v| "#{k}=#{v}" }.join('-')
|
224
|
+
digest = Digest::MD5.hexdigest(opts)
|
225
|
+
if digest
|
226
|
+
path += "#{digest}"
|
227
|
+
end
|
228
|
+
if checksum
|
229
|
+
path += "#{checksum}"
|
230
|
+
end
|
231
|
+
path
|
232
|
+
end
|
233
|
+
|
234
|
+
end
|
235
|
+
|
236
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'zip'
|
2
|
+
module LgPodPlugin
|
3
|
+
class LUtils
|
4
|
+
def self.unzip_file (zip_file, dest_dir)
|
5
|
+
begin
|
6
|
+
Zip::File.open(zip_file) do |file|
|
7
|
+
file.each do |f|
|
8
|
+
file_path = File.join(dest_dir, f.name)
|
9
|
+
FileUtils.mkdir_p(File.dirname(file_path))
|
10
|
+
next if file_path.include?("Example")
|
11
|
+
# next if file_path.include?("LICENSE")
|
12
|
+
next if file_path.include?(".gitignore")
|
13
|
+
next if file_path.include?("node_modules")
|
14
|
+
next if file_path.include?("package.json")
|
15
|
+
next if file_path.include?(".swiftlint.yml")
|
16
|
+
next if file_path.include?("_Pods.xcodeproj")
|
17
|
+
next if file_path.include?("package-lock.json")
|
18
|
+
file.extract(f, file_path)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
return true
|
22
|
+
rescue => err
|
23
|
+
puts err
|
24
|
+
return false
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.aes_decrypt(key, data)
|
30
|
+
de_cipher = OpenSSL::Cipher::Cipher.new("AES-128-CBC")
|
31
|
+
de_cipher.decrypt
|
32
|
+
de_cipher.key = [key].pack('H*')
|
33
|
+
# de_cipher.iv = [iv].pack('H*');
|
34
|
+
puts de_cipher.update([data].pack('H*')) << de_cipher.final
|
35
|
+
end
|
36
|
+
|
37
|
+
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
|
2
|
+
require_relative 'string'
|
3
|
+
require 'cocoapods/user_interface'
|
4
|
+
|
5
|
+
module LgPodPlugin
|
6
|
+
|
7
|
+
def self.log_red(msg)
|
8
|
+
Pod::CoreUI.puts msg.red
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.log_blue(msg)
|
12
|
+
Pod::CoreUI.puts msg.blue
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.log_green(msg)
|
16
|
+
Pod::CoreUI.puts msg.green
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.log_yellow(msg)
|
20
|
+
Pod::CoreUI.puts msg.yellow
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.log(msg)
|
24
|
+
Pod::CoreUI.puts msg
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,140 @@
|
|
1
|
+
require 'singleton'
|
2
|
+
require 'yaml'
|
3
|
+
require_relative 'l_cache'
|
4
|
+
require_relative 'git_util'
|
5
|
+
require_relative 'downloader.rb'
|
6
|
+
module LgPodPlugin
|
7
|
+
|
8
|
+
class LRequest
|
9
|
+
include Singleton
|
10
|
+
REQUIRED_ATTRS ||= %i[name options workspace cache downloader git_util lock_info lock_params is_update].freeze
|
11
|
+
attr_accessor(*REQUIRED_ATTRS)
|
12
|
+
|
13
|
+
def is_update_pod
|
14
|
+
cgi = CGI.new
|
15
|
+
command_keys = cgi.keys
|
16
|
+
unless command_keys.count > 0
|
17
|
+
return false
|
18
|
+
end
|
19
|
+
first_key = command_keys[0].to_s ||= ""
|
20
|
+
if first_key.include?("install")
|
21
|
+
false
|
22
|
+
elsif first_key.include?("update")
|
23
|
+
true
|
24
|
+
else
|
25
|
+
false
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def get_lock_info
|
30
|
+
lock_file = self.workspace.join("Podfile.lock")
|
31
|
+
if lock_file.exist?
|
32
|
+
json = YAML.load_file(lock_file.to_path)
|
33
|
+
json["EXTERNAL SOURCES"]
|
34
|
+
else
|
35
|
+
nil
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def get_lock_params(git, branch, tag, commit)
|
40
|
+
unless self.lock_info
|
41
|
+
return nil
|
42
|
+
end
|
43
|
+
current_pod_info = self.lock_info[name]
|
44
|
+
unless current_pod_info
|
45
|
+
return nil
|
46
|
+
end
|
47
|
+
lock_commit = current_pod_info[:commit]
|
48
|
+
if git && tag
|
49
|
+
lock_tag = current_pod_info[:tag]
|
50
|
+
if lock_tag == tag
|
51
|
+
return { :git => git, :commit => lock_commit, :tag => lock_tag }
|
52
|
+
else
|
53
|
+
return nil
|
54
|
+
end
|
55
|
+
elsif git && branch
|
56
|
+
lock_branch = current_pod_info[:branch]
|
57
|
+
if branch == lock_branch
|
58
|
+
return { :git => git, :commit => lock_commit, :branch => lock_branch}
|
59
|
+
else
|
60
|
+
return nil
|
61
|
+
end
|
62
|
+
elsif commit == lock_commit
|
63
|
+
return { :git => git, :commit => lock_commit }
|
64
|
+
else
|
65
|
+
nil
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
def setup_pod_info(name, workspace, options = {})
|
70
|
+
self.name = name
|
71
|
+
hash_map = options
|
72
|
+
tag = hash_map[:tag]
|
73
|
+
git = hash_map[:git]
|
74
|
+
path = hash_map[:path]
|
75
|
+
commit = hash_map[:commit]
|
76
|
+
branch = hash_map[:branch]
|
77
|
+
self.workspace = workspace
|
78
|
+
self.is_update = self.is_update_pod
|
79
|
+
if self.lock_info == nil
|
80
|
+
self.lock_info = self.get_lock_info
|
81
|
+
end
|
82
|
+
self.lock_params = self.get_lock_params(git, branch, tag, commit)
|
83
|
+
if git && tag
|
84
|
+
if self.lock_params && !self.is_update
|
85
|
+
lock_tag = self.lock_params[:tag]
|
86
|
+
lock_commit = self.lock_params[:commit]
|
87
|
+
if lock_tag == tag && lock_commit
|
88
|
+
hash_map[:commit] = lock_commit
|
89
|
+
else
|
90
|
+
_, new_commit = LGitUtil.git_ls_remote_refs(git, branch, tag, commit)
|
91
|
+
hash_map[:commit] = new_commit
|
92
|
+
end
|
93
|
+
else
|
94
|
+
_, new_commit = LGitUtil.git_ls_remote_refs(git, branch, tag,commit)
|
95
|
+
hash_map[:commit] = new_commit
|
96
|
+
end
|
97
|
+
elsif git && commit
|
98
|
+
if self.lock_params && !self.is_update
|
99
|
+
hash_map[:commit] = commit
|
100
|
+
else
|
101
|
+
new_branch, new_commit = LGitUtil.git_ls_remote_refs(git, branch, tag, commit)
|
102
|
+
if new_commit
|
103
|
+
hash_map[:commit] = new_commit
|
104
|
+
end
|
105
|
+
if new_branch
|
106
|
+
hash_map[:branch] = new_branch
|
107
|
+
end
|
108
|
+
end
|
109
|
+
elsif git && branch
|
110
|
+
if self.lock_params && !self.is_update
|
111
|
+
lock_branch = self.lock_params[:branch]
|
112
|
+
lock_commit = self.lock_params[:commit]
|
113
|
+
if branch == lock_branch && lock_commit
|
114
|
+
hash_map[:commit] = lock_commit
|
115
|
+
else
|
116
|
+
_, new_commit = LGitUtil.git_ls_remote_refs(git, branch, tag, commit)
|
117
|
+
hash_map[:commit] = new_commit
|
118
|
+
end
|
119
|
+
else
|
120
|
+
_, new_commit = LGitUtil.git_ls_remote_refs(git, branch, tag, commit)
|
121
|
+
hash_map[:commit] = new_commit
|
122
|
+
end
|
123
|
+
elsif !path
|
124
|
+
new_branch, new_commit = LGitUtil.git_ls_remote_refs(git, branch, tag, commit)
|
125
|
+
hash_map[:commit] = new_commit
|
126
|
+
hash_map[:branch] = new_branch
|
127
|
+
end
|
128
|
+
self.options = hash_map
|
129
|
+
self.cache = LCache.new(self.workspace)
|
130
|
+
self.git_util = LGitUtil.new(name, hash_map)
|
131
|
+
self.downloader = LDownloader.new(name, hash_map)
|
132
|
+
end
|
133
|
+
|
134
|
+
def self.shared
|
135
|
+
return LRequest.instance
|
136
|
+
end
|
137
|
+
|
138
|
+
end
|
139
|
+
|
140
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module LgPodPlugin
|
2
|
+
|
3
|
+
class String
|
4
|
+
# colorization
|
5
|
+
def colorize(color_code)
|
6
|
+
"\e[#{color_code}m#{self}\e[0m"
|
7
|
+
end
|
8
|
+
|
9
|
+
def red
|
10
|
+
colorize(31)
|
11
|
+
end
|
12
|
+
|
13
|
+
def green
|
14
|
+
colorize(32)
|
15
|
+
end
|
16
|
+
|
17
|
+
def yellow
|
18
|
+
colorize(33)
|
19
|
+
end
|
20
|
+
|
21
|
+
def blue
|
22
|
+
colorize(34)
|
23
|
+
end
|
24
|
+
|
25
|
+
def pink
|
26
|
+
colorize(35)
|
27
|
+
end
|
28
|
+
|
29
|
+
def light_blue
|
30
|
+
colorize(36)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
data/lib/lg_pod_plugin.rb
CHANGED
@@ -1,75 +1,21 @@
|
|
1
1
|
require 'git'
|
2
|
-
require '
|
2
|
+
require 'cocoapods-downloader'
|
3
|
+
require 'cocoapods-core/podfile/target_definition'
|
3
4
|
require "lg_pod_plugin/version"
|
4
|
-
|
5
|
+
require_relative 'lg_pod_plugin/log'
|
6
|
+
require_relative 'lg_pod_plugin/install'
|
7
|
+
require_relative 'lg_pod_plugin/request'
|
5
8
|
require_relative 'lg_pod_plugin/database'
|
6
|
-
require_relative 'lg_pod_plugin/
|
9
|
+
require_relative 'lg_pod_plugin/downloader.rb'
|
7
10
|
require_relative 'lg_pod_plugin/git_util'
|
8
|
-
require_relative 'lg_pod_plugin/pod_spec'
|
9
|
-
require_relative 'lg_pod_plugin/install'
|
10
|
-
require 'cocoapods-core/podfile/target_definition'
|
11
11
|
|
12
12
|
module LgPodPlugin
|
13
13
|
|
14
|
-
class String
|
15
|
-
# colorization
|
16
|
-
def colorize(color_code)
|
17
|
-
"\e[#{color_code}m#{self}\e[0m"
|
18
|
-
end
|
19
|
-
|
20
|
-
def red
|
21
|
-
colorize(31)
|
22
|
-
end
|
23
|
-
|
24
|
-
def green
|
25
|
-
colorize(32)
|
26
|
-
end
|
27
|
-
|
28
|
-
def yellow
|
29
|
-
colorize(33)
|
30
|
-
end
|
31
|
-
|
32
|
-
def blue
|
33
|
-
colorize(34)
|
34
|
-
end
|
35
|
-
|
36
|
-
def pink
|
37
|
-
colorize(35)
|
38
|
-
end
|
39
|
-
|
40
|
-
def light_blue
|
41
|
-
colorize(36)
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
14
|
class Error < StandardError; end
|
46
15
|
|
47
|
-
def self.log_red(msg)
|
48
|
-
Pod::CoreUI.puts msg.red
|
49
|
-
end
|
50
|
-
|
51
|
-
def self.log_blue(msg)
|
52
|
-
Pod::CoreUI.puts msg.blue
|
53
|
-
end
|
54
|
-
|
55
|
-
def self.log_green(msg)
|
56
|
-
Pod::CoreUI.puts msg.green
|
57
|
-
end
|
58
|
-
|
59
|
-
def self.log_yellow(msg)
|
60
|
-
Pod::CoreUI.puts msg.yellow
|
61
|
-
end
|
62
|
-
|
63
|
-
def self.log(msg)
|
64
|
-
Pod::CoreUI.puts msg
|
65
|
-
end
|
66
|
-
|
67
16
|
public
|
68
17
|
# 对 Profile 方法进行拓展
|
69
18
|
def pod(name, *requirements)
|
70
19
|
Installer.new(self, name, requirements)
|
71
20
|
end
|
72
|
-
|
73
|
-
|
74
21
|
end
|
75
|
-
|