Skip to content

Commit 0f5eabc

Browse files
authored
Merge pull request #13478 from dependabot/markhallen/add-maven-install-json-for-bazel
Enable the inclusion of maven_install.json files in the temporary folder during Bazel sync operations.
2 parents 9719e70 + f16cabc commit 0f5eabc

File tree

4 files changed

+66
-5
lines changed

4 files changed

+66
-5
lines changed

bazel/lib/dependabot/bazel/file_fetcher.rb

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class FileFetcher < Dependabot::FileFetchers::Base
1111

1212
WORKSPACE_FILES = T.let(%w(WORKSPACE WORKSPACE.bazel).freeze, T::Array[String])
1313
MODULE_FILES = T.let(%w(MODULE.bazel).freeze, T::Array[String])
14-
CONFIG_FILES = T.let(%w(.bazelrc MODULE.bazel.lock).freeze, T::Array[String])
14+
CONFIG_FILES = T.let(%w(.bazelrc MODULE.bazel.lock .bazelversion maven_install.json).freeze, T::Array[String])
1515
SKIP_DIRECTORIES = T.let(%w(.git .bazel-* bazel-* node_modules .github).freeze, T::Array[String])
1616

1717
sig { override.returns(String) }
@@ -86,14 +86,11 @@ def module_files
8686
def config_files
8787
files = T.let([], T::Array[DependencyFile])
8888

89-
CONFIG_FILES.each do |filename|
89+
CONFIG_FILES.map do |filename|
9090
file = fetch_file_if_present(filename)
9191
files << file if file
9292
end
9393

94-
bazelversion = fetch_file_if_present(".bazelversion")
95-
files << bazelversion if bazelversion
96-
9794
files
9895
end
9996

bazel/spec/dependabot/bazel/file_fetcher_spec.rb

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,29 @@
113113
it "fetches the MODULE.bazel file" do
114114
expect(fetched_files.map(&:name)).to include("MODULE.bazel")
115115
end
116+
117+
context "with a maven_install.json file" do
118+
before do
119+
stub_request(:get, url + "?ref=sha")
120+
.to_return(
121+
status: 200,
122+
body: fixture("github", "contents_bazel_with_maven_install.json"),
123+
headers: { "content-type" => "application/json" }
124+
)
125+
126+
stub_request(:get, url + "maven_install.json?ref=sha")
127+
.to_return(
128+
status: 200,
129+
body: fixture("github", "contents_bazel_maven_install.json"),
130+
headers: { "content-type" => "application/json" }
131+
)
132+
end
133+
134+
it "includes maven_install.json" do
135+
puts "files: #{fetched_files.map(&:name)}"
136+
expect(fetched_files.map(&:name)).to include("maven_install.json")
137+
end
138+
end
116139
end
117140

118141
context "when beta ecosystems are not allowed" do
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"name": "maven_install.json",
3+
"path": "maven_install.json",
4+
"sha": "abc123",
5+
"size": 1234,
6+
"url": "https://api.github.com/repos/example/repo/contents/maven_install.json?ref=sha",
7+
"html_url": "https://github.com/example/repo/blob/sha/maven_install.json",
8+
"git_url": "https://api.github.com/repos/example/repo/git/blobs/abc123",
9+
"download_url": "https://raw.githubusercontent.com/example/repo/sha/maven_install.json",
10+
"type": "file",
11+
"content": "bW9kdWxlKG5hbWUgPSAiZXhhbXBsZSIsIHZlcnNpb24gPSAiMS4wLjAiKQ==\n",
12+
"encoding": "base64"
13+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
[
2+
{
3+
"name": "MODULE.bazel",
4+
"path": "MODULE.bazel",
5+
"sha": "abc123",
6+
"size": 1234,
7+
"url": "https://api.github.com/repos/example/repo/contents/MODULE.bazel?ref=sha",
8+
"html_url": "https://github.com/example/repo/blob/sha/MODULE.bazel",
9+
"git_url": "https://api.github.com/repos/example/repo/git/blobs/abc123",
10+
"download_url": "https://raw.githubusercontent.com/example/repo/sha/MODULE.bazel",
11+
"type": "file",
12+
"content": "bW9kdWxlKG5hbWUgPSAiZXhhbXBsZSIsIHZlcnNpb24gPSAiMS4wLjAiKQ==\n",
13+
"encoding": "base64"
14+
},
15+
{
16+
"name": "maven_install.json",
17+
"path": "maven_install.json",
18+
"sha": "abc123",
19+
"size": 1234,
20+
"url": "https://api.github.com/repos/example/repo/contents/maven_install.json?ref=sha",
21+
"html_url": "https://github.com/example/repo/blob/sha/maven_install.json",
22+
"git_url": "https://api.github.com/repos/example/repo/git/blobs/abc123",
23+
"download_url": "https://raw.githubusercontent.com/example/repo/sha/maven_install.json",
24+
"type": "file",
25+
"content": "bW9kdWxlKG5hbWUgPSAiZXhhbXBsZSIsIHZlcnNpb24gPSAiMS4wLjAiKQ==\n",
26+
"encoding": "base64"
27+
}
28+
]

0 commit comments

Comments
 (0)