lg_pod_plugin 1.0.8 → 1.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/bin/lg +5 -0
- data/lib/command/cache.rb +22 -18
- data/lib/command/command.rb +27 -35
- data/lib/command/install.rb +52 -0
- data/lib/command/update.rb +39 -0
- data/lib/lg_pod_plugin/downloader.rb +12 -17
- data/lib/lg_pod_plugin/git_util.rb +150 -106
- data/lib/lg_pod_plugin/install.rb +74 -88
- data/lib/lg_pod_plugin/l_cache.rb +11 -77
- data/lib/lg_pod_plugin/l_util.rb +6 -2
- data/lib/lg_pod_plugin/request.rb +90 -82
- data/lib/lg_pod_plugin/version.rb +1 -1
- data/lib/lg_pod_plugin.rb +9 -5
- metadata +57 -118
- data/lib/git/author.rb +0 -14
- data/lib/git/base/factory.rb +0 -101
- data/lib/git/base.rb +0 -670
- data/lib/git/branch.rb +0 -126
- data/lib/git/branches.rb +0 -71
- data/lib/git/config.rb +0 -22
- data/lib/git/diff.rb +0 -155
- data/lib/git/encoding_utils.rb +0 -33
- data/lib/git/escaped_path.rb +0 -77
- data/lib/git/index.rb +0 -5
- data/lib/git/lib.rb +0 -1215
- data/lib/git/log.rb +0 -135
- data/lib/git/object.rb +0 -312
- data/lib/git/path.rb +0 -31
- data/lib/git/remote.rb +0 -36
- data/lib/git/repository.rb +0 -6
- data/lib/git/stash.rb +0 -27
- data/lib/git/stashes.rb +0 -55
- data/lib/git/status.rb +0 -199
- data/lib/git/url.rb +0 -127
- data/lib/git/version.rb +0 -5
- data/lib/git/working_directory.rb +0 -4
- data/lib/git/worktree.rb +0 -38
- data/lib/git/worktrees.rb +0 -47
- data/lib/git.rb +0 -326
- data/lib/rchardet/big5freq.rb +0 -927
- data/lib/rchardet/big5prober.rb +0 -42
- data/lib/rchardet/chardistribution.rb +0 -250
- data/lib/rchardet/charsetgroupprober.rb +0 -110
- data/lib/rchardet/charsetprober.rb +0 -70
- data/lib/rchardet/codingstatemachine.rb +0 -67
- data/lib/rchardet/constants.rb +0 -42
- data/lib/rchardet/escprober.rb +0 -90
- data/lib/rchardet/escsm.rb +0 -245
- data/lib/rchardet/eucjpprober.rb +0 -88
- data/lib/rchardet/euckrfreq.rb +0 -597
- data/lib/rchardet/euckrprober.rb +0 -42
- data/lib/rchardet/euctwfreq.rb +0 -431
- data/lib/rchardet/euctwprober.rb +0 -42
- data/lib/rchardet/gb18030freq.rb +0 -474
- data/lib/rchardet/gb18030prober.rb +0 -42
- data/lib/rchardet/hebrewprober.rb +0 -289
- data/lib/rchardet/jisfreq.rb +0 -571
- data/lib/rchardet/jpcntx.rb +0 -229
- data/lib/rchardet/langbulgarianmodel.rb +0 -229
- data/lib/rchardet/langcyrillicmodel.rb +0 -330
- data/lib/rchardet/langgreekmodel.rb +0 -227
- data/lib/rchardet/langhebrewmodel.rb +0 -202
- data/lib/rchardet/langhungarianmodel.rb +0 -226
- data/lib/rchardet/langthaimodel.rb +0 -201
- data/lib/rchardet/latin1prober.rb +0 -147
- data/lib/rchardet/mbcharsetprober.rb +0 -89
- data/lib/rchardet/mbcsgroupprober.rb +0 -47
- data/lib/rchardet/mbcssm.rb +0 -542
- data/lib/rchardet/sbcharsetprober.rb +0 -122
- data/lib/rchardet/sbcsgroupprober.rb +0 -58
- data/lib/rchardet/sjisprober.rb +0 -88
- data/lib/rchardet/universaldetector.rb +0 -179
- data/lib/rchardet/utf8prober.rb +0 -87
- data/lib/rchardet/version.rb +0 -3
- data/lib/rchardet.rb +0 -67
- data/lib/zip/central_directory.rb +0 -212
- data/lib/zip/compressor.rb +0 -9
- data/lib/zip/constants.rb +0 -115
- data/lib/zip/crypto/decrypted_io.rb +0 -40
- data/lib/zip/crypto/encryption.rb +0 -11
- data/lib/zip/crypto/null_encryption.rb +0 -43
- data/lib/zip/crypto/traditional_encryption.rb +0 -99
- data/lib/zip/decompressor.rb +0 -31
- data/lib/zip/deflater.rb +0 -34
- data/lib/zip/dos_time.rb +0 -53
- data/lib/zip/entry.rb +0 -719
- data/lib/zip/entry_set.rb +0 -88
- data/lib/zip/errors.rb +0 -19
- data/lib/zip/extra_field/generic.rb +0 -44
- data/lib/zip/extra_field/ntfs.rb +0 -94
- data/lib/zip/extra_field/old_unix.rb +0 -46
- data/lib/zip/extra_field/universal_time.rb +0 -77
- data/lib/zip/extra_field/unix.rb +0 -39
- data/lib/zip/extra_field/zip64.rb +0 -70
- data/lib/zip/extra_field/zip64_placeholder.rb +0 -15
- data/lib/zip/extra_field.rb +0 -103
- data/lib/zip/file.rb +0 -468
- data/lib/zip/filesystem.rb +0 -643
- data/lib/zip/inflater.rb +0 -54
- data/lib/zip/input_stream.rb +0 -180
- data/lib/zip/ioextras/abstract_input_stream.rb +0 -122
- data/lib/zip/ioextras/abstract_output_stream.rb +0 -43
- data/lib/zip/ioextras.rb +0 -36
- data/lib/zip/null_compressor.rb +0 -15
- data/lib/zip/null_decompressor.rb +0 -19
- data/lib/zip/null_input_stream.rb +0 -10
- data/lib/zip/output_stream.rb +0 -198
- data/lib/zip/pass_thru_compressor.rb +0 -23
- data/lib/zip/pass_thru_decompressor.rb +0 -31
- data/lib/zip/streamable_directory.rb +0 -15
- data/lib/zip/streamable_stream.rb +0 -52
- data/lib/zip/version.rb +0 -3
- data/lib/zip.rb +0 -72
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: bfad1a89dbfca4907d2188cea319433a1d7e7bb9d067b63ed93cd71c285bf4d5
|
|
4
|
+
data.tar.gz: 90d653002dee76968ade7d6c43aede5fb0552280a9d210fdcb9423f1495574bc
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 444b1a2f4951337b0c552f74651b2ef8ad2278425733b70023bbdfad30da156fbbbba8efb703aca3ffaa0f6cb21cca16ed2b6ffbd54634e84a33cea314b05f09
|
|
7
|
+
data.tar.gz: c92fb25a5e438f6b6583122629328ab4019d1189d724026dfcd6fe5ddfca1b285a323efd612b0aea193223583f32ab969198ede1dd37e10d04b794b918751852
|
data/bin/lg
ADDED
data/lib/command/cache.rb
CHANGED
|
@@ -1,18 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
#
|
|
17
|
-
|
|
18
|
-
|
|
1
|
+
require 'claide'
|
|
2
|
+
require_relative 'command'
|
|
3
|
+
|
|
4
|
+
module LgPodPlugin
|
|
5
|
+
class Command
|
|
6
|
+
class Cache < Command
|
|
7
|
+
self.abstract_command = true
|
|
8
|
+
self.summary = 'Manipulate the CocoaPods cache'
|
|
9
|
+
|
|
10
|
+
self.description = <<-DESC
|
|
11
|
+
Manipulate the download cache for pods, like printing the cache content
|
|
12
|
+
or cleaning the pods cache.
|
|
13
|
+
DESC
|
|
14
|
+
|
|
15
|
+
def initialize(argv)
|
|
16
|
+
# pp argv
|
|
17
|
+
super
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
data/lib/command/command.rb
CHANGED
|
@@ -1,35 +1,27 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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
|
-
# # config.verbose = self.verbose? unless verbose.nil?
|
|
29
|
-
# unless self.ansi_output?
|
|
30
|
-
# Colored2.disable!
|
|
31
|
-
# String.send(:define_method, :colorize) { |string, _| string }
|
|
32
|
-
# end
|
|
33
|
-
# end
|
|
34
|
-
# end
|
|
35
|
-
# end
|
|
1
|
+
require 'claide'
|
|
2
|
+
|
|
3
|
+
module LgPodPlugin
|
|
4
|
+
class Command < CLAide::Command
|
|
5
|
+
require_relative 'cache'
|
|
6
|
+
require_relative 'update'
|
|
7
|
+
require_relative 'install'
|
|
8
|
+
self.command = 'lg'
|
|
9
|
+
self.version = VERSION
|
|
10
|
+
self.abstract_command = true
|
|
11
|
+
self.description = 'this is `lg_pod_plugin` command line tool!'
|
|
12
|
+
def self.options
|
|
13
|
+
[
|
|
14
|
+
['--silent', 'Show nothing']
|
|
15
|
+
].concat(super)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def self.run(argv)
|
|
19
|
+
super(argv)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def initialize(argv)
|
|
23
|
+
super
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
end
|
|
27
|
+
end
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
require 'claide'
|
|
2
|
+
|
|
3
|
+
module LgPodPlugin
|
|
4
|
+
class Command
|
|
5
|
+
class Install < Command
|
|
6
|
+
REQUIRED_ATTRS ||= %i[log repo_update].freeze
|
|
7
|
+
attr_accessor(*REQUIRED_ATTRS)
|
|
8
|
+
|
|
9
|
+
self.summary = 'Install project dependencies according to versions from a Podfile.lock'
|
|
10
|
+
|
|
11
|
+
self.description = <<-DESC
|
|
12
|
+
Downloads all dependencies defined in `Podfile` and creates an Xcode
|
|
13
|
+
Pods library project in `./Pods`.
|
|
14
|
+
|
|
15
|
+
The Xcode project file should be specified in your `Podfile` like this:
|
|
16
|
+
|
|
17
|
+
project 'path/to/XcodeProject.xcodeproj'
|
|
18
|
+
|
|
19
|
+
If no project is specified, then a search for an Xcode project will
|
|
20
|
+
be made. If more than one Xcode project is found, the command will
|
|
21
|
+
raise an error.
|
|
22
|
+
|
|
23
|
+
This will configure the project to reference the Pods static library,
|
|
24
|
+
add a build configuration file, and add a post build script to copy
|
|
25
|
+
Pod resources.
|
|
26
|
+
|
|
27
|
+
This may return one of several error codes if it encounters problems.
|
|
28
|
+
* `1` Generic error code
|
|
29
|
+
* `31` Spec not found (i.e out-of-date source repos, mistyped Pod name etc...)
|
|
30
|
+
DESC
|
|
31
|
+
|
|
32
|
+
def self.options
|
|
33
|
+
[
|
|
34
|
+
['--repo-update', 'Force running `pod repo update` before install'],
|
|
35
|
+
['--deployment', 'Disallow any changes to the Podfile or the Podfile.lock during installation'],
|
|
36
|
+
['--clean-install', 'Ignore the contents of the project cache and force a full pod installation. This only ' \
|
|
37
|
+
'applies to projects that have enabled incremental installation'],
|
|
38
|
+
].concat(super).reject { |(name, _)| name == '--no-repo-update' }
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def initialize(argv)
|
|
42
|
+
self.log = argv.flag?('verbose')
|
|
43
|
+
self.repo_update = argv.flag?('repo-update')
|
|
44
|
+
super
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def run
|
|
48
|
+
LgPodPlugin.install({ :verbose => self.log, :repo_update => self.repo_update })
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
require 'claide'
|
|
2
|
+
module LgPodPlugin
|
|
3
|
+
class Command
|
|
4
|
+
class Update < Command
|
|
5
|
+
REQUIRED_ATTRS ||= %i[log repo_update].freeze
|
|
6
|
+
attr_accessor(*REQUIRED_ATTRS)
|
|
7
|
+
self.summary = 'Update outdated project dependencies and create new ' \
|
|
8
|
+
'Podfile.lock'
|
|
9
|
+
|
|
10
|
+
self.description = <<-DESC
|
|
11
|
+
Updates the Pods identified by the specified `POD_NAMES`, which is a
|
|
12
|
+
space-delimited list of pod names. If no `POD_NAMES` are specified, it
|
|
13
|
+
updates all the Pods, ignoring the contents of the Podfile.lock. This
|
|
14
|
+
command is reserved for the update of dependencies; pod install should
|
|
15
|
+
be used to install changes to the Podfile.
|
|
16
|
+
DESC
|
|
17
|
+
|
|
18
|
+
def self.options
|
|
19
|
+
[
|
|
20
|
+
["--sources=#{Pod::TrunkSource::TRUNK_REPO_URL}", 'The sources from which to update dependent pods. ' \
|
|
21
|
+
'Multiple sources must be comma-delimited'],
|
|
22
|
+
['--exclude-pods=podName', 'Pods to exclude during update. Multiple pods must be comma-delimited'],
|
|
23
|
+
['--clean-install', 'Ignore the contents of the project cache and force a full pod installation. This only ' \
|
|
24
|
+
'applies to projects that have enabled incremental installation'],
|
|
25
|
+
].concat(super)
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def initialize(argv)
|
|
29
|
+
self.log = argv.flag?('verbose')
|
|
30
|
+
self.repo_update = argv.flag?('repo-update')
|
|
31
|
+
super
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def run
|
|
35
|
+
LgPodPlugin.update({ :verbose => self.log, :repo_update => self.repo_update })
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
require 'git'
|
|
2
2
|
require_relative 'l_cache'
|
|
3
|
-
# require_relative 'database'
|
|
4
3
|
require_relative 'file_path'
|
|
5
4
|
|
|
6
5
|
module LgPodPlugin
|
|
@@ -12,16 +11,12 @@ module LgPodPlugin
|
|
|
12
11
|
|
|
13
12
|
def initialize(name, options = {})
|
|
14
13
|
self.name = name
|
|
15
|
-
self.options = options
|
|
16
|
-
self.git = options[:git]
|
|
17
|
-
self.tag = options[:tag]
|
|
18
|
-
self.branch = options[:branch]
|
|
19
|
-
self.commit = options[:commit]
|
|
14
|
+
self.options = Hash.new.deep_merge(options)
|
|
15
|
+
self.git = self.options[:git]
|
|
16
|
+
self.tag = self.options[:tag]
|
|
17
|
+
self.branch = self.options[:branch]
|
|
18
|
+
self.commit = self.options[:commit]
|
|
20
19
|
end
|
|
21
|
-
|
|
22
|
-
# def check_cache_valid(name, branch)
|
|
23
|
-
# self.db.should_clean_pod_info(name, branch)
|
|
24
|
-
# end
|
|
25
20
|
|
|
26
21
|
# 预下载处理
|
|
27
22
|
def pre_download_pod
|
|
@@ -31,15 +26,15 @@ module LgPodPlugin
|
|
|
31
26
|
LgPodPlugin.log_green "Using `#{name}`"
|
|
32
27
|
end
|
|
33
28
|
# 发现本地有缓存, 不需要更新缓存
|
|
34
|
-
need_download = LRequest.shared.cache.find_pod_cache(
|
|
35
|
-
if
|
|
36
|
-
LgPodPlugin.log_green "find the cache of `#{name}`, you can use it now."
|
|
37
|
-
return
|
|
38
|
-
else
|
|
29
|
+
need_download = LRequest.shared.cache.find_pod_cache(name)
|
|
30
|
+
if need_download
|
|
39
31
|
LgPodPlugin.log_green "find the new commit of `#{name}`, Git downloading now."
|
|
32
|
+
# 本地 git 下载 pod 目录
|
|
33
|
+
LRequest.shared.git_util.pre_download_git_repository
|
|
34
|
+
else
|
|
35
|
+
LRequest.shared.libs.delete(self.name)
|
|
36
|
+
LgPodPlugin.log_green "find the cache of `#{name}`, you can use it now."
|
|
40
37
|
end
|
|
41
|
-
# 本地 git 下载 pod 目录
|
|
42
|
-
LRequest.shared.git_util.pre_download_git_repository
|
|
43
38
|
|
|
44
39
|
# 本地clone代码失败跳出去
|
|
45
40
|
# unless real_pod_path.exist?
|
|
@@ -20,8 +20,10 @@ module LgPodPlugin
|
|
|
20
20
|
self.commit = options[:commit]
|
|
21
21
|
end
|
|
22
22
|
|
|
23
|
+
# 从 GitLab下载 zip包
|
|
23
24
|
# 根据branch 下载 zip 包
|
|
24
|
-
def
|
|
25
|
+
def gitlab_download_branch_zip(path, temp_name)
|
|
26
|
+
branch = self.branch ||= "master"
|
|
25
27
|
token = LRequest.shared.token
|
|
26
28
|
unless token
|
|
27
29
|
return self.git_clone_by_branch(path, temp_name)
|
|
@@ -32,25 +34,25 @@ module LgPodPlugin
|
|
|
32
34
|
unless project_name
|
|
33
35
|
return self.git_clone_by_branch(path, temp_name)
|
|
34
36
|
end
|
|
35
|
-
download_url = base_url + "/-/archive/" +
|
|
37
|
+
download_url = base_url + "/-/archive/" + branch + "/#{project_name}-#{branch}.zip"
|
|
36
38
|
LgPodPlugin.log_blue "开始下载 => #{download_url}"
|
|
37
|
-
system("curl --header PRIVATE-TOKEN:#{token} -o #{file_name} --connect-timeout
|
|
39
|
+
system("curl --header PRIVATE-TOKEN:#{token} -o #{file_name} --connect-timeout 60 --retry 3 #{download_url}")
|
|
38
40
|
unless File.exist?(file_name)
|
|
39
41
|
LgPodPlugin.log_red("下载zip包失败, 尝试git clone #{self.git}")
|
|
40
42
|
return self.git_clone_by_branch(path, temp_name)
|
|
41
43
|
end
|
|
42
44
|
# 解压文件
|
|
43
45
|
result = LUtils.unzip_file(path.join(file_name).to_path, "./")
|
|
44
|
-
new_file_name = "#{project_name}-#{
|
|
46
|
+
new_file_name = "#{project_name}-#{branch}"
|
|
45
47
|
unless result && File.exist?(new_file_name)
|
|
46
|
-
LgPodPlugin.log_red("
|
|
48
|
+
LgPodPlugin.log_red("正在尝试git clone #{self.git}")
|
|
47
49
|
return self.git_clone_by_branch(path, temp_name)
|
|
48
50
|
end
|
|
49
51
|
path.join(new_file_name)
|
|
50
52
|
end
|
|
51
53
|
|
|
52
54
|
# 通过tag下载zip包
|
|
53
|
-
def
|
|
55
|
+
def gitlab_download_tag_zip(path, temp_name)
|
|
54
56
|
token = LRequest.shared.token
|
|
55
57
|
unless token
|
|
56
58
|
return self.git_clone_by_tag(path, temp_name)
|
|
@@ -64,7 +66,7 @@ module LgPodPlugin
|
|
|
64
66
|
download_url = base_url + "/-/archive/" + self.tag + "/#{project_name}-#{self.tag}.zip"
|
|
65
67
|
# 下载文件
|
|
66
68
|
LgPodPlugin.log_blue "开始下载 => #{download_url}"
|
|
67
|
-
system("curl -s --header PRIVATE-TOKEN:#{token} -o #{file_name} #{download_url}")
|
|
69
|
+
system("curl -s --header PRIVATE-TOKEN:#{token} -o #{file_name} --connect-timeout 60 --retry 3 #{download_url}")
|
|
68
70
|
unless File.exist?(file_name)
|
|
69
71
|
LgPodPlugin.log_red("下载zip包失败, 尝试git clone #{self.git}")
|
|
70
72
|
return self.git_clone_by_tag(path, temp_name)
|
|
@@ -73,13 +75,14 @@ module LgPodPlugin
|
|
|
73
75
|
result = LUtils.unzip_file(path.join(file_name).to_path, "./")
|
|
74
76
|
new_file_name = "#{project_name}-#{self.tag}"
|
|
75
77
|
unless result && File.exist?(new_file_name)
|
|
76
|
-
LgPodPlugin.log_red("
|
|
78
|
+
LgPodPlugin.log_red("正在尝试git clone #{self.git}")
|
|
77
79
|
return self.git_clone_by_tag(path, temp_name)
|
|
78
80
|
end
|
|
79
81
|
path.join(new_file_name)
|
|
80
82
|
end
|
|
83
|
+
|
|
81
84
|
# 通过 commit 下载zip包
|
|
82
|
-
def
|
|
85
|
+
def gitlab_download_commit_zip(path, temp_name)
|
|
83
86
|
token = LRequest.shared.token
|
|
84
87
|
unless token
|
|
85
88
|
return self.git_clone_by_commit(path, temp_name)
|
|
@@ -93,24 +96,119 @@ module LgPodPlugin
|
|
|
93
96
|
download_url = base_url + "/-/archive/" + self.commit + "/#{project_name}-#{self.commit}.zip"
|
|
94
97
|
# 下载文件
|
|
95
98
|
LgPodPlugin.log_blue "开始下载 => #{download_url}"
|
|
96
|
-
system("curl -s --header PRIVATE-TOKEN:#{token} -o #{file_name} #{download_url}")
|
|
99
|
+
system("curl -s --header PRIVATE-TOKEN:#{token} -o #{file_name} --connect-timeout 60 --retry 3 #{download_url}")
|
|
100
|
+
unless File.exist?(file_name)
|
|
101
|
+
LgPodPlugin.log_red("正在尝试git clone #{self.git}")
|
|
102
|
+
return self.git_clone_by_commit(path, temp_name)
|
|
103
|
+
end
|
|
104
|
+
# 解压文件
|
|
105
|
+
result = LUtils.unzip_file(path.join(file_name).to_path, "./")
|
|
106
|
+
new_file_name = "#{project_name}-#{self.commit}"
|
|
107
|
+
unless result && File.exist?(new_file_name)
|
|
108
|
+
LgPodPlugin.log_red("正在尝试git clone #{self.git}")
|
|
109
|
+
return self.git_clone_by_commit(path, temp_name)
|
|
110
|
+
end
|
|
111
|
+
path.join(new_file_name)
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
# 从 Github下载 zip 包
|
|
115
|
+
# 根据branch 下载 zip 包
|
|
116
|
+
def github_download_branch_zip(path, temp_name)
|
|
117
|
+
file_name = "#{temp_name}.zip"
|
|
118
|
+
branch = self.branch ||= "master"
|
|
119
|
+
if self.git.include?(".git")
|
|
120
|
+
base_url = self.git[0...self.git.length - 4]
|
|
121
|
+
else
|
|
122
|
+
base_url = self.git
|
|
123
|
+
end
|
|
124
|
+
project_name = base_url.split("/").last if base_url
|
|
125
|
+
origin_url = base_url + "/archive/#{branch}.zip"
|
|
126
|
+
download_url = "https://gh.api.99988866.xyz/#{origin_url}"
|
|
127
|
+
LgPodPlugin.log_blue "开始下载 => #{download_url}"
|
|
128
|
+
system("curl -o #{file_name} --connect-timeout 60 --retry 3 #{download_url}")
|
|
97
129
|
unless File.exist?(file_name)
|
|
98
130
|
LgPodPlugin.log_red("下载zip包失败, 尝试git clone #{self.git}")
|
|
131
|
+
return self.git_clone_by_branch(path, temp_name)
|
|
132
|
+
end
|
|
133
|
+
# 解压文件
|
|
134
|
+
result = LUtils.unzip_file(path.join(file_name).to_path, "./")
|
|
135
|
+
new_file_name = "#{project_name}-#{branch}"
|
|
136
|
+
unless result && File.exist?(new_file_name)
|
|
137
|
+
LgPodPlugin.log_red("正在尝试git clone #{self.git}")
|
|
138
|
+
return self.git_clone_by_branch(path, temp_name)
|
|
139
|
+
end
|
|
140
|
+
path.join(new_file_name)
|
|
141
|
+
end
|
|
142
|
+
|
|
143
|
+
# 通过tag下载zip包
|
|
144
|
+
def github_download_tag_zip(path, temp_name)
|
|
145
|
+
file_name = "#{temp_name}.zip"
|
|
146
|
+
if self.git.include?(".git")
|
|
147
|
+
base_url = self.git[0...self.git.length - 4]
|
|
148
|
+
else
|
|
149
|
+
base_url = self.git
|
|
150
|
+
end
|
|
151
|
+
project_name = base_url.split("/").last if base_url
|
|
152
|
+
origin_url = base_url + "/archive/refs/tags/#{self.tag}.zip"
|
|
153
|
+
download_url = "https://gh.api.99988866.xyz/#{origin_url}"
|
|
154
|
+
# 下载文件
|
|
155
|
+
LgPodPlugin.log_blue "开始下载 => #{download_url}"
|
|
156
|
+
system("curl -s -o #{file_name} --connect-timeout 60 --retry 3 #{download_url}")
|
|
157
|
+
unless File.exist?(file_name)
|
|
158
|
+
LgPodPlugin.log_red("正在尝试git clone #{self.git}")
|
|
159
|
+
return self.git_clone_by_tag(path, temp_name)
|
|
160
|
+
end
|
|
161
|
+
# 解压文件
|
|
162
|
+
result = LUtils.unzip_file(path.join(file_name).to_path, "./")
|
|
163
|
+
if self.tag.include?("v") && self.tag[0...1] == "v"
|
|
164
|
+
this_tag = self.tag[1...self.tag.length]
|
|
165
|
+
else
|
|
166
|
+
this_tag = self.tag
|
|
167
|
+
end
|
|
168
|
+
new_file_name = "#{project_name}-#{this_tag}"
|
|
169
|
+
unless result && File.exist?(new_file_name)
|
|
170
|
+
LgPodPlugin.log_red("正在尝试git clone #{self.git}")
|
|
171
|
+
return self.git_clone_by_tag(path, temp_name)
|
|
172
|
+
end
|
|
173
|
+
path.join(new_file_name)
|
|
174
|
+
end
|
|
175
|
+
|
|
176
|
+
# 通过 commit 下载zip包
|
|
177
|
+
def github_download_commit_zip(path, temp_name)
|
|
178
|
+
file_name = "#{temp_name}.zip"
|
|
179
|
+
if self.git.include?(".git")
|
|
180
|
+
base_url = self.git[0...self.git.length - 4]
|
|
181
|
+
else
|
|
182
|
+
base_url = self.git
|
|
183
|
+
end
|
|
184
|
+
project_name = base_url.split("/").last if base_url
|
|
185
|
+
origin_url = base_url + "/archive/#{self.commit}.zip"
|
|
186
|
+
download_url = "https://gh.api.99988866.xyz/#{origin_url}"
|
|
187
|
+
# 下载文件
|
|
188
|
+
LgPodPlugin.log_blue "开始下载 => #{download_url}"
|
|
189
|
+
system("curl -s -o #{file_name} --connect-timeout 15 --retry 3 #{download_url}")
|
|
190
|
+
unless File.exist?(file_name)
|
|
191
|
+
LgPodPlugin.log_red("正在尝试git clone #{self.git}")
|
|
99
192
|
return self.git_clone_by_commit(path, temp_name)
|
|
100
193
|
end
|
|
101
194
|
# 解压文件
|
|
102
195
|
result = LUtils.unzip_file(path.join(file_name).to_path, "./")
|
|
103
196
|
new_file_name = "#{project_name}-#{self.commit}"
|
|
104
197
|
unless result && File.exist?(new_file_name)
|
|
105
|
-
LgPodPlugin.log_red("
|
|
198
|
+
LgPodPlugin.log_red("正在尝试git clone #{self.git}")
|
|
106
199
|
return self.git_clone_by_commit(path, temp_name)
|
|
107
200
|
end
|
|
108
201
|
path.join(new_file_name)
|
|
109
202
|
end
|
|
110
203
|
|
|
111
204
|
def git_clone_by_branch(path, temp_name)
|
|
112
|
-
|
|
113
|
-
|
|
205
|
+
if self.git && self.branch
|
|
206
|
+
LgPodPlugin.log_blue "git clone --depth=1 --branch #{self.branch} #{self.git}"
|
|
207
|
+
system("git clone --depth=1 -b #{self.branch} #{self.git} #{temp_name}")
|
|
208
|
+
else
|
|
209
|
+
LgPodPlugin.log_blue "git clone --depth=1 #{self.git}"
|
|
210
|
+
system("git clone --depth=1 #{self.git} #{temp_name}")
|
|
211
|
+
end
|
|
114
212
|
path.join(temp_name)
|
|
115
213
|
end
|
|
116
214
|
|
|
@@ -136,42 +234,38 @@ module LgPodPlugin
|
|
|
136
234
|
temp_name = "lg_temp_pod"
|
|
137
235
|
if self.git && self.tag
|
|
138
236
|
if self.git.include?("capp/iOS")
|
|
139
|
-
return
|
|
237
|
+
return gitlab_download_tag_zip(path, temp_name)
|
|
238
|
+
elsif self.git.include?("https://github.com")
|
|
239
|
+
return github_download_tag_zip path, temp_name
|
|
140
240
|
else
|
|
141
241
|
return self.git_clone_by_tag(path, temp_name)
|
|
142
242
|
end
|
|
143
243
|
elsif self.git && self.branch
|
|
144
244
|
if self.git.include?("capp/iOS")
|
|
145
|
-
return self.
|
|
245
|
+
return self.gitlab_download_branch_zip(path, temp_name)
|
|
246
|
+
elsif self.git.include?("https://github.com")
|
|
247
|
+
return self.github_download_branch_zip path, temp_name
|
|
146
248
|
else
|
|
147
249
|
return self.git_clone_by_branch(path, temp_name)
|
|
148
250
|
end
|
|
149
251
|
elsif self.git && self.commit
|
|
150
252
|
if self.git.include?("capp/iOS")
|
|
151
|
-
return self.
|
|
253
|
+
return self.gitlab_download_commit_zip(path, temp_name)
|
|
254
|
+
elsif self.git.include?("https://github.com")
|
|
255
|
+
return self.github_download_commit_zip path, temp_name
|
|
152
256
|
else
|
|
153
257
|
return self.git_clone_by_commit(path, temp_name)
|
|
154
258
|
end
|
|
259
|
+
elsif self.git
|
|
260
|
+
if self.git.include?("capp/iOS")
|
|
261
|
+
return self.gitlab_download_branch_zip(path, temp_name)
|
|
262
|
+
elsif self.git.include?("https://github.com")
|
|
263
|
+
return self.github_download_branch_zip path, temp_name
|
|
264
|
+
else
|
|
265
|
+
return self.git_clone_by_branch(path, temp_name)
|
|
266
|
+
end
|
|
155
267
|
end
|
|
156
|
-
end
|
|
157
|
-
|
|
158
|
-
# def git_checkout(branch)
|
|
159
|
-
# system("git checkout -b #{branch}")
|
|
160
|
-
# end
|
|
161
|
-
#
|
|
162
|
-
# def git_switch(branch)
|
|
163
|
-
# system("git switch #{branch}")
|
|
164
|
-
# end
|
|
165
268
|
|
|
166
|
-
def request_params
|
|
167
|
-
hash_map = {:git => git}
|
|
168
|
-
if git && tag
|
|
169
|
-
hash_map[:tag] = tag
|
|
170
|
-
hash_map[:commit] = self.commit
|
|
171
|
-
else
|
|
172
|
-
hash_map[:commit] = commit
|
|
173
|
-
end
|
|
174
|
-
hash_map
|
|
175
269
|
end
|
|
176
270
|
|
|
177
271
|
def pre_download_git_repository
|
|
@@ -188,20 +282,24 @@ module LgPodPlugin
|
|
|
188
282
|
unless get_temp_folder.exist?
|
|
189
283
|
return nil
|
|
190
284
|
end
|
|
191
|
-
|
|
285
|
+
if LRequest.shared.single_git
|
|
286
|
+
LgPodPlugin::LCache.cache_pod(self.name, get_temp_folder, { :git => self.git })
|
|
287
|
+
end
|
|
288
|
+
LgPodPlugin::LCache.cache_pod(self.name, get_temp_folder, LRequest.shared.get_cache_key_params)
|
|
192
289
|
FileUtils.chdir(LFileManager.download_director)
|
|
193
290
|
FileUtils.rm_rf(lg_pod_path)
|
|
194
291
|
end
|
|
195
|
-
|
|
292
|
+
|
|
196
293
|
# 获取最新的一条 commit 信息
|
|
197
294
|
def self.git_ls_remote_refs(git, branch, tag, commit)
|
|
198
295
|
if branch
|
|
199
296
|
LgPodPlugin.log_yellow "git ls-remote #{git} #{branch}"
|
|
200
|
-
|
|
297
|
+
result = %x(git ls-remote #{git} #{branch})
|
|
298
|
+
new_commit = result.split(" ").first if result
|
|
201
299
|
return [branch, new_commit]
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
300
|
+
elsif tag
|
|
301
|
+
LgPodPlugin.log_yellow "git ls-remote #{git}"
|
|
302
|
+
ls = Git.ls_remote(git, :head => true)
|
|
205
303
|
map = ls["tags"]
|
|
206
304
|
keys = map.keys
|
|
207
305
|
idx = keys.index("#{tag}")
|
|
@@ -212,75 +310,21 @@ module LgPodPlugin
|
|
|
212
310
|
new_commit = map[key][:sha]
|
|
213
311
|
return [nil, new_commit]
|
|
214
312
|
else
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
# 本地pod库git操作
|
|
229
|
-
def git_local_pod_check(path)
|
|
230
|
-
FileUtils.chdir(path)
|
|
231
|
-
git = Git.open(Pathname("./"))
|
|
232
|
-
current_branch = git.current_branch
|
|
233
|
-
last_stash_message = "#{current_branch}_pod_install_cache"
|
|
234
|
-
if self.branch == current_branch || !self.branch
|
|
235
|
-
# 是否恢复储藏内容到暂存区
|
|
236
|
-
self.should_pull(git ,current_branch)
|
|
237
|
-
else
|
|
238
|
-
# 存储上一个 branch 未暂存的内容
|
|
239
|
-
# 判断 git status 是否有要暂存的内容
|
|
240
|
-
have_changes = git.status.changed.map { |change|
|
|
241
|
-
change.to_s
|
|
242
|
-
}
|
|
243
|
-
# 如果有要暂存的内容, 就 git stash save
|
|
244
|
-
unless have_changes.empty?
|
|
245
|
-
# "当前#{current_branch}分支有未暂存的内容"
|
|
246
|
-
git.branch.stashes.save(last_stash_message)
|
|
313
|
+
if commit
|
|
314
|
+
return nil, commit
|
|
315
|
+
else
|
|
316
|
+
LgPodPlugin.log_yellow "git ls-remote #{git}"
|
|
317
|
+
ls = Git.ls_remote(git, :head => true)
|
|
318
|
+
find_commit = ls["head"][:sha]
|
|
319
|
+
ls["branches"].each do |key, value|
|
|
320
|
+
sha = value[:sha]
|
|
321
|
+
next if sha != find_commit
|
|
322
|
+
return [key, find_commit]
|
|
323
|
+
end
|
|
324
|
+
return nil, find_commit
|
|
247
325
|
end
|
|
248
|
-
# 这里 checkout到目标分支, 本地有git switch -b xxx, 本地没有 git checkout -b xxx
|
|
249
|
-
git.checkout(git.branch(branch))
|
|
250
|
-
current_branch = git.current_branch
|
|
251
|
-
self.should_pull(git ,current_branch)
|
|
252
|
-
# 是否恢复储藏内容到暂存区
|
|
253
|
-
self.should_pop_stash(git, current_branch)
|
|
254
|
-
end
|
|
255
|
-
end
|
|
256
|
-
# 是否pull 代码
|
|
257
|
-
def should_pull(git, branch, new_commit = nil)
|
|
258
|
-
new_branch = branch ||= self.branch
|
|
259
|
-
git_url = git.remote.url ||= self.git
|
|
260
|
-
if new_commit == nil
|
|
261
|
-
_, new_commit = LGitUtil.git_ls_remote_refs(git_url, new_branch,nil, nil)
|
|
262
326
|
end
|
|
263
|
-
local_commit = git.log(1).to_s #本地最后一条 commit hash 值
|
|
264
|
-
if local_commit != new_commit
|
|
265
|
-
system("git pull origin #{branch}")
|
|
266
|
-
end
|
|
267
|
-
end
|
|
268
327
|
|
|
269
|
-
def should_pop_stash(git, branch)
|
|
270
|
-
last_stash_message = "#{branch}_pod_install_cache"
|
|
271
|
-
# 查看下贮存的有没有代码
|
|
272
|
-
stashes = git.branch.stashes.all.flatten.select do |ss|
|
|
273
|
-
ss.is_a?(String)
|
|
274
|
-
end
|
|
275
|
-
unless stashes.include?(last_stash_message)
|
|
276
|
-
return
|
|
277
|
-
end
|
|
278
|
-
drop_index = stashes.index(last_stash_message)
|
|
279
|
-
# 恢复上次贮藏的代码
|
|
280
|
-
system("git stash apply stash@{#{drop_index}} ")
|
|
281
|
-
# pop 掉已恢复到暂缓区的代码
|
|
282
|
-
git_command = "git stash drop stash@{" + "#{drop_index}" + "}"
|
|
283
|
-
system(git_command)
|
|
284
328
|
end
|
|
285
329
|
|
|
286
330
|
end
|