Skip to content

Commit f4a8eec

Browse files
Copilotzkoppert
andcommitted
Fix registries deletion bug and add regression test
Co-authored-by: zkoppert <6935431+zkoppert@users.noreply.github.com>
1 parent 0c163d5 commit f4a8eec

File tree

2 files changed

+50
-3
lines changed

2 files changed

+50
-3
lines changed

dependabot_file.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
# Define data structure for dependabot.yaml
1212
data = {
1313
"version": 2,
14-
"registries": {},
1514
"updates": [],
1615
}
1716

@@ -60,8 +59,6 @@ def make_dependabot_config(
6059
dependabot_config["updates"][-1].update(
6160
{"registries": [SingleQuotedScalarString(ecosystem)]}
6261
)
63-
else:
64-
dependabot_config.pop("registries", None)
6562

6663
if schedule_day:
6764
dependabot_config["updates"][-1].update(

test_dependabot_file.py

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -819,6 +819,56 @@ def test_build_dependabot_file_with_labels(self):
819819
)
820820
self.assertEqual(result, expected_result)
821821

822+
def test_build_dependabot_file_preserves_existing_registries(self):
823+
"""Test that existing registries are preserved when adding new ecosystems"""
824+
repo = MagicMock()
825+
repo.file_contents.side_effect = lambda filename: filename == "Gemfile"
826+
827+
# Create existing config with registries but no bundler ecosystem
828+
existing_config = MagicMock()
829+
existing_config.content = base64.b64encode(
830+
b"""
831+
version: 2
832+
registries:
833+
gradle-artifactory:
834+
type: maven-repository
835+
url: https://acme.jfrog.io/artifactory/my-gradle-registry
836+
username: octocat
837+
password: ${{secrets.MY_ARTIFACTORY_PASSWORD}}
838+
updates:
839+
- package-ecosystem: "npm"
840+
directory: "/"
841+
schedule:
842+
interval: "weekly"
843+
"""
844+
)
845+
846+
expected_result = yaml.load(
847+
b"""
848+
version: 2
849+
registries:
850+
gradle-artifactory:
851+
type: maven-repository
852+
url: https://acme.jfrog.io/artifactory/my-gradle-registry
853+
username: octocat
854+
password: ${{secrets.MY_ARTIFACTORY_PASSWORD}}
855+
updates:
856+
- package-ecosystem: "npm"
857+
directory: "/"
858+
schedule:
859+
interval: "weekly"
860+
- package-ecosystem: 'bundler'
861+
directory: '/'
862+
schedule:
863+
interval: 'weekly'
864+
"""
865+
)
866+
867+
result = build_dependabot_file(
868+
repo, False, [], {}, existing_config, "weekly", "", [], None
869+
)
870+
self.assertEqual(result, expected_result)
871+
822872

823873
if __name__ == "__main__":
824874
unittest.main()

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy