Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions dependabot_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
# Define data structure for dependabot.yaml
data = {
"version": 2,
"registries": {},
"updates": [],
}

Expand Down Expand Up @@ -60,8 +59,6 @@ def make_dependabot_config(
dependabot_config["updates"][-1].update(
{"registries": [SingleQuotedScalarString(ecosystem)]}
)
else:
dependabot_config.pop("registries", None)

if schedule_day:
dependabot_config["updates"][-1].update(
Expand Down
50 changes: 50 additions & 0 deletions test_dependabot_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -819,6 +819,56 @@ def test_build_dependabot_file_with_labels(self):
)
self.assertEqual(result, expected_result)

def test_build_dependabot_file_preserves_existing_registries(self):
"""Test that existing registries are preserved when adding new ecosystems"""
repo = MagicMock()
repo.file_contents.side_effect = lambda filename: filename == "Gemfile"

# Create existing config with registries but no bundler ecosystem
existing_config = MagicMock()
existing_config.content = base64.b64encode(
b"""
version: 2
registries:
gradle-artifactory:
type: maven-repository
url: https://acme.jfrog.io/artifactory/my-gradle-registry
username: octocat
password: ${{secrets.MY_ARTIFACTORY_PASSWORD}}
updates:
- package-ecosystem: "npm"
directory: "/"
schedule:
interval: "weekly"
"""
)

expected_result = yaml.load(
b"""
version: 2
registries:
gradle-artifactory:
type: maven-repository
url: https://acme.jfrog.io/artifactory/my-gradle-registry
username: octocat
password: ${{secrets.MY_ARTIFACTORY_PASSWORD}}
updates:
- package-ecosystem: "npm"
directory: "/"
schedule:
interval: "weekly"
- package-ecosystem: 'bundler'
directory: '/'
schedule:
interval: 'weekly'
"""
)

result = build_dependabot_file(
repo, False, [], {}, existing_config, "weekly", "", [], None
)
self.assertEqual(result, expected_result)


if __name__ == "__main__":
unittest.main()
Loading