Skip to content

Commit

Permalink
update_dependencies now can take --owner argument
Browse files Browse the repository at this point in the history
Owner defaults to KDAB, but I might be testing actions in
my personal repo
  • Loading branch information
iamsergio committed Jan 22, 2025
1 parent e5143c6 commit 5532293
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
14 changes: 7 additions & 7 deletions src/gh_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ def print_submodule_versions(repo_paths):
f" {submodule_path}: {current_version} -> ????")


def update_dependency(proj_name, dep_name, sha1, repo_path, remote, branch):
def update_dependency(proj_name, dep_name, sha1, repo_path, remote, branch, owner='KDAB'):
proj = get_project(proj_name)
if 'dependencies' not in proj:
print(
Expand All @@ -421,16 +421,16 @@ def update_dependency(proj_name, dep_name, sha1, repo_path, remote, branch):
deps = proj['dependencies']
dep = deps[dep_name]
if 'submodule_path' in dep:
return update_submodule(proj_name, dep_name, sha1, repo_path, remote, branch)
return update_submodule(proj_name, dep_name, sha1, repo_path, remote, branch, owner)

if 'fetchcontent_path' in dep:
return update_fetchcontent(proj_name, dep_name, sha1, repo_path, remote, branch)
return update_fetchcontent(proj_name, dep_name, sha1, repo_path, remote, branch, owner)

print("Dependency is neither a submodule or a FetchContent, check releasing.toml")
return False


def update_fetchcontent(proj_name, dep_name, sha1, repo_path, remote, branch):
def update_fetchcontent(proj_name, dep_name, sha1, repo_path, remote, branch, owner='KDAB'):
'''
Like update_submodule() but bumps a FetchContent dependency.
'''
Expand Down Expand Up @@ -462,13 +462,13 @@ def update_fetchcontent(proj_name, dep_name, sha1, repo_path, remote, branch):

commit_msg = f"\"Bump {dep_name} from {versions['current_version']} to {tag_name}\""

if not commit_and_push_pr(commit_msg, f"KDAB/{proj_name}", repo_path, remote, branch, tmp_branch):
if not commit_and_push_pr(commit_msg, f"{owner}/{proj_name}", repo_path, remote, branch, tmp_branch):
return False

return True


def update_submodule(proj_name, submodule_name, sha1, repo_path, remote, branch):
def update_submodule(proj_name, submodule_name, sha1, repo_path, remote, branch, owner='KDAB'):
proj = get_project(proj_name)

deps = proj['dependencies']
Expand Down Expand Up @@ -500,7 +500,7 @@ def update_submodule(proj_name, submodule_name, sha1, repo_path, remote, branch)
return False

commit_msg = f"\"Bump {submodule_name} from {versions['current_version']} to {sha1}\""
if not commit_and_push_pr(commit_msg, f"KDAB/{proj_name}", repo_path, remote, branch, tmp_branch):
if not commit_and_push_pr(commit_msg, f"{owner}/{proj_name}", repo_path, remote, branch, tmp_branch):
return False

return True
Expand Down
7 changes: 6 additions & 1 deletion src/update_dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ def print_dependencies(proj_name, repo_path):
parser.add_argument('--branch', metavar='<branch>',
help="Remote branch, defaults to the main branch", required=False)

parser.add_argument('--owner', metavar='<owner>',
help="Repo owner, usually KDAB", required=False, default='KDAB')

parser.add_argument('--sha1', metavar='<sha1, tag or branch>',
help="Sha tag or branch, defaults to latest", dest='new_sha1', required=False)

Expand All @@ -79,4 +82,6 @@ def print_dependencies(proj_name, repo_path):
print_dependencies(args.proj_name, args.repo_path)
elif args.dependency_name:
gh_utils.update_dependency(args.proj_name, args.dependency_name,
args.new_sha1, args.repo_path, args.remote, args.branch)
args.new_sha1, args.repo_path,
args.remote, args.branch,
args.owner)
2 changes: 1 addition & 1 deletion workflows/submodule-bump.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,6 @@ jobs:
- name: Bump submodule
if: inputs.submodule != 'Only print current and available versions'
run: |
python3 ./ci-release-tools/src/update_dependencies.py --update-dependency ${{inputs.submodule}} --proj-name ${{ env.PROJECT_NAME }} --repo-path .
python3 ./ci-release-tools/src/update_dependencies.py --update-dependency ${{inputs.submodule}} --proj-name ${{ env.PROJECT_NAME }} --repo-path . --owner ${{ github.repository_owner }}
env:
GH_TOKEN: ${{ github.token }}

0 comments on commit 5532293

Please sign in to comment.