lg_pod_plugin 1.1.5.7 → 1.1.6.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ce8fcf508c4622d896bc35d848db7c9d8238648722e38cde3dca35f5b30a5c42
4
- data.tar.gz: 756567c34b08dc9d99af1f8f9c4fd8a3adf527d60afd4155315ed4c2e7a89616
3
+ metadata.gz: 8cf74181198e5c879bdbf6ef84ca2de6286d56fa355665a9f68db20fda87b9ba
4
+ data.tar.gz: bc480be0ff2a011c60aa23a48355c03c6b329c0a6360708c9c7aa5e1a26b44a2
5
5
  SHA512:
6
- metadata.gz: 0e35116e0824a397cfb7021ed6ffa793d1143f3300b8eab09c827a93e704292ed13b38bab506b8754ad3379d7fc682c34d537516545c2c4e9c89581158f399e3
7
- data.tar.gz: defe217180c036512d189a183d7ad1ce1a20a6b90bbdc56ef957851c55d6bcfee279fbfeb5ce64ac8a762fda002b76c5601ae4f57ad6449e21cfe3984e304c9f
6
+ metadata.gz: ce2163d8778eb68adef6fec76595ba9a2cd66be2abea079011c8294155b30f84d48bc659dc510f27e046a1637a9e554357e81d3ceb5cb0a45a11e23f364d34f7
7
+ data.tar.gz: 79005659b57432323474fc0237f1c0e01aff28602d6d72cd349e42f8e6ef755b2fc09519f3f577c4a483d17275cc2dac4bd0491d776a349aefbf32d8ceab234c
@@ -23,7 +23,7 @@ module LgPodPlugin
23
23
  user_info = LSqliteDb.shared.query_user_info(user_id)
24
24
  # 用户授权 token 不存在, 提示用户输入用户名密码
25
25
  unless user_info
26
- user_info = GitLabAPI.get_gitlab_access_token_input(uri, user_id, nil, nil)
26
+ user_info = GitLabAPI.get_gitlab_access_token_input(uri, user_id,nil ,nil )
27
27
  return nil unless user_info
28
28
  end
29
29
  time_now = Time.now.to_i
@@ -4,10 +4,11 @@ module LgPodPlugin
4
4
  class LPodTarget
5
5
  attr_reader :name
6
6
  attr_reader :dependencies
7
+ attr_reader :internal_hash
7
8
  def initialize(target)
8
- internal_hash = target.send(:internal_hash)
9
- @name = internal_hash["name"]
10
- array = Array.new(internal_hash['dependencies'] ||= [])
9
+ @internal_hash = target.send(:internal_hash)
10
+ @name = @internal_hash["name"]
11
+ array = Array.new(@internal_hash['dependencies'] ||= [])
11
12
  dependencies = array.reject do |e|
12
13
  if LUtils.is_a_string?(e)
13
14
  true
@@ -29,5 +30,6 @@ module LgPodPlugin
29
30
  end
30
31
  @dependencies = external_pods
31
32
  end
33
+
32
34
  end
33
35
  end
@@ -49,13 +49,13 @@ module LgPodPlugin
49
49
  LgPodPlugin.log_green "Using `#{name}`"
50
50
  end
51
51
  hash_map = self.request.get_cache_key_params
52
+ self.request.checkout_options.delete(:branch) if commit
53
+ self.request.checkout_options[:commit] = commit if commit
52
54
  # 发现本地有缓存, 不需要更新缓存
53
55
  pod_is_exist, destination, cache_pod_spec = LCache.new.pod_cache_exist(name, hash_map, podspec, self.request.released_pod)
54
56
  if pod_is_exist
55
57
  is_delete = self.request.params["is_delete"] ||= false
56
58
  LProject.shared.need_update_pods.delete(name) if is_delete
57
- self.request.checkout_options.delete(:branch) if commit
58
- self.request.checkout_options[:commit] = commit if commit
59
59
  LgPodPlugin.log_green "find the cache of `#{name}`, you can use it now."
60
60
  nil
61
61
  else
@@ -106,8 +106,6 @@ module LgPodPlugin
106
106
  LgPodPlugin::LCache.cache_pod(name, download_params, self.request.get_cache_key_params,podspec, self.request.released_pod)
107
107
  FileUtils.chdir(LFileManager.download_director)
108
108
  FileUtils.rm_rf(download_params)
109
- self.request.checkout_options.delete(:branch) if commit
110
- self.request.checkout_options[:commit] = commit if commit
111
109
  end
112
110
  nil
113
111
  end
@@ -27,19 +27,10 @@ module LgPodPlugin
27
27
  uri = URI("#{host}/oauth/token")
28
28
  hash_map = { "grant_type" => "password", "username" => username, "password" => password }
29
29
  LgPodPlugin.log_green "开始请求 access_token, url => #{uri.to_s} "
30
- req = Net::HTTP::Post.new(uri)
31
- req.set_form_data(hash_map)
32
- res = Net::HTTP.start((uri.hostname ||= ""), uri.port) do |http|
33
- http.open_timeout = 15
34
- http.read_timeout = 15
35
- http.request(req)
36
- end
37
- case res
38
- when Net::HTTPSuccess, Net::HTTPRedirection
39
- json = JSON.parse(res.body)
40
- else
41
- json = JSON.parse(res.body)
42
- error = json["error"]
30
+ req = Net::HTTP.post_form(uri, hash_map)
31
+ json = JSON.parse(req.body)
32
+ error = json["error"]
33
+ if error != nil
43
34
  if error == "invalid_grant"
44
35
  LSqliteDb.shared.delete_user_info(user_id)
45
36
  end
@@ -195,34 +186,7 @@ module LgPodPlugin
195
186
  end
196
187
  end
197
188
 
198
- #获取项目中仓库文件和目录的列表
199
- # def self.get_gitlab_repository_tree(host, token, project_id, sha)
200
- # begin
201
- # hash_map = Hash.new
202
- # hash_map["ref"] = sha
203
- # hash_map["access_token"] = token
204
- # hash_map["per_page"] = 50
205
- # uri = URI("#{host}/api/v4/projects/#{project_id}/repository/tree")
206
- # uri.query = URI.encode_www_form(hash_map)
207
- # res = Net::HTTP.get_response(uri)
208
- # if res.body
209
- # array = JSON.parse(res.body)
210
- # else
211
- # array = nil
212
- # end
213
- # return Set.new unless array && array.is_a?(Array)
214
- # files = array.collect { |dict|
215
- # dict["path"]
216
- # }
217
- # set = Set.new.merge files
218
- # return set
219
- # rescue
220
- # return Set.new
221
- # end
222
- # end
223
-
224
189
  public
225
-
226
190
  def self.get_podspec_file_content(host, token, project_id, sha, filepath)
227
191
  begin
228
192
  hash_map = Hash.new
@@ -64,8 +64,6 @@ module LgPodPlugin
64
64
  if pod_is_exist
65
65
  is_delete = request.params["is_delete"] ||= false
66
66
  LProject.shared.need_update_pods.delete(name) if is_delete
67
- request.checkout_options.delete(:branch) if commit
68
- request.checkout_options[:commit] = commit if commit
69
67
  else
70
68
  git = checkout_options[:git]
71
69
  return unless git
@@ -91,8 +89,6 @@ module LgPodPlugin
91
89
  end
92
90
  FileUtils.chdir(LFileManager.download_director)
93
91
  FileUtils.rm_rf(download_params)
94
- request.checkout_options.delete(:branch) if commit
95
- request.checkout_options[:commit] = commit if commit
96
92
  end
97
93
 
98
94
  end
@@ -19,7 +19,7 @@ module LgPodPlugin
19
19
 
20
20
  public
21
21
  def self.run(command, options = {})
22
- self.clean_sandbox
22
+ clean_sandbox()
23
23
  workspace = Pathname(Dir.pwd)
24
24
  update = (command == "update")
25
25
  LSqliteDb.shared.init_database
@@ -16,6 +16,7 @@ module LgPodPlugin
16
16
  attr_reader :external_pods
17
17
  attr_reader :need_update_pods
18
18
  attr_accessor :cache_specs
19
+ attr_accessor :redirect_url_hash
19
20
  def setup(workspace,podfile_path, update, repo_update)
20
21
  @podfile = Pod::Podfile.from_file(podfile_path)
21
22
  @update = update
@@ -35,7 +36,8 @@ module LgPodPlugin
35
36
  @cache_specs = Hash.new
36
37
  @external_pods = Hash.new.merge!(external_pods)
37
38
  @need_update_pods = Hash.new.merge!(external_pods)
38
- self
39
+ @redirect_url_hash = Hash.new
40
+ return self
39
41
  end
40
42
 
41
43
  def self.shared
@@ -5,8 +5,7 @@ module LgPodPlugin
5
5
 
6
6
  class LURI
7
7
  public
8
- attr_reader :ip
9
- attr_reader :path
8
+ # attr_reader :path
10
9
  attr_reader :host
11
10
  attr_reader :scheme
12
11
  attr_reader :hostname
@@ -14,35 +13,41 @@ module LgPodPlugin
14
13
  attr_reader :uri
15
14
  public
16
15
  def initialize(git)
17
- begin
18
- uri = URI(git)
19
- rescue => exception
20
- if git.include?("git@") && git.include?(":")
21
- match = %r{(?<=git@).*?(?=:)}.match(git)
22
- host = match ? match[0] : ""
16
+ if git.include?("git@") && git.include?(":")
17
+ match = %r{(?<=git@).*?(?=:)}.match(git)
18
+ host = match ? match[0] : ""
19
+ if is_address(host)
23
20
  base_url = LUtils.get_gitlab_base_url(git)
24
21
  path = base_url.split(":").last
25
- uri = URI("http://#{host}/#{path}")
22
+ origin_uri = URI("http://#{host}/#{path}")
26
23
  else
27
- LgPodPlugin.log_red exception
28
- uri = nil
24
+ base_url = LUtils.get_gitlab_base_url(git)
25
+ path = base_url.split(":").last
26
+ origin_uri = URI("https://#{host}/#{path}")
29
27
  end
28
+ else
29
+ origin_uri = URI(git)
30
30
  end
31
- return unless uri
32
- ip_address = getaddress(uri)
33
- return unless ip_address
34
- if git.include?("ssh") || git.include?("git@gitlab") || git.include?("git@")
35
- @uri = URI("http://#{ip_address}#{uri.path}")
31
+ return if origin_uri.nil?
32
+ redirect_url = LProject.shared.redirect_url_hash[origin_uri.host]
33
+ if redirect_url
34
+ @uri = redirect_url
36
35
  else
37
- @uri = URI("#{uri.scheme}://#{ip_address}#{uri.path}")
36
+ @uri = URI(get_redirect_url(origin_uri.scheme + "://" + origin_uri.host))
37
+ LProject.shared.redirect_url_hash[origin_uri.host] = @uri
38
38
  end
39
- @ip = ip_address
40
- @host = @uri.host ||= ""
41
- @path = @uri.path ||= ""
42
- @scheme = @uri.scheme ||= ""
39
+ @host = @uri.host
40
+ @scheme = @uri.scheme ||= "https"
43
41
  @hostname = @scheme + "://" + @host
44
42
  end
45
43
 
44
+ def get_redirect_url(host)
45
+ redirect_url = Net::HTTP.get_response(URI(host))['location']
46
+ return host unless redirect_url
47
+ uri = URI(redirect_url)
48
+ return uri.scheme + "://" + uri.host
49
+ end
50
+
46
51
  private
47
52
  #判断是否是 IP 地址
48
53
  def is_address(host)
@@ -51,30 +56,30 @@ module LgPodPlugin
51
56
  end
52
57
 
53
58
  # 获取 ip 地址
54
- private
55
- def getaddress(uri)
56
- begin
57
- if self.is_address(uri.host)
58
- ip = uri.host
59
- return ip
60
- else
61
- ip_address = Resolv.getaddress uri.host
62
- return ip_address
63
- end
64
- rescue
65
- result = %x(ping #{uri.host} -t 1)
66
- return if !result || result == "" || result.include?("timeout")
67
- match = %r{\d+.\d+.\d+.\d+}.match(result)
68
- return if match.nil?
69
- ip_address = match ? match[0] : ""
70
- begin
71
- return ip_address if IPAddr.new(ip_address)
72
- rescue => exception
73
- LgPodPlugin.log_red exception
74
- return nil
75
- end
76
- end
77
- end
59
+ # private
60
+ # def getaddress(uri)
61
+ # begin
62
+ # if self.is_address(uri.host)
63
+ # ip = uri.host
64
+ # return ip
65
+ # else
66
+ # ip_address = Resolv.getaddress uri.host
67
+ # return ip_address
68
+ # end
69
+ # rescue
70
+ # result = %x(ping #{uri.host} -t 1)
71
+ # return if !result || result == "" || result.include?("timeout")
72
+ # match = %r{\d+.\d+.\d+.\d+}.match(result)
73
+ # return if match.nil?
74
+ # ip_address = match ? match[0] : ""
75
+ # begin
76
+ # return ip_address if IPAddr.new(ip_address)
77
+ # rescue => exception
78
+ # LgPodPlugin.log_red exception
79
+ # return nil
80
+ # end
81
+ # end
82
+ # end
78
83
 
79
84
  public def to_s
80
85
  return "" unless @uri
@@ -12,7 +12,7 @@ module LgPodPlugin
12
12
  uri = LURI.new(url)
13
13
  if uri.host
14
14
  self.uri = uri
15
- self.ip = uri.ip
15
+ self.ip = uri.host
16
16
  self.network_ok = true
17
17
  else
18
18
  self.uri = nil
@@ -1,3 +1,3 @@
1
1
  module LgPodPlugin
2
- VERSION = "1.1.5.7"
2
+ VERSION = "1.1.6.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lg_pod_plugin
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.5.7
4
+ version: 1.1.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - dongzb01
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-02-08 00:00:00.000000000 Z
11
+ date: 2023-02-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cocoapods