From 6a3e19c63640b3f886154c6cd856fc407e70c430 Mon Sep 17 00:00:00 2001 From: Sergio Martins Date: Wed, 22 Jan 2025 11:42:48 +0000 Subject: [PATCH] Make update_submodules() create PR for fetchcontent edits --- src/gh_utils.py | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/src/gh_utils.py b/src/gh_utils.py index ce0cb52..3445a9e 100755 --- a/src/gh_utils.py +++ b/src/gh_utils.py @@ -432,9 +432,16 @@ def update_fetchcontent(proj_name, dep_name, sha1, repo_path, remote, branch): Like update_submodule() but bumps a FetchContent dependency. ''' + if not run_command(f"git -C {repo_path} checkout {branch}"): + return False + + tmp_branch = checkout_randomly_named_branch(repo_path, "gh-actions") + if not tmp_branch: + return False + versions = get_fetchcontent_versions(repo_path, proj_name, dep_name) versions = versions[0] - tag_name = None + tag_name = sha1 # gets replaced by a name if we have it current_sha1 = versions['current_version_sha1'] if not sha1: @@ -450,6 +457,23 @@ def update_fetchcontent(proj_name, dep_name, sha1, repo_path, remote, branch): print(f'Error while editing {cmake_filename}') return False + if not run_command(f"git -C {repo_path} add {cmake_filename}"): + return False + + commit_msg = f"\"Bump {dep_name} from {versions['current_version']} to {tag_name}\"" + + if not run_command(f"git -C {repo_path} commit --author \"KDAB GitHub Actions \" -m {commit_msg}"): + return False + + if not run_command(f"git -C {repo_path} push {remote} {tmp_branch}"): + return False + + if not run_command(f"git -C {repo_path} push --set-upstream {remote} {tmp_branch}"): + return False + + if not run_command(f"gh pr create -R KDAB/{proj_name} --base {branch} -H {tmp_branch} --title {commit_msg} --body \"Automatically created via GH action.\""): + return False + return False