diff --git a/CHANGES.md b/CHANGES.md index b728e15..43bb818 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,5 +1,10 @@ ## Changes +### 4.0.1 (unreleased) + +- Fix specifying out a revision (#40) + [pbauer] + ### 4.0.0 (2024-02-28) - Breaking: Remove `--pre` on sources from generated `requirements-mxdev.txt`. diff --git a/src/mxdev/vcs/git.py b/src/mxdev/vcs/git.py index 8c0d6a5..24e9c14 100644 --- a/src/mxdev/vcs/git.py +++ b/src/mxdev/vcs/git.py @@ -36,15 +36,19 @@ def __init__(self, source: typing.Dict[str, str]): if "revision" in source: source["rev"] = source["revision"] del source["revision"] - if "branch" in source and "rev" in source: - logger.error( - "Cannot specify both branch (%s) and rev/revision " - "(%s) in source for %s", - source["branch"], - source["rev"], - source["name"], - ) - sys.exit(1) + if "rev" in source: + # drop default value for branch if rev is specified + if source.get("branch") == "main": + del source["branch"] + elif "branch" in source: + logger.error( + "Cannot specify both branch (%s) and rev/revision " + "(%s) in source for %s", + source["branch"], + source["rev"], + source["name"], + ) + sys.exit(1) super().__init__(source) @functools.lru_cache(maxsize=4096)