From 48a34b4dab1c3af497764e33bb1c8dab33fb3396 Mon Sep 17 00:00:00 2001 From: Ricardo Pardini Date: Sun, 7 May 2023 01:38:30 +0200 Subject: [PATCH] WiP: patching.py: BASE_GIT_TAG now very sneakily also accepts a branch name --- lib/tools/patching.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/tools/patching.py b/lib/tools/patching.py index 3c259258478c..30a1bbab5b06 100755 --- a/lib/tools/patching.py +++ b/lib/tools/patching.py @@ -231,7 +231,16 @@ raise Exception("BASE_GIT_REVISION or BASE_GIT_TAG must be set") else: log.debug(f"Getting revision of BASE_GIT_TAG={BASE_GIT_TAG}") - BASE_GIT_REVISION = git_repo.tags[BASE_GIT_TAG].commit.hexsha + # first, try as a tag: + try: + BASE_GIT_REVISION = git_repo.tags[BASE_GIT_TAG].commit.hexsha + except IndexError: + # not a tag, try as a branch: + try: + BASE_GIT_REVISION = git_repo.branches[BASE_GIT_TAG].commit.hexsha + except IndexError: + raise Exception(f"BASE_GIT_TAG={BASE_GIT_TAG} is neither a tag nor a branch") + log.debug(f"Found BASE_GIT_REVISION={BASE_GIT_REVISION} for BASE_GIT_TAG={BASE_GIT_TAG}") patching_utils.prepare_clean_git_tree_for_patching(git_repo, BASE_GIT_REVISION, BRANCH_FOR_PATCHES)