From a1f30c44dd519e3e8f3739c78d6529c0363fb84f Mon Sep 17 00:00:00 2001 From: Philip Bauer Date: Thu, 29 Feb 2024 10:36:27 +0100 Subject: [PATCH] fix use of rev (#40) --- CHANGES.md | 5 +++++ src/mxdev/vcs/git.py | 22 +++++++++++++--------- 2 files changed, 18 insertions(+), 9 deletions(-) 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)