3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
# File 'lib/cocoapods-jxedt/git_helper/cache_pucher.rb', line 3
def self.push(output_dir, targets=nil, force_push=false)
require_relative 'git_command'
require_relative 'zip'
repo = Jxedt.config.git_remote_repo
cache_path = Jxedt.config.git_cache_path
branch = Jxedt.config.cache_branch
commander = Jxedt::GitCommand.new(cache_path)
commander.git_fetch(repo, branch)
output_dir = Pathname.new(output_dir)
approve, refuse = [], []
output_dir.children.each do |child|
next unless child.directory?
pod_name = child.basename.to_s
next if targets && targets.is_a?(Array) && !(targets.include?(pod_name))
pod_checksum = child.children.select { |ch| ch.extname == '.checksum' }.first
pod_checksum = pod_checksum.basename.sub_ext('').to_s unless pod_checksum.nil?
next if pod_checksum.nil?
to_dir = Pathname.new(cache_path) + "GeneratedFrameworks" + pod_name
to_dir.mkpath unless to_dir.exist?
zip_file = to_dir + "#{pod_checksum}.zip"
skip = zip_file.exist? && !force_push
next refuse << pod_name if skip
approve << pod_name
Jxedt::ZipUtils.zip(child.to_s, :zip_name => pod_checksum, :to_dir => to_dir)
end
commander.git_commit_and_push(branch) if approve.size > 0
Pod::UI.puts "🎉 组件已缓存成功: #{approve}".yellow if approve.size > 0
Pod::UI.puts "👻 组件缓存失败,存在相同的校验和: #{refuse}".red if refuse.size > 0
end
|