dependabot-common 0.162.1 → 0.164.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/dependabot/pull_request_creator/bitbucket.rb +1 -1
- data/lib/dependabot/pull_request_creator/gitlab.rb +20 -18
- data/lib/dependabot/pull_request_creator.rb +2 -1
- data/lib/dependabot/pull_request_updater/gitlab.rb +4 -3
- data/lib/dependabot/pull_request_updater.rb +6 -3
- data/lib/dependabot/shared_helpers.rb +6 -2
- data/lib/dependabot/source.rb +37 -1
- data/lib/dependabot/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7b3537e1c2ef5a4a5120217558ff023781a1bc2530da65e7a37e8f80c75ac710
|
4
|
+
data.tar.gz: 9c11fca086d103b58ff9a532dd342bba154dcd72918c8c3100a662f2bd98dfa0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ff69bb062697827ad9ba6f583dbc6735419ccb1c9f9298dd523e11dcbdfcb134e8129998cb6f7b246356047b04b0ece0ff75c51234f39d9754c52c40139ad5ef
|
7
|
+
data.tar.gz: 83d50bf3ed74365bb964a237de1fa1a8620864890f703bc2619a1e5f0cbee80c039f475a8674cfc333a811c0a9b55b5cd758b8dd04f56d276f758bafc4577489
|
@@ -10,25 +10,26 @@ module Dependabot
|
|
10
10
|
attr_reader :source, :branch_name, :base_commit, :credentials,
|
11
11
|
:files, :pr_description, :pr_name, :commit_message,
|
12
12
|
:author_details, :labeler, :approvers, :assignees,
|
13
|
-
:milestone
|
13
|
+
:milestone, :target_project_id
|
14
14
|
|
15
15
|
def initialize(source:, branch_name:, base_commit:, credentials:,
|
16
16
|
files:, commit_message:, pr_description:, pr_name:,
|
17
17
|
author_details:, labeler:, approvers:, assignees:,
|
18
|
-
milestone:)
|
19
|
-
@source
|
20
|
-
@branch_name
|
21
|
-
@base_commit
|
22
|
-
@credentials
|
23
|
-
@files
|
24
|
-
@commit_message
|
25
|
-
@pr_description
|
26
|
-
@pr_name
|
27
|
-
@author_details
|
28
|
-
@labeler
|
29
|
-
@approvers
|
30
|
-
@assignees
|
31
|
-
@milestone
|
18
|
+
milestone:, target_project_id:)
|
19
|
+
@source = source
|
20
|
+
@branch_name = branch_name
|
21
|
+
@base_commit = base_commit
|
22
|
+
@credentials = credentials
|
23
|
+
@files = files
|
24
|
+
@commit_message = commit_message
|
25
|
+
@pr_description = pr_description
|
26
|
+
@pr_name = pr_name
|
27
|
+
@author_details = author_details
|
28
|
+
@labeler = labeler
|
29
|
+
@approvers = approvers
|
30
|
+
@assignees = assignees
|
31
|
+
@milestone = milestone
|
32
|
+
@target_project_id = target_project_id
|
32
33
|
end
|
33
34
|
|
34
35
|
def create
|
@@ -76,7 +77,7 @@ module Dependabot
|
|
76
77
|
|
77
78
|
def merge_request_exists?
|
78
79
|
gitlab_client_for_source.merge_requests(
|
79
|
-
source.repo,
|
80
|
+
target_project_id || source.repo,
|
80
81
|
source_branch: branch_name,
|
81
82
|
target_branch: source.branch || default_branch,
|
82
83
|
state: "all"
|
@@ -143,7 +144,8 @@ module Dependabot
|
|
143
144
|
remove_source_branch: true,
|
144
145
|
assignee_ids: assignees,
|
145
146
|
labels: labeler.labels_for_pr.join(","),
|
146
|
-
milestone_id: milestone
|
147
|
+
milestone_id: milestone,
|
148
|
+
target_project_id: target_project_id
|
147
149
|
)
|
148
150
|
end
|
149
151
|
|
@@ -156,7 +158,7 @@ module Dependabot
|
|
156
158
|
approvers.keys.map { |k| [k.to_sym, approvers[k]] }.to_h
|
157
159
|
|
158
160
|
gitlab_client_for_source.edit_merge_request_approvers(
|
159
|
-
source.repo,
|
161
|
+
target_project_id || source.repo,
|
160
162
|
merge_request.iid,
|
161
163
|
approver_ids: approvers_hash[:approvers],
|
162
164
|
approver_group_ids: approvers_hash[:group_approvers]
|
@@ -8,16 +8,17 @@ module Dependabot
|
|
8
8
|
class PullRequestUpdater
|
9
9
|
class Gitlab
|
10
10
|
attr_reader :source, :files, :base_commit, :old_commit, :credentials,
|
11
|
-
:pull_request_number
|
11
|
+
:pull_request_number, :target_project_id
|
12
12
|
|
13
13
|
def initialize(source:, base_commit:, old_commit:, files:,
|
14
|
-
credentials:, pull_request_number:)
|
14
|
+
credentials:, pull_request_number:, target_project_id:)
|
15
15
|
@source = source
|
16
16
|
@base_commit = base_commit
|
17
17
|
@old_commit = old_commit
|
18
18
|
@files = files
|
19
19
|
@credentials = credentials
|
20
20
|
@pull_request_number = pull_request_number
|
21
|
+
@target_project_id = target_project_id
|
21
22
|
end
|
22
23
|
|
23
24
|
def update
|
@@ -39,7 +40,7 @@ module Dependabot
|
|
39
40
|
|
40
41
|
def merge_request
|
41
42
|
@merge_request ||= gitlab_client_for_source.merge_request(
|
42
|
-
source.repo,
|
43
|
+
target_project_id || source.repo,
|
43
44
|
pull_request_number
|
44
45
|
)
|
45
46
|
end
|
@@ -9,11 +9,12 @@ module Dependabot
|
|
9
9
|
class BranchProtected < StandardError; end
|
10
10
|
|
11
11
|
attr_reader :source, :files, :base_commit, :old_commit, :credentials,
|
12
|
-
:pull_request_number, :author_details, :signature_key
|
12
|
+
:pull_request_number, :author_details, :signature_key, :provider_metadata
|
13
13
|
|
14
14
|
def initialize(source:, base_commit:, old_commit:, files:,
|
15
15
|
credentials:, pull_request_number:,
|
16
|
-
author_details: nil, signature_key: nil
|
16
|
+
author_details: nil, signature_key: nil,
|
17
|
+
provider_metadata: {})
|
17
18
|
@source = source
|
18
19
|
@base_commit = base_commit
|
19
20
|
@old_commit = old_commit
|
@@ -22,6 +23,7 @@ module Dependabot
|
|
22
23
|
@pull_request_number = pull_request_number
|
23
24
|
@author_details = author_details
|
24
25
|
@signature_key = signature_key
|
26
|
+
@provider_metadata = provider_metadata
|
25
27
|
end
|
26
28
|
|
27
29
|
def update
|
@@ -55,7 +57,8 @@ module Dependabot
|
|
55
57
|
old_commit: old_commit,
|
56
58
|
files: files,
|
57
59
|
credentials: credentials,
|
58
|
-
pull_request_number: pull_request_number
|
60
|
+
pull_request_number: pull_request_number,
|
61
|
+
target_project_id: provider_metadata[:target_project_id]
|
59
62
|
)
|
60
63
|
end
|
61
64
|
|
@@ -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)
|
44
|
-
|
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
|
|
data/lib/dependabot/source.rb
CHANGED
@@ -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")
|
data/lib/dependabot/version.rb
CHANGED
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.
|
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-
|
11
|
+
date: 2021-11-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|