lg_pod_plugin 1.1.3 → 1.1.4.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/lg +2 -2
- data/lib/command/command.rb +1 -2
- data/lib/command/install.rb +7 -2
- data/lib/command/update.rb +4 -1
- data/lib/lg_pod_plugin/config/l_config.rb +59 -0
- data/lib/lg_pod_plugin/config/lockfile_model.rb +59 -0
- data/lib/lg_pod_plugin/config/podspec.rb +266 -0
- data/lib/lg_pod_plugin/config/target.rb +33 -0
- data/lib/lg_pod_plugin/{database.rb → db/database.rb} +76 -16
- data/lib/lg_pod_plugin/downloader/downloader.rb +156 -0
- data/lib/lg_pod_plugin/{l_cache.rb → downloader/l_cache.rb} +42 -23
- data/lib/lg_pod_plugin/downloader/request.rb +239 -0
- data/lib/lg_pod_plugin/git/git_clone.rb +85 -0
- data/lib/lg_pod_plugin/git/git_download.rb +53 -0
- data/lib/lg_pod_plugin/git/github_api.rb +137 -0
- data/lib/lg_pod_plugin/git/github_archive.rb +165 -0
- data/lib/lg_pod_plugin/git/gitlab_api.rb +266 -0
- data/lib/lg_pod_plugin/git/gitlab_archive.rb +180 -0
- data/lib/lg_pod_plugin/git/http_download.rb +39 -0
- data/lib/lg_pod_plugin/installer/PodDownload +0 -0
- data/lib/lg_pod_plugin/installer/concurrency.rb +21 -0
- data/lib/lg_pod_plugin/installer/install.rb +111 -0
- data/lib/lg_pod_plugin/installer/main.rb +63 -0
- data/lib/lg_pod_plugin/installer/project.rb +47 -0
- data/lib/lg_pod_plugin/net/l_uri.rb +87 -0
- data/lib/lg_pod_plugin/net/net-ping.rb +27 -0
- data/lib/lg_pod_plugin/pod/external_pod.rb +21 -0
- data/lib/lg_pod_plugin/pod/release-pod.rb +158 -0
- data/lib/lg_pod_plugin/utils/aes-crypt.rb +82 -0
- data/lib/lg_pod_plugin/{file_path.rb → utils/file_path.rb} +3 -5
- data/lib/lg_pod_plugin/utils/l_util.rb +133 -0
- data/lib/lg_pod_plugin/{log.rb → utils/log.rb} +1 -1
- data/lib/lg_pod_plugin/{string.rb → utils/string.rb} +0 -0
- data/lib/lg_pod_plugin/version.rb +1 -1
- data/lib/lg_pod_plugin.rb +24 -9
- data/lib/sqlite3-1.5.3-arm64-darwin/API_CHANGES.md +49 -0
- data/lib/sqlite3-1.5.3-arm64-darwin/CHANGELOG.md +462 -0
- data/lib/sqlite3-1.5.3-arm64-darwin/CONTRIBUTING.md +24 -0
- data/lib/sqlite3-1.5.3-arm64-darwin/ChangeLog.cvs +88 -0
- data/lib/sqlite3-1.5.3-arm64-darwin/README.md +235 -0
- data/lib/sqlite3-1.5.3-arm64-darwin/dependencies.yml +14 -0
- data/lib/sqlite3-1.5.3-arm64-darwin/ext/sqlite3/aggregator.c +274 -0
- data/lib/sqlite3-1.5.3-arm64-darwin/ext/sqlite3/aggregator.h +12 -0
- data/lib/sqlite3-1.5.3-arm64-darwin/ext/sqlite3/backup.c +168 -0
- data/lib/sqlite3-1.5.3-arm64-darwin/ext/sqlite3/backup.h +15 -0
- data/lib/sqlite3-1.5.3-arm64-darwin/ext/sqlite3/database.c +853 -0
- data/lib/sqlite3-1.5.3-arm64-darwin/ext/sqlite3/database.h +17 -0
- data/lib/sqlite3-1.5.3-arm64-darwin/ext/sqlite3/exception.c +98 -0
- data/lib/sqlite3-1.5.3-arm64-darwin/ext/sqlite3/exception.h +8 -0
- data/lib/sqlite3-1.5.3-arm64-darwin/ext/sqlite3/extconf.rb +251 -0
- data/lib/sqlite3-1.5.3-arm64-darwin/ext/sqlite3/sqlite3.c +163 -0
- data/lib/sqlite3-1.5.3-arm64-darwin/ext/sqlite3/sqlite3_ruby.h +48 -0
- data/lib/sqlite3-1.5.3-arm64-darwin/ext/sqlite3/statement.c +442 -0
- data/lib/sqlite3-1.5.3-arm64-darwin/ext/sqlite3/statement.h +16 -0
- data/lib/sqlite3-1.5.3-arm64-darwin/faq/faq.md +431 -0
- data/lib/sqlite3-1.5.3-arm64-darwin/faq/faq.rb +145 -0
- data/lib/sqlite3-1.5.3-arm64-darwin/faq/faq.yml +426 -0
- data/lib/sqlite3-1.5.3-arm64-darwin/lib/sqlite3/2.6/sqlite3_native.bundle +0 -0
- data/lib/sqlite3-1.5.3-arm64-darwin/lib/sqlite3/2.7/sqlite3_native.bundle +0 -0
- data/lib/sqlite3-1.5.3-arm64-darwin/lib/sqlite3/3.0/sqlite3_native.bundle +0 -0
- data/lib/sqlite3-1.5.3-arm64-darwin/lib/sqlite3/3.1/sqlite3_native.bundle +0 -0
- data/lib/sqlite3-1.5.3-arm64-darwin/lib/sqlite3/constants.rb +50 -0
- data/lib/sqlite3-1.5.3-arm64-darwin/lib/sqlite3/database.rb +741 -0
- data/lib/sqlite3-1.5.3-arm64-darwin/lib/sqlite3/errors.rb +35 -0
- data/lib/sqlite3-1.5.3-arm64-darwin/lib/sqlite3/pragmas.rb +595 -0
- data/lib/sqlite3-1.5.3-arm64-darwin/lib/sqlite3/resultset.rb +187 -0
- data/lib/sqlite3-1.5.3-arm64-darwin/lib/sqlite3/statement.rb +145 -0
- data/lib/sqlite3-1.5.3-arm64-darwin/lib/sqlite3/translator.rb +118 -0
- data/lib/sqlite3-1.5.3-arm64-darwin/lib/sqlite3/value.rb +57 -0
- data/lib/sqlite3-1.5.3-arm64-darwin/lib/sqlite3/version.rb +23 -0
- data/lib/sqlite3-1.5.3-arm64-darwin/lib/sqlite3.rb +15 -0
- data/lib/sqlite3-1.5.3-arm64-darwin/test/helper.rb +27 -0
- data/lib/sqlite3-1.5.3-arm64-darwin/test/test_backup.rb +33 -0
- data/lib/sqlite3-1.5.3-arm64-darwin/test/test_collation.rb +82 -0
- data/lib/sqlite3-1.5.3-arm64-darwin/test/test_database.rb +545 -0
- data/lib/sqlite3-1.5.3-arm64-darwin/test/test_database_flags.rb +95 -0
- data/lib/sqlite3-1.5.3-arm64-darwin/test/test_database_readonly.rb +36 -0
- data/lib/sqlite3-1.5.3-arm64-darwin/test/test_database_readwrite.rb +41 -0
- data/lib/sqlite3-1.5.3-arm64-darwin/test/test_deprecated.rb +44 -0
- data/lib/sqlite3-1.5.3-arm64-darwin/test/test_encoding.rb +155 -0
- data/lib/sqlite3-1.5.3-arm64-darwin/test/test_integration.rb +507 -0
- data/lib/sqlite3-1.5.3-arm64-darwin/test/test_integration_aggregate.rb +336 -0
- data/lib/sqlite3-1.5.3-arm64-darwin/test/test_integration_open_close.rb +30 -0
- data/lib/sqlite3-1.5.3-arm64-darwin/test/test_integration_pending.rb +115 -0
- data/lib/sqlite3-1.5.3-arm64-darwin/test/test_integration_resultset.rb +142 -0
- data/lib/sqlite3-1.5.3-arm64-darwin/test/test_integration_statement.rb +194 -0
- data/lib/sqlite3-1.5.3-arm64-darwin/test/test_result_set.rb +37 -0
- data/lib/sqlite3-1.5.3-arm64-darwin/test/test_sqlite3.rb +30 -0
- data/lib/sqlite3-1.5.3-arm64-darwin/test/test_statement.rb +263 -0
- data/lib/sqlite3-1.5.3-arm64-darwin/test/test_statement_execute.rb +35 -0
- data/lib/sqlite3-1.5.3-x86_64-darwin/API_CHANGES.md +49 -0
- data/lib/sqlite3-1.5.3-x86_64-darwin/CHANGELOG.md +462 -0
- data/lib/sqlite3-1.5.3-x86_64-darwin/CONTRIBUTING.md +24 -0
- data/lib/sqlite3-1.5.3-x86_64-darwin/ChangeLog.cvs +88 -0
- data/lib/sqlite3-1.5.3-x86_64-darwin/README.md +235 -0
- data/lib/sqlite3-1.5.3-x86_64-darwin/dependencies.yml +14 -0
- data/lib/sqlite3-1.5.3-x86_64-darwin/ext/sqlite3/aggregator.c +274 -0
- data/lib/sqlite3-1.5.3-x86_64-darwin/ext/sqlite3/aggregator.h +12 -0
- data/lib/sqlite3-1.5.3-x86_64-darwin/ext/sqlite3/backup.c +168 -0
- data/lib/sqlite3-1.5.3-x86_64-darwin/ext/sqlite3/backup.h +15 -0
- data/lib/sqlite3-1.5.3-x86_64-darwin/ext/sqlite3/database.c +853 -0
- data/lib/sqlite3-1.5.3-x86_64-darwin/ext/sqlite3/database.h +17 -0
- data/lib/sqlite3-1.5.3-x86_64-darwin/ext/sqlite3/exception.c +98 -0
- data/lib/sqlite3-1.5.3-x86_64-darwin/ext/sqlite3/exception.h +8 -0
- data/lib/sqlite3-1.5.3-x86_64-darwin/ext/sqlite3/extconf.rb +251 -0
- data/lib/sqlite3-1.5.3-x86_64-darwin/ext/sqlite3/sqlite3.c +163 -0
- data/lib/sqlite3-1.5.3-x86_64-darwin/ext/sqlite3/sqlite3_ruby.h +48 -0
- data/lib/sqlite3-1.5.3-x86_64-darwin/ext/sqlite3/statement.c +442 -0
- data/lib/sqlite3-1.5.3-x86_64-darwin/ext/sqlite3/statement.h +16 -0
- data/lib/sqlite3-1.5.3-x86_64-darwin/faq/faq.md +431 -0
- data/lib/sqlite3-1.5.3-x86_64-darwin/faq/faq.rb +145 -0
- data/lib/sqlite3-1.5.3-x86_64-darwin/faq/faq.yml +426 -0
- data/lib/sqlite3-1.5.3-x86_64-darwin/lib/sqlite3/2.6/sqlite3_native.bundle +0 -0
- data/lib/sqlite3-1.5.3-x86_64-darwin/lib/sqlite3/2.7/sqlite3_native.bundle +0 -0
- data/lib/sqlite3-1.5.3-x86_64-darwin/lib/sqlite3/3.0/sqlite3_native.bundle +0 -0
- data/lib/sqlite3-1.5.3-x86_64-darwin/lib/sqlite3/3.1/sqlite3_native.bundle +0 -0
- data/lib/sqlite3-1.5.3-x86_64-darwin/lib/sqlite3/constants.rb +50 -0
- data/lib/sqlite3-1.5.3-x86_64-darwin/lib/sqlite3/database.rb +741 -0
- data/lib/sqlite3-1.5.3-x86_64-darwin/lib/sqlite3/errors.rb +35 -0
- data/lib/sqlite3-1.5.3-x86_64-darwin/lib/sqlite3/pragmas.rb +595 -0
- data/lib/sqlite3-1.5.3-x86_64-darwin/lib/sqlite3/resultset.rb +187 -0
- data/lib/sqlite3-1.5.3-x86_64-darwin/lib/sqlite3/statement.rb +145 -0
- data/lib/sqlite3-1.5.3-x86_64-darwin/lib/sqlite3/translator.rb +118 -0
- data/lib/sqlite3-1.5.3-x86_64-darwin/lib/sqlite3/value.rb +57 -0
- data/lib/sqlite3-1.5.3-x86_64-darwin/lib/sqlite3/version.rb +23 -0
- data/lib/sqlite3-1.5.3-x86_64-darwin/lib/sqlite3.rb +15 -0
- data/lib/sqlite3-1.5.3-x86_64-darwin/test/helper.rb +27 -0
- data/lib/sqlite3-1.5.3-x86_64-darwin/test/test_backup.rb +33 -0
- data/lib/sqlite3-1.5.3-x86_64-darwin/test/test_collation.rb +82 -0
- data/lib/sqlite3-1.5.3-x86_64-darwin/test/test_database.rb +545 -0
- data/lib/sqlite3-1.5.3-x86_64-darwin/test/test_database_flags.rb +95 -0
- data/lib/sqlite3-1.5.3-x86_64-darwin/test/test_database_readonly.rb +36 -0
- data/lib/sqlite3-1.5.3-x86_64-darwin/test/test_database_readwrite.rb +41 -0
- data/lib/sqlite3-1.5.3-x86_64-darwin/test/test_deprecated.rb +44 -0
- data/lib/sqlite3-1.5.3-x86_64-darwin/test/test_encoding.rb +155 -0
- data/lib/sqlite3-1.5.3-x86_64-darwin/test/test_integration.rb +507 -0
- data/lib/sqlite3-1.5.3-x86_64-darwin/test/test_integration_aggregate.rb +336 -0
- data/lib/sqlite3-1.5.3-x86_64-darwin/test/test_integration_open_close.rb +30 -0
- data/lib/sqlite3-1.5.3-x86_64-darwin/test/test_integration_pending.rb +115 -0
- data/lib/sqlite3-1.5.3-x86_64-darwin/test/test_integration_resultset.rb +142 -0
- data/lib/sqlite3-1.5.3-x86_64-darwin/test/test_integration_statement.rb +194 -0
- data/lib/sqlite3-1.5.3-x86_64-darwin/test/test_result_set.rb +37 -0
- data/lib/sqlite3-1.5.3-x86_64-darwin/test/test_sqlite3.rb +30 -0
- data/lib/sqlite3-1.5.3-x86_64-darwin/test/test_statement.rb +263 -0
- data/lib/sqlite3-1.5.3-x86_64-darwin/test/test_statement_execute.rb +35 -0
- metadata +146 -53
- data/lib/lg_pod_plugin/downloader.rb +0 -57
- data/lib/lg_pod_plugin/gitlab_api.rb +0 -147
- data/lib/lg_pod_plugin/gitlab_archive.rb +0 -352
- data/lib/lg_pod_plugin/gitlab_download.rb +0 -159
- data/lib/lg_pod_plugin/install.rb +0 -81
- data/lib/lg_pod_plugin/l_config.rb +0 -83
- data/lib/lg_pod_plugin/l_util.rb +0 -145
- data/lib/lg_pod_plugin/net-ping.rb +0 -41
- data/lib/lg_pod_plugin/podspec.rb +0 -156
- data/lib/lg_pod_plugin/release-pod.rb +0 -90
- data/lib/lg_pod_plugin/request.rb +0 -221
- data/lib/lg_pod_plugin/runner.rb +0 -114
- data/lib/lg_pod_plugin/specification.rb +0 -52
@@ -1,352 +0,0 @@
|
|
1
|
-
require 'uri'
|
2
|
-
require_relative 'request'
|
3
|
-
require_relative 'l_util'
|
4
|
-
require_relative 'l_config'
|
5
|
-
require_relative 'podspec'
|
6
|
-
require_relative 'gitlab_api'
|
7
|
-
|
8
|
-
module LgPodPlugin
|
9
|
-
|
10
|
-
class GitLabArchive
|
11
|
-
REQUIRED_ATTRS ||= %i[git tag name commit branch].freeze
|
12
|
-
attr_accessor(*REQUIRED_ATTRS)
|
13
|
-
|
14
|
-
def initialize(name, git, branch, tag, commit)
|
15
|
-
self.git = git ||= LRequest.shared.request_params[:git]
|
16
|
-
self.tag = tag ||= LRequest.shared.request_params[:tag]
|
17
|
-
self.name = name ||= LRequest.shared.request_params[:name]
|
18
|
-
self.commit = commit ||= LRequest.shared.request_params[:commit]
|
19
|
-
self.branch = branch ||= LRequest.shared.request_params[:branch]
|
20
|
-
end
|
21
|
-
|
22
|
-
# 下载某个文件zip格式
|
23
|
-
def gitlab_download_file_by_name(path, filename, temp_name, project_name)
|
24
|
-
host = LRequest.shared.config.host
|
25
|
-
project = LRequest.shared.config.project
|
26
|
-
unless host
|
27
|
-
http = Ping.new(project.web_url)
|
28
|
-
host = http.uri.scheme + "://" + http.uri.hostname
|
29
|
-
end
|
30
|
-
if self.git && self.tag
|
31
|
-
sha = self.tag
|
32
|
-
elsif self.git && self.branch
|
33
|
-
sha = self.branch
|
34
|
-
elsif self.git && self.commit
|
35
|
-
sha = self.commit
|
36
|
-
end
|
37
|
-
token = LRequest.shared.config.access_token
|
38
|
-
begin
|
39
|
-
encode_fiename = LUtils.url_encode(filename)
|
40
|
-
download_url = host + "/api/v4/projects/" + "#{project.id}" + "/repository/archive.zip#{"\\?"}" + "path#{"\\="}#{encode_fiename}#{"\\&"}sha#{"\\="}#{sha}"
|
41
|
-
rescue => exception
|
42
|
-
return nil
|
43
|
-
end
|
44
|
-
LUtils.download_gitlab_zip_file(download_url, token, temp_name)
|
45
|
-
return nil unless File.exist?(temp_name)
|
46
|
-
result = LUtils.unzip_file(temp_name, "./")
|
47
|
-
FileUtils.rm_rf temp_name unless result
|
48
|
-
return nil unless result
|
49
|
-
temp_zip_folder = nil
|
50
|
-
path.each_child do |f|
|
51
|
-
ftype = File::ftype(f)
|
52
|
-
next unless ftype == "directory"
|
53
|
-
next unless f.to_path.include?("#{filename}") || f.to_path.include?("#{project_name}")
|
54
|
-
temp_zip_folder = f
|
55
|
-
break
|
56
|
-
end
|
57
|
-
return nil unless temp_zip_folder && temp_zip_folder.exist?
|
58
|
-
begin
|
59
|
-
FileUtils.chdir(temp_zip_folder)
|
60
|
-
temp_zip_folder.each_child do |f|
|
61
|
-
ftype = File::ftype(f)
|
62
|
-
FileUtils.mv(f, path)
|
63
|
-
end
|
64
|
-
FileUtils.chdir(path)
|
65
|
-
FileUtils.rm_rf(temp_zip_folder)
|
66
|
-
FileUtils.rm_rf("./#{temp_name}")
|
67
|
-
return path
|
68
|
-
rescue => exception
|
69
|
-
pp exception
|
70
|
-
return path
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
# 从 GitLab下载 zip包
|
75
|
-
# 根据branch 下载 zip 包
|
76
|
-
def gitlab_download_branch_zip(root_path, temp_name)
|
77
|
-
project_path = root_path.join(self.name)
|
78
|
-
unless project_path.exist?
|
79
|
-
project_path.mkdir
|
80
|
-
FileUtils.chdir(project_path)
|
81
|
-
end
|
82
|
-
branch = self.branch ||= "HEAD"
|
83
|
-
token = LRequest.shared.config.access_token
|
84
|
-
base_url = LRequest.shared.config.project.web_url
|
85
|
-
project_name = LRequest.shared.config.project.path
|
86
|
-
podspec_name = self.name + ".podspec"
|
87
|
-
LgPodPlugin.log_blue "开始下载 => #{base_url}"
|
88
|
-
self.gitlab_download_file_by_name(project_path, podspec_name,"#{podspec_name}.zip", project_name)
|
89
|
-
podspec_path = project_path.join(podspec_name)
|
90
|
-
return nil unless File.exist?(podspec_path)
|
91
|
-
begin
|
92
|
-
need_download_files = PodSpec.form_file(podspec_path).source_files
|
93
|
-
rescue
|
94
|
-
need_download_files = Set[]
|
95
|
-
end
|
96
|
-
unless !need_download_files.empty?
|
97
|
-
FileUtils.chdir(root_path)
|
98
|
-
file_name = "#{temp_name}.zip"
|
99
|
-
download_url = LUtils.get_gitlab_download_url(base_url, branch, nil, nil, project_name)
|
100
|
-
raise "download_url不存在" unless download_url
|
101
|
-
# LgPodPlugin.log_blue "开始下载 => #{download_url}"
|
102
|
-
LUtils.download_gitlab_zip_file(download_url, token, file_name)
|
103
|
-
raise "下载zip包失败, 尝试git clone #{self.git}" unless File.exist?(file_name)
|
104
|
-
# 解压文件
|
105
|
-
result = LUtils.unzip_file(root_path.join(file_name).to_path, "./")
|
106
|
-
new_file_name = "#{project_name}-#{branch}"
|
107
|
-
raise "解压文件失败, #{new_file_name}不存在" unless result && File.exist?(new_file_name)
|
108
|
-
return root_path.join(new_file_name)
|
109
|
-
end
|
110
|
-
need_download_files.each do |file|
|
111
|
-
next if project_path.join(file).exist?
|
112
|
-
self.gitlab_download_file_by_name(project_path, file,"#{file}.zip", project_name)
|
113
|
-
end
|
114
|
-
return project_path
|
115
|
-
end
|
116
|
-
|
117
|
-
# 通过tag下载zip包
|
118
|
-
def gitlab_download_tag_zip(root_path, temp_name)
|
119
|
-
project_path = root_path.join(self.name)
|
120
|
-
unless project_path.exist?
|
121
|
-
project_path.mkdir
|
122
|
-
FileUtils.chdir(project_path)
|
123
|
-
end
|
124
|
-
token = LRequest.shared.config.access_token
|
125
|
-
base_url = LRequest.shared.config.project.web_url
|
126
|
-
project_name = LRequest.shared.config.project.path
|
127
|
-
podspec_name = self.name + ".podspec"
|
128
|
-
LgPodPlugin.log_blue "开始下载 => #{base_url}"
|
129
|
-
self.gitlab_download_file_by_name(project_path, podspec_name,"#{podspec_name}.zip", project_name)
|
130
|
-
podspec_path = project_path.join(podspec_name)
|
131
|
-
return nil unless File.exist?(podspec_path)
|
132
|
-
begin
|
133
|
-
need_download_files = PodSpec.form_file(podspec_path).source_files
|
134
|
-
rescue
|
135
|
-
need_download_files = Set[]
|
136
|
-
end
|
137
|
-
unless !need_download_files.empty?
|
138
|
-
tag = self.tag
|
139
|
-
FileUtils.chdir(root_path)
|
140
|
-
file_name = "#{temp_name}.zip"
|
141
|
-
download_url = LUtils.get_gitlab_download_url(base_url, nil, tag, nil, project_name)
|
142
|
-
raise "download_url不存在" unless download_url
|
143
|
-
LUtils.download_gitlab_zip_file(download_url, token, file_name)
|
144
|
-
raise "下载zip包失败, 尝试git clone #{self.git}" unless File.exist?(file_name)
|
145
|
-
# 解压文件
|
146
|
-
result = LUtils.unzip_file(root_path.join(file_name).to_path, "./")
|
147
|
-
new_file_name = "#{project_name}-#{tag}"
|
148
|
-
raise "解压文件失败, #{new_file_name}不存在" unless result && File.exist?(new_file_name)
|
149
|
-
return root_path.join(new_file_name)
|
150
|
-
end
|
151
|
-
need_download_files.each do |file|
|
152
|
-
self.gitlab_download_file_by_name(project_path, file,"#{file}.zip", project_name)
|
153
|
-
end
|
154
|
-
return project_path
|
155
|
-
end
|
156
|
-
|
157
|
-
# 通过 commit 下载zip包
|
158
|
-
def gitlab_download_commit_zip(root_path, temp_name)
|
159
|
-
project_path = root_path.join(self.name)
|
160
|
-
unless project_path.exist?
|
161
|
-
project_path.mkdir
|
162
|
-
FileUtils.chdir(project_path)
|
163
|
-
end
|
164
|
-
token = LRequest.shared.config.access_token
|
165
|
-
base_url = LRequest.shared.config.project.web_url
|
166
|
-
project_name = LRequest.shared.config.project.path
|
167
|
-
podspec_name = self.name + ".podspec"
|
168
|
-
LgPodPlugin.log_blue "开始下载 => #{base_url}"
|
169
|
-
self.gitlab_download_file_by_name(project_path, podspec_name,"#{podspec_name}.zip", project_name)
|
170
|
-
podspec_path = project_path.join(podspec_name)
|
171
|
-
return nil unless File.exist?(podspec_path)
|
172
|
-
begin
|
173
|
-
need_download_files = PodSpec.form_file(podspec_path).source_files
|
174
|
-
rescue
|
175
|
-
need_download_files = Set[]
|
176
|
-
end
|
177
|
-
unless !need_download_files.empty?
|
178
|
-
FileUtils.chdir(root_path)
|
179
|
-
file_name = "#{temp_name}.zip"
|
180
|
-
download_url = LUtils.get_gitlab_download_url(base_url, nil, nil, self.commit, project_name)
|
181
|
-
raise "download_url不存在" unless download_url
|
182
|
-
# LgPodPlugin.log_blue "开始下载 => #{download_url}"
|
183
|
-
LUtils.download_gitlab_zip_file(download_url, token, file_name)
|
184
|
-
raise "下载zip包失败, 尝试git clone #{self.git}" unless File.exist?(file_name)
|
185
|
-
# 解压文件
|
186
|
-
result = LUtils.unzip_file(root_path.join(file_name).to_path, "./")
|
187
|
-
new_file_name = "#{project_name}-#{self.commit}"
|
188
|
-
raise "解压文件失败, #{new_file_name}不存在" unless result && File.exist?(new_file_name)
|
189
|
-
return root_path.join(new_file_name)
|
190
|
-
end
|
191
|
-
need_download_files.each do |file|
|
192
|
-
self.gitlab_download_file_by_name(project_path, file,"#{file}.zip", project_name)
|
193
|
-
end
|
194
|
-
return project_path
|
195
|
-
end
|
196
|
-
|
197
|
-
# 从 Github下载 zip 包
|
198
|
-
# 根据branch 下载 zip 包
|
199
|
-
def github_download_branch_zip(path, temp_name)
|
200
|
-
file_name = "#{temp_name}.zip"
|
201
|
-
branch = self.branch ||= "HEAD"
|
202
|
-
if self.git.include?(".git")
|
203
|
-
base_url = self.git[0...self.git.length - 4]
|
204
|
-
else
|
205
|
-
base_url = self.git
|
206
|
-
end
|
207
|
-
project_name = base_url.split("/").last if base_url
|
208
|
-
url_path = base_url.split("https://github.com/").last
|
209
|
-
if branch == "HEAD"
|
210
|
-
download_url = "https://gh.api.99988866.xyz/" + "#{base_url}" + "/archive/#{branch}.zip"
|
211
|
-
else
|
212
|
-
download_url = "https://codeload.github.com/#{url_path}/zip/refs/heads/#{branch}"
|
213
|
-
end
|
214
|
-
LgPodPlugin.log_blue "开始下载 => #{download_url}"
|
215
|
-
LUtils.download_github_zip_file(download_url, file_name)
|
216
|
-
unless File.exist?(file_name)
|
217
|
-
LgPodPlugin.log_red("下载zip包失败, 尝试git clone #{self.git}")
|
218
|
-
return self.git_clone_by_branch(path, temp_name)
|
219
|
-
end
|
220
|
-
# 解压文件
|
221
|
-
result = LUtils.unzip_file(path.join(file_name).to_path, "./")
|
222
|
-
temp_zip_folder = nil
|
223
|
-
path.each_child do |f|
|
224
|
-
ftype = File::ftype(f)
|
225
|
-
next unless ftype == "directory"
|
226
|
-
next unless f.to_path.include?("#{branch}") || f.to_path.include?("#{project_name}")
|
227
|
-
temp_zip_folder = f
|
228
|
-
break
|
229
|
-
end
|
230
|
-
unless temp_zip_folder && File.exist?(temp_zip_folder)
|
231
|
-
LgPodPlugin.log_red("正在尝试git clone #{self.git}")
|
232
|
-
return self.git_clone_by_branch(path, temp_name)
|
233
|
-
end
|
234
|
-
temp_zip_folder
|
235
|
-
end
|
236
|
-
|
237
|
-
# 通过tag下载zip包
|
238
|
-
def github_download_tag_zip(path, temp_name)
|
239
|
-
file_name = "#{temp_name}.zip"
|
240
|
-
if self.git.include?(".git")
|
241
|
-
base_url = self.git[0...self.git.length - 4]
|
242
|
-
else
|
243
|
-
base_url = self.git
|
244
|
-
end
|
245
|
-
uri = URI(base_url)
|
246
|
-
project_name = base_url.split("/").last if base_url
|
247
|
-
download_url = "https://codeload.github.com#{uri.path}/zip/refs/tags/#{self.tag}"
|
248
|
-
# 下载文件
|
249
|
-
LgPodPlugin.log_blue "开始下载 => #{download_url}"
|
250
|
-
LUtils.download_github_zip_file(download_url, file_name)
|
251
|
-
unless File.exist?(file_name)
|
252
|
-
LgPodPlugin.log_red("正在尝试git clone #{self.git}")
|
253
|
-
return self.git_clone_by_tag(path, temp_name)
|
254
|
-
end
|
255
|
-
# 解压文件
|
256
|
-
result = LUtils.unzip_file(path.join(file_name).to_path, "./")
|
257
|
-
temp_zip_folder = nil
|
258
|
-
path.each_child do |f|
|
259
|
-
ftype = File::ftype(f)
|
260
|
-
next unless ftype == "directory"
|
261
|
-
version = self.tag.split("v").last ||= self.tag
|
262
|
-
next unless f.to_path.include?("#{project_name}") || f.to_path.include?(version)
|
263
|
-
temp_zip_folder = f
|
264
|
-
break
|
265
|
-
end
|
266
|
-
unless temp_zip_folder && File.exist?(temp_zip_folder)
|
267
|
-
LgPodPlugin.log_red("正在尝试git clone #{self.git}")
|
268
|
-
return self.git_clone_by_tag(path, temp_name)
|
269
|
-
end
|
270
|
-
temp_zip_folder
|
271
|
-
end
|
272
|
-
|
273
|
-
# 通过 commit 下载zip包
|
274
|
-
def github_download_commit_zip(path, temp_name)
|
275
|
-
file_name = "#{temp_name}.zip"
|
276
|
-
if self.git.include?(".git")
|
277
|
-
base_url = self.git[0...self.git.length - 4]
|
278
|
-
else
|
279
|
-
base_url = self.git
|
280
|
-
end
|
281
|
-
uri = URI(base_url)
|
282
|
-
project_name = base_url.split("/").last if base_url
|
283
|
-
download_url = "https://codeload.github.com#{uri.path}/zip/#{self.commit}"
|
284
|
-
# 下载文件
|
285
|
-
LgPodPlugin.log_blue "开始下载 => #{download_url}"
|
286
|
-
LUtils.download_github_zip_file(download_url, file_name)
|
287
|
-
unless File.exist?(file_name)
|
288
|
-
LgPodPlugin.log_red("正在尝试git clone #{self.git}")
|
289
|
-
return self.git_clone_by_commit(path, temp_name)
|
290
|
-
end
|
291
|
-
# 解压文件
|
292
|
-
result = LUtils.unzip_file(path.join(file_name).to_path, "./")
|
293
|
-
new_file_name = "#{project_name}-#{self.commit}"
|
294
|
-
unless result && File.exist?(new_file_name)
|
295
|
-
LgPodPlugin.log_red("正在尝试git clone #{self.git}")
|
296
|
-
return self.git_clone_by_commit(path, temp_name)
|
297
|
-
end
|
298
|
-
path.join(new_file_name)
|
299
|
-
end
|
300
|
-
|
301
|
-
def git_clone_by_branch(path, temp_name)
|
302
|
-
download_temp_path = path.join(temp_name)
|
303
|
-
if self.git && self.branch
|
304
|
-
git_download_command(temp_name, self.git, self.branch, nil)
|
305
|
-
else
|
306
|
-
git_download_command(temp_name, self.git, nil, nil)
|
307
|
-
if File.exist?(temp_name)
|
308
|
-
system("git -C #{download_temp_path.to_path} rev-parse HEAD")
|
309
|
-
end
|
310
|
-
end
|
311
|
-
download_temp_path
|
312
|
-
end
|
313
|
-
|
314
|
-
def git_clone_by_tag(path, temp_name)
|
315
|
-
git_download_command(temp_name, self.git, nil, self.tag)
|
316
|
-
path.join(temp_name)
|
317
|
-
end
|
318
|
-
|
319
|
-
# git clone commit
|
320
|
-
def git_clone_by_commit(path, temp_name)
|
321
|
-
Git.init(temp_name)
|
322
|
-
FileUtils.chdir(temp_name)
|
323
|
-
LgPodPlugin.log_blue "git clone #{self.git}"
|
324
|
-
system("git remote add origin #{self.git}")
|
325
|
-
system("git fetch origin #{self.commit}")
|
326
|
-
system("git reset --hard FETCH_HEAD")
|
327
|
-
path.join(temp_name)
|
328
|
-
end
|
329
|
-
|
330
|
-
# 封装 git clone命令
|
331
|
-
def git_download_command(temp_name, git, branch, tag)
|
332
|
-
cmds = ['git']
|
333
|
-
cmds << "clone"
|
334
|
-
cmds << "#{git}"
|
335
|
-
cmds << "#{temp_name} "
|
336
|
-
cmds << "--template="
|
337
|
-
cmds << "--single-branch --depth 1"
|
338
|
-
if branch
|
339
|
-
cmds << "--branch"
|
340
|
-
cmds << branch
|
341
|
-
elsif tag
|
342
|
-
cmds << "--branch"
|
343
|
-
cmds << tag
|
344
|
-
end
|
345
|
-
cmds_to_s = cmds.join(" ")
|
346
|
-
LgPodPlugin.log_blue cmds_to_s
|
347
|
-
system(cmds_to_s)
|
348
|
-
end
|
349
|
-
|
350
|
-
end
|
351
|
-
|
352
|
-
end
|
@@ -1,159 +0,0 @@
|
|
1
|
-
require 'pp'
|
2
|
-
require 'git'
|
3
|
-
require_relative 'l_config'
|
4
|
-
require_relative 'l_util'
|
5
|
-
require_relative 'request'
|
6
|
-
require_relative 'l_cache'
|
7
|
-
require_relative 'net-ping'
|
8
|
-
require_relative 'database'
|
9
|
-
require_relative 'gitlab_archive'
|
10
|
-
|
11
|
-
module LgPodPlugin
|
12
|
-
|
13
|
-
class LGitUtil
|
14
|
-
|
15
|
-
REQUIRED_ATTRS ||= %i[git tag path name commit branch].freeze
|
16
|
-
attr_accessor(*REQUIRED_ATTRS)
|
17
|
-
|
18
|
-
def initialize(name, options = {})
|
19
|
-
self.name = name
|
20
|
-
self.git = options[:git]
|
21
|
-
self.tag = options[:tag]
|
22
|
-
self.path = options[:path]
|
23
|
-
self.branch = options[:branch]
|
24
|
-
self.commit = options[:commit]
|
25
|
-
end
|
26
|
-
|
27
|
-
# clone 代码仓库
|
28
|
-
def git_clone_repository(path)
|
29
|
-
FileUtils.chdir(path)
|
30
|
-
temp_name = "lg_temp_pod"
|
31
|
-
git_archive = GitLabArchive.new(self.name, self.git, self.branch, self.tag, self.commit)
|
32
|
-
if self.git && self.tag
|
33
|
-
begin
|
34
|
-
if LUtils.is_use_gitlab_archive_file(self.git)
|
35
|
-
return git_archive.gitlab_download_tag_zip(path, temp_name)
|
36
|
-
elsif self.git.include?("https://github.com")
|
37
|
-
return git_archive.github_download_tag_zip path, temp_name
|
38
|
-
else
|
39
|
-
return git_archive.git_clone_by_tag(path, temp_name)
|
40
|
-
end
|
41
|
-
rescue
|
42
|
-
return git_archive.git_clone_by_tag(path, temp_name)
|
43
|
-
end
|
44
|
-
elsif self.git && self.branch
|
45
|
-
begin
|
46
|
-
if LUtils.is_use_gitlab_archive_file(self.git)
|
47
|
-
return git_archive.gitlab_download_branch_zip(path, temp_name)
|
48
|
-
elsif self.git.include?("https://github.com")
|
49
|
-
return git_archive.github_download_branch_zip path, temp_name
|
50
|
-
else
|
51
|
-
return git_archive.git_clone_by_branch(path, temp_name)
|
52
|
-
end
|
53
|
-
rescue
|
54
|
-
return git_archive.git_clone_by_branch(path, temp_name)
|
55
|
-
end
|
56
|
-
elsif self.git && self.commit
|
57
|
-
if LUtils.is_use_gitlab_archive_file(self.git)
|
58
|
-
return git_archive.gitlab_download_commit_zip(path, temp_name)
|
59
|
-
elsif self.git.include?("https://github.com")
|
60
|
-
return git_archive.github_download_commit_zip path, temp_name
|
61
|
-
else
|
62
|
-
return git_archive.git_clone_by_commit(path, temp_name)
|
63
|
-
end
|
64
|
-
elsif self.git
|
65
|
-
if LUtils.is_use_gitlab_archive_file(self.git)
|
66
|
-
return git_archive.gitlab_download_branch_zip(path, temp_name)
|
67
|
-
elsif self.git.include?("https://github.com")
|
68
|
-
return git_archive.github_download_branch_zip path, temp_name
|
69
|
-
else
|
70
|
-
return git_archive.git_clone_by_branch(path, temp_name)
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
end
|
75
|
-
|
76
|
-
# git 预下载
|
77
|
-
def pre_download_git_repository
|
78
|
-
temp_path = LFileManager.download_director.join("temp")
|
79
|
-
FileUtils.rm_rf(temp_path) if temp_path.exist?
|
80
|
-
lg_pod_path = LRequest.shared.cache.cache_root
|
81
|
-
lg_pod_path.mkdir(0700) unless lg_pod_path.exist?
|
82
|
-
get_temp_folder = git_clone_repository(lg_pod_path)
|
83
|
-
#下载 git 仓库失败
|
84
|
-
return nil unless (get_temp_folder && get_temp_folder.exist?)
|
85
|
-
LgPodPlugin::LCache.cache_pod(self.name, get_temp_folder, { :git => self.git }) if LRequest.shared.single_git
|
86
|
-
LgPodPlugin::LCache.cache_pod(self.name, get_temp_folder, LRequest.shared.get_cache_key_params)
|
87
|
-
FileUtils.chdir(LFileManager.download_director)
|
88
|
-
FileUtils.rm_rf(lg_pod_path)
|
89
|
-
end
|
90
|
-
|
91
|
-
# 获取最新的一条 commit 信息
|
92
|
-
def self.git_ls_remote_refs(name,git, branch, tag, commit)
|
93
|
-
ip = LRequest.shared.net_ping.ip
|
94
|
-
network_ok = LRequest.shared.net_ping.network_ok
|
95
|
-
return [nil, nil] unless (ip && network_ok)
|
96
|
-
if branch
|
97
|
-
LgPodPlugin.log_blue "git ls-remote #{git} #{branch}"
|
98
|
-
begin
|
99
|
-
result = %x(timeout 5 git ls-remote #{git} #{branch})
|
100
|
-
rescue
|
101
|
-
result = %x(git ls-remote #{git} #{branch})
|
102
|
-
end
|
103
|
-
unless result && result != ""
|
104
|
-
id = LPodLatestRefs.get_pod_id(name, git)
|
105
|
-
pod_info = LSqliteDb.shared.query_pod_refs(id)
|
106
|
-
new_commit = pod_info.commit if pod_info
|
107
|
-
return [branch, new_commit]
|
108
|
-
end
|
109
|
-
new_commit, new_branch = LUtils.commit_from_ls_remote(result, branch)
|
110
|
-
if new_commit
|
111
|
-
LSqliteDb.shared.insert_pod_refs(name, git, branch, tag, new_commit)
|
112
|
-
end
|
113
|
-
return [branch, new_commit]
|
114
|
-
elsif tag
|
115
|
-
LgPodPlugin.log_blue "git ls-remote --tags #{git}"
|
116
|
-
begin
|
117
|
-
result = %x(timeout 5 git ls-remote --tags #{git})
|
118
|
-
rescue
|
119
|
-
result = %x(git ls-remote --tags #{git})
|
120
|
-
end
|
121
|
-
unless result && result != ""
|
122
|
-
id = LPodLatestRefs.get_pod_id(name, git)
|
123
|
-
pod_info = LSqliteDb.shared.query_pod_refs(id)
|
124
|
-
new_commit = pod_info.commit if pod_info
|
125
|
-
new_branch = pod_info.branch if pod_info
|
126
|
-
return [new_branch, new_commit]
|
127
|
-
end
|
128
|
-
new_commit, new_branch = LUtils.commit_from_ls_remote(result, tag)
|
129
|
-
if new_commit
|
130
|
-
LSqliteDb.shared.insert_pod_refs(name, git, branch, tag, new_commit)
|
131
|
-
end
|
132
|
-
return [new_branch, new_commit]
|
133
|
-
elsif commit
|
134
|
-
return nil, commit
|
135
|
-
else
|
136
|
-
LgPodPlugin.log_blue "git ls-remote #{git}"
|
137
|
-
begin
|
138
|
-
result = %x(timeout 5 git ls-remote -- #{git})
|
139
|
-
rescue
|
140
|
-
result = %x(git ls-remote -- #{git})
|
141
|
-
end
|
142
|
-
unless result && result != ""
|
143
|
-
id = LPodLatestRefs.get_pod_id(name, git)
|
144
|
-
pod_info = LSqliteDb.shared.query_pod_refs(id)
|
145
|
-
new_commit = pod_info.commit if pod_info
|
146
|
-
new_branch = pod_info.branch if pod_info
|
147
|
-
return [new_branch, new_commit]
|
148
|
-
end
|
149
|
-
new_commit, new_branch = LUtils.commit_from_ls_remote(result, "HEAD")
|
150
|
-
if new_commit
|
151
|
-
LSqliteDb.shared.insert_pod_refs(name, git, new_branch, tag, new_commit)
|
152
|
-
end
|
153
|
-
return [new_branch, new_commit]
|
154
|
-
end
|
155
|
-
end
|
156
|
-
|
157
|
-
end
|
158
|
-
|
159
|
-
end
|
@@ -1,81 +0,0 @@
|
|
1
|
-
require 'pp'
|
2
|
-
require 'git'
|
3
|
-
require 'cgi'
|
4
|
-
require 'cocoapods'
|
5
|
-
require_relative 'request'
|
6
|
-
require_relative 'database'
|
7
|
-
require_relative 'downloader'
|
8
|
-
require 'cocoapods-core/podfile'
|
9
|
-
require_relative 'release-pod'
|
10
|
-
require_relative 'gitlab_download'
|
11
|
-
require 'cocoapods-core/podfile/target_definition'
|
12
|
-
|
13
|
-
module LgPodPlugin
|
14
|
-
|
15
|
-
class Installer
|
16
|
-
REQUIRED_ATTRS ||= %i[name version options target real_name workspace].freeze
|
17
|
-
attr_accessor(*REQUIRED_ATTRS)
|
18
|
-
|
19
|
-
def initialize(profile, name, requirements)
|
20
|
-
unless name
|
21
|
-
raise StandardError, 'A dependency requires a name.'
|
22
|
-
end
|
23
|
-
if name.include?("/")
|
24
|
-
self.name = name.split("/").first
|
25
|
-
else
|
26
|
-
self.name = name
|
27
|
-
end
|
28
|
-
self.real_name = name
|
29
|
-
self.workspace = profile.send(:defined_in_file).dirname
|
30
|
-
self.target = profile.send(:current_target_definition)
|
31
|
-
unless requirements && requirements.is_a?(Hash)
|
32
|
-
LRequest.shared.libs.delete(name)
|
33
|
-
LRequest.shared.libs.delete(self.real_name)
|
34
|
-
LgPodPlugin.log_red "pod `#{name}`, 缺少必要的 [git|commit|tag|branch] 参数"
|
35
|
-
return
|
36
|
-
end
|
37
|
-
git = requirements[:git]
|
38
|
-
tag = requirements[:tag]
|
39
|
-
commit = requirements[:commit]
|
40
|
-
branch = requirements[:branch]
|
41
|
-
hash_map = Hash.new.merge!(requirements)
|
42
|
-
if git
|
43
|
-
if tag
|
44
|
-
hash_map.delete(:branch)
|
45
|
-
hash_map.delete(:commit)
|
46
|
-
elsif commit
|
47
|
-
hash_map.delete(:tag)
|
48
|
-
hash_map.delete(:branch)
|
49
|
-
elsif branch
|
50
|
-
hash_map.delete(:tag)
|
51
|
-
hash_map.delete(:commit)
|
52
|
-
else
|
53
|
-
hash_map.delete(:tag)
|
54
|
-
hash_map.delete(:branch)
|
55
|
-
hash_map.delete(:commit)
|
56
|
-
end
|
57
|
-
end
|
58
|
-
self.options = hash_map
|
59
|
-
LRequest.shared.setup_pod_info(self.name, self.workspace, hash_map)
|
60
|
-
LRequest.shared.downloader.real_name = self.real_name
|
61
|
-
self.install_remote_pod(name, hash_map)
|
62
|
-
end
|
63
|
-
|
64
|
-
public
|
65
|
-
def install_remote_pod(name, options = {})
|
66
|
-
git = options[:git]
|
67
|
-
if git
|
68
|
-
if LRequest.shared.net_ping && LRequest.shared.net_ping.ip && LRequest.shared.net_ping.network_ok
|
69
|
-
LRequest.shared.downloader.pre_download_pod
|
70
|
-
else
|
71
|
-
LgPodPlugin.log_red "请求#{git} 超时, 下载失败!"
|
72
|
-
end
|
73
|
-
else
|
74
|
-
LRequest.shared.libs.delete(name)
|
75
|
-
LRequest.shared.libs.delete(self.real_name)
|
76
|
-
LgPodPlugin.log_red "pod `#{name}`, 缺少必要的 [git|commit|tag|branch] 参数"
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
|
-
end
|
81
|
-
end
|
@@ -1,83 +0,0 @@
|
|
1
|
-
require 'json'
|
2
|
-
require 'uri'
|
3
|
-
require 'io/console'
|
4
|
-
require_relative 'request'
|
5
|
-
require_relative 'database'
|
6
|
-
require_relative 'gitlab_api'
|
7
|
-
|
8
|
-
module LgPodPlugin
|
9
|
-
|
10
|
-
class LConfig
|
11
|
-
attr_accessor :host
|
12
|
-
attr_accessor :base_url
|
13
|
-
attr_accessor :project_name
|
14
|
-
attr_accessor :access_token
|
15
|
-
attr_accessor :refresh_token
|
16
|
-
attr_accessor :project
|
17
|
-
|
18
|
-
def initialize
|
19
|
-
end
|
20
|
-
|
21
|
-
public
|
22
|
-
def self.getConfig(git)
|
23
|
-
return nil if git.include?("github.com") || git.include?("gitee.com") || git.include?("coding.net") || git.include?("code.aliyun.com")
|
24
|
-
ip_address = LRequest.shared.net_ping.ip
|
25
|
-
network_ok = LRequest.shared.net_ping.network_ok
|
26
|
-
return nil unless ip_address && network_ok
|
27
|
-
if git.include?("ssh") || git.include?("git@gitlab") || git.include?("git@")
|
28
|
-
host = "http://" + ip_address
|
29
|
-
else
|
30
|
-
uri = LRequest.shared.net_ping.uri
|
31
|
-
host = uri ? ("#{uri.scheme}://" + ip_address) : ("http://" + ip_address)
|
32
|
-
end
|
33
|
-
user_id = LUserAuthInfo.get_user_id(host)
|
34
|
-
user_info = LSqliteDb.shared.query_user_info(user_id)
|
35
|
-
unless user_info
|
36
|
-
LgPodPlugin.log_yellow "请输入 `#{uri}` 的用户名"
|
37
|
-
username = STDIN.gets.chomp
|
38
|
-
LgPodPlugin.log_yellow "请输入 `#{uri}` 的密码"
|
39
|
-
password = STDIN.noecho(&:gets).chomp
|
40
|
-
GitLabAPI.request_gitlab_access_token(host, username, password)
|
41
|
-
return nil unless user_info = LSqliteDb.shared.query_user_info(user_id)
|
42
|
-
end
|
43
|
-
|
44
|
-
time = Time.now.to_i
|
45
|
-
# 判断 token 是否失效
|
46
|
-
if user_info.expires_in <= time
|
47
|
-
new_user_info = GitLabAPI.refresh_gitlab_access_token(host, user_info.refresh_token)
|
48
|
-
unless new_user_info
|
49
|
-
username = user_info.username
|
50
|
-
password = user_info.password
|
51
|
-
unless username && password
|
52
|
-
LgPodPlugin.log_yellow "请输入 `#{uri}` 的用户名"
|
53
|
-
username = STDIN.gets.chomp
|
54
|
-
LgPodPlugin.log_yellow "请输入 `#{uri}` 的密码"
|
55
|
-
password = STDIN.noecho(&:gets).chomp
|
56
|
-
end
|
57
|
-
GitLabAPI.request_gitlab_access_token(host, username, password)
|
58
|
-
return nil unless new_user_info = LSqliteDb.shared.query_user_info(user_id)
|
59
|
-
end
|
60
|
-
|
61
|
-
config = LConfig.new
|
62
|
-
config.host = host
|
63
|
-
config.access_token = new_user_info.access_token
|
64
|
-
config.refresh_token = new_user_info.refresh_token
|
65
|
-
config.base_url = LUtils.get_gitlab_base_url(git)
|
66
|
-
config.project_name = LUtils.get_git_project_name(git)
|
67
|
-
config.project = LSqliteDb.shared.query_project_info(config.project_name, git)
|
68
|
-
return config
|
69
|
-
else
|
70
|
-
config = LConfig.new
|
71
|
-
config.host = host
|
72
|
-
config.access_token = user_info.access_token
|
73
|
-
config.refresh_token = user_info.refresh_token
|
74
|
-
config.base_url = LUtils.get_gitlab_base_url(git)
|
75
|
-
config.project_name = LUtils.get_git_project_name(git)
|
76
|
-
config.project = LSqliteDb.shared.query_project_info(config.project_name, git)
|
77
|
-
return config
|
78
|
-
end
|
79
|
-
|
80
|
-
end
|
81
|
-
|
82
|
-
end
|
83
|
-
end
|