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
9 changes: 8 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,14 @@ Changelog
2.0.5 (unreleased)
------------------

* Add ``subpath`` option to specify a subdirectory of a repository. [mamico]
- Allow a later source option to override an earlier one instead of raising
``ValueError: Key '...' already in source info.``. This lets a ``[sources]``
entry refine a shared/extended definition, e.g. ``foo += branch=my-feature``
overriding the ``branch`` set upstream. Fixes `#125
<https://github.com/fschulze/mr.developer/issues/125>`_.
[janjaapdriessen]

- Add ``subpath`` option to specify a subdirectory of a repository. [mamico]


2.0.4 (2025-07-17)
Expand Down
6 changes: 5 additions & 1 deletion src/mr/developer/extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,11 @@ def get_sources(self):
if not key:
raise ValueError("Option with no name '%s'." % option)
if key in source:
raise ValueError("Key '%s' already in source info." % key)
# A later option overrides an earlier one, e.g.
# ``foo += branch=my-feature`` refining the ``branch`` set
# in a shared/extended source definition.
logger.info(
"Overriding '%s' for source '%s'." % (key, name))
if key == 'path':
value = os.path.join(value, name)
if not os.path.isabs(value):
Expand Down
13 changes: 7 additions & 6 deletions src/mr/developer/tests/test_extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,15 +218,16 @@ def testOptionParsingBeforeURL(self, buildout, extension):
assert sources['pkg.foo']['rev'] == '>=456ad138'

def testDuplicateOptionParsing(self, buildout, extension):
# A duplicate option is not an error: the later value wins, so a
# ``+=`` addition can override a value from a shared source definition
# (e.g. ``pkg.foo += branch=feature``).
buildout['sources'].update({
'pkg.foo': 'git dummy://foo/trunk rev=456ad138 rev=blubber',
'pkg.bar': 'git dummy://bar branch=main branch=feature',
})
pytest.raises(ValueError, extension.get_sources)

buildout['sources'].update({
'pkg.foo': 'git dummy://foo/trunk kind=svn',
})
pytest.raises(ValueError, extension.get_sources)
sources = extension.get_sources()
assert sources['pkg.foo']['rev'] == 'blubber'
assert sources['pkg.bar']['branch'] == 'feature'

def testInvalidOptionParsing(self, buildout, extension):
buildout['sources'].update({
Expand Down
Loading