From d4fdbae7a66470a891004feaadc2ce9cae26d65d Mon Sep 17 00:00:00 2001 From: Kenneth Hoste Date: Fri, 7 Jun 2024 21:39:05 +0200 Subject: [PATCH] don't try to determine repo version when file that contains version doesn't exist --- easybuild/tools/github.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/easybuild/tools/github.py b/easybuild/tools/github.py index 9a6bc985b8..6d4a1300fc 100644 --- a/easybuild/tools/github.py +++ b/easybuild/tools/github.py @@ -589,13 +589,19 @@ def fetch_files_from_pr(pr, path=None, github_user=None, github_account=None, gi raise EasyBuildError("Couldn't find path to patched file %s", full_path) if github_repo == GITHUB_EASYCONFIGS_REPO: - ver = _get_version_for_repo(os.path.join(final_path, 'setup.py')) + ver_file = os.path.join(final_path, 'setup.py') elif github_repo == GITHUB_EASYBLOCKS_REPO: - ver = _get_version_for_repo(os.path.join(final_path, 'easybuild', 'easyblocks', '__init__.py')) - - if different_major_versions(FRAMEWORK_VERSION, ver): - raise EasyBuildError("Framework (%s) is a different major version than used in %s/%s PR #%s (%s)", - FRAMEWORK_VERSION, github_account, github_repo, pr, ver) + ver_file = os.path.join(final_path, 'easybuild', 'easyblocks', '__init__.py') + else: + raise EasyBuildError("Don't know how to determine version for repo %s", github_repo) + + # take into account that the file we need to determine repo version may not be available, + # for example when a closed PR is used (since then we only download files patched by the PR) + if os.path.exists(ver_file): + ver = _get_version_for_repo(ver_file) + if different_major_versions(FRAMEWORK_VERSION, ver): + raise EasyBuildError("Framework (%s) is a different major version than used in %s/%s PR #%s (%s)", + FRAMEWORK_VERSION, github_account, github_repo, pr, ver) return files