Skip to content

fix: Fix registries deletion when adding new ecosystems to dependabot.yml #378

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jul 21, 2025
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
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