Skip to content

Commit

Permalink
Make update_submodules() create PR for fetchcontent edits
Browse files Browse the repository at this point in the history
  • Loading branch information
iamsergio committed Jan 22, 2025
1 parent 062dfc5 commit 6a3e19c
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion src/gh_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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 <gh@kdab>\" -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


Expand Down

0 comments on commit 6a3e19c

Please sign in to comment.