dependabot-common 0.164.0 → 0.164.1

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: 15d09c789245d49223db4df88b82fa3376f9ca598b926ce44e9c10018d0442c1
4
- data.tar.gz: 9e6ed02b46b8cbe7b574a515abf1179b136d0501b657620d187914f9f29b7e7a
3
+ metadata.gz: 7b3537e1c2ef5a4a5120217558ff023781a1bc2530da65e7a37e8f80c75ac710
4
+ data.tar.gz: 9c11fca086d103b58ff9a532dd342bba154dcd72918c8c3100a662f2bd98dfa0
5
5
  SHA512:
6
- metadata.gz: 0a47e494cd76b7569d4fba0212f188f2b401fd087f70cc44b94f39ad16650edcacf90440200e6d16f0978c84d832d97eb24d892d8f74a38607b875b932f8eb1c
7
- data.tar.gz: 89cac44d3a3febd767e78146deba6758b821c0d61bded08856c098117f2388a052e6063a879282a75f4346727517374ed936af5b78975ea7ab68ffbd1d4c3eed
6
+ metadata.gz: ff69bb062697827ad9ba6f583dbc6735419ccb1c9f9298dd523e11dcbdfcb134e8129998cb6f7b246356047b04b0ece0ff75c51234f39d9754c52c40139ad5ef
7
+ data.tar.gz: 83d50bf3ed74365bb964a237de1fa1a8620864890f703bc2619a1e5f0cbee80c039f475a8674cfc333a811c0a9b55b5cd758b8dd04f56d276f758bafc4577489
@@ -40,10 +40,14 @@ module Dependabot
40
40
 
41
41
  def self.in_a_temporary_directory(directory = "/")
42
42
  Dir.mkdir(Utils::BUMP_TMP_DIR_PATH) unless Dir.exist?(Utils::BUMP_TMP_DIR_PATH)
43
- Dir.mktmpdir(Utils::BUMP_TMP_FILE_PREFIX, Utils::BUMP_TMP_DIR_PATH) do |dir|
44
- path = Pathname.new(File.join(dir, directory)).expand_path
43
+ tmp_dir = Dir.mktmpdir(Utils::BUMP_TMP_FILE_PREFIX, Utils::BUMP_TMP_DIR_PATH)
44
+
45
+ begin
46
+ path = Pathname.new(File.join(tmp_dir, directory)).expand_path
45
47
  FileUtils.mkpath(path)
46
48
  Dir.chdir(path) { yield(path) }
49
+ ensure
50
+ FileUtils.rm_rf(tmp_dir)
47
51
  end
48
52
  end
49
53
 
@@ -9,6 +9,15 @@ module Dependabot
9
9
  (?:(?:/tree|/blob)/(?<branch>[^/]+)/(?<directory>.*)[\#|/])?
10
10
  }x.freeze
11
11
 
12
+ GITHUB_ENTERPRISE_SOURCE = %r{
13
+ (?<protocol>(http://|https://|git://|ssh://))*
14
+ (?<username>[^@]+@)*
15
+ (?<host>[^/]+)
16
+ [/:]
17
+ (?<repo>[\w.-]+/(?:(?!\.git|\.\s)[\w.-])+)
18
+ (?:(?:/tree|/blob)/(?<branch>[^/]+)/(?<directory>.*)[\#|/])?
19
+ }x.freeze
20
+
12
21
  GITLAB_SOURCE = %r{
13
22
  (?<provider>gitlab)
14
23
  (?:\.com)[/:]
@@ -40,7 +49,7 @@ module Dependabot
40
49
  :hostname, :api_endpoint
41
50
 
42
51
  def self.from_url(url_string)
43
- return unless url_string&.match?(SOURCE_REGEX)
52
+ return github_enterprise_from_url(url_string) unless url_string&.match?(SOURCE_REGEX)
44
53
 
45
54
  captures = url_string.match(SOURCE_REGEX).named_captures
46
55
 
@@ -52,6 +61,33 @@ module Dependabot
52
61
  )
53
62
  end
54
63
 
64
+ def self.github_enterprise_from_url(url_string)
65
+ captures = url_string&.match(GITHUB_ENTERPRISE_SOURCE)&.named_captures
66
+ return unless captures
67
+
68
+ base_url = "https://#{captures.fetch('host')}"
69
+
70
+ return unless github_enterprise?(base_url)
71
+
72
+ new(
73
+ provider: "github",
74
+ repo: captures.fetch("repo"),
75
+ directory: captures.fetch("directory"),
76
+ branch: captures.fetch("branch"),
77
+ hostname: captures.fetch("host"),
78
+ api_endpoint: File.join(base_url, "api", "v3")
79
+ )
80
+ end
81
+
82
+ def self.github_enterprise?(base_url)
83
+ resp = Excon.get(File.join(base_url, "status"))
84
+ resp.status == 200 &&
85
+ # Alternatively: resp.headers["Server"] == "GitHub.com", but this
86
+ # currently doesn't work with development environments
87
+ resp.headers["X-GitHub-Request-Id"] &&
88
+ !resp.headers["X-GitHub-Request-Id"].empty?
89
+ end
90
+
55
91
  def initialize(provider:, repo:, directory: nil, branch: nil, commit: nil,
56
92
  hostname: nil, api_endpoint: nil)
57
93
  if (hostname.nil? ^ api_endpoint.nil?) && (provider != "codecommit")
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Dependabot
4
- VERSION = "0.164.0"
4
+ VERSION = "0.164.1"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dependabot-common
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.164.0
4
+ version: 0.164.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dependabot
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-10-27 00:00:00.000000000 Z
11
+ date: 2021-11-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport