lg_pod_plugin 1.1.5.7 → 1.1.5.9

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: ebaf5437bed598ffa64a8ed94863d10c05c0cfcb848e9edbf726ad212662878b
4
+ data.tar.gz: 1e10a6ad2ec5b02e8771a2580db0374d635998320aaa8739bb4bebcf80eba0ba
5
5
  SHA512:
6
- metadata.gz: 0e35116e0824a397cfb7021ed6ffa793d1143f3300b8eab09c827a93e704292ed13b38bab506b8754ad3379d7fc682c34d537516545c2c4e9c89581158f399e3
7
- data.tar.gz: defe217180c036512d189a183d7ad1ce1a20a6b90bbdc56ef957851c55d6bcfee279fbfeb5ce64ac8a762fda002b76c5601ae4f57ad6449e21cfe3984e304c9f
6
+ metadata.gz: 629fa53e19b009413466cd44b9c6ecf28bffcfd7e500524cdf449d4ef6ef0f298a925f7eb0390b734d0937f57712f7cc078227afbe60950d39a923f845b4c026
7
+ data.tar.gz: 7772b927826ef6fe0476db3933e9863b27a98aced13853b58583d3141cdf89c09ff5655e2da90e2258f82e1697155aa2a6c0d24d1bb1729b288df6b6b93578fe
@@ -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
@@ -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
@@ -5,7 +5,6 @@ module LgPodPlugin
5
5
 
6
6
  class LURI
7
7
  public
8
- attr_reader :ip
9
8
  attr_reader :path
10
9
  attr_reader :host
11
10
  attr_reader :scheme
@@ -29,53 +28,63 @@ module LgPodPlugin
29
28
  end
30
29
  end
31
30
  return unless uri
32
- ip_address = getaddress(uri)
33
- return unless ip_address
34
31
  if git.include?("ssh") || git.include?("git@gitlab") || git.include?("git@")
35
- @uri = URI("http://#{ip_address}#{uri.path}")
32
+ redirect_url = get_redirect_url("https://#{uri.host}#{uri.path}")
33
+ @uri = URI(redirect_url)
36
34
  else
37
- @uri = URI("#{uri.scheme}://#{ip_address}#{uri.path}")
35
+ redirect_url = get_redirect_url("#{uri.scheme}://#{uri.host}#{uri.path}")
36
+ @uri = URI(redirect_url)
38
37
  end
39
- @ip = ip_address
40
38
  @host = @uri.host ||= ""
41
39
  @path = @uri.path ||= ""
42
40
  @scheme = @uri.scheme ||= ""
43
41
  @hostname = @scheme + "://" + @host
44
42
  end
45
43
 
46
- private
47
- #判断是否是 IP 地址
48
- def is_address(host)
49
- match = %r{^((2[0-4]\d|25[0-5]|[01]?\d\d?)\.){3}(2[0-4]\d|25[0-5]|[01]?\d\d?)$}.match(host)
50
- !(match.nil?)
51
- end
52
-
53
- # 获取 ip 地址
54
- private
55
- def getaddress(uri)
44
+ def get_redirect_url(host)
45
+ redirect_url = Net::HTTP.get_response(URI(host))['location']
56
46
  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
47
+ uri = URI(redirect_url)
48
+ return uri.scheme + "://" + uri.host
64
49
  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
50
+ return host
76
51
  end
77
52
  end
78
53
 
54
+
55
+ private
56
+ #判断是否是 IP 地址
57
+ # def is_address(host)
58
+ # match = %r{^((2[0-4]\d|25[0-5]|[01]?\d\d?)\.){3}(2[0-4]\d|25[0-5]|[01]?\d\d?)$}.match(host)
59
+ # !(match.nil?)
60
+ # end
61
+
62
+ # 获取 ip 地址
63
+ # private
64
+ # def getaddress(uri)
65
+ # begin
66
+ # if self.is_address(uri.host)
67
+ # ip = uri.host
68
+ # return ip
69
+ # else
70
+ # ip_address = Resolv.getaddress uri.host
71
+ # return ip_address
72
+ # end
73
+ # rescue
74
+ # result = %x(ping #{uri.host} -t 1)
75
+ # return if !result || result == "" || result.include?("timeout")
76
+ # match = %r{\d+.\d+.\d+.\d+}.match(result)
77
+ # return if match.nil?
78
+ # ip_address = match ? match[0] : ""
79
+ # begin
80
+ # return ip_address if IPAddr.new(ip_address)
81
+ # rescue => exception
82
+ # LgPodPlugin.log_red exception
83
+ # return nil
84
+ # end
85
+ # end
86
+ # end
87
+
79
88
  public def to_s
80
89
  return "" unless @uri
81
90
  @uri.to_s
@@ -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.5.9"
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.5.9
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-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cocoapods