Skip to content
This repository has been archived by the owner on Aug 25, 2024. It is now read-only.

Commit

Permalink
feature: git: github api: Enable create or update logic from title, b…
Browse files Browse the repository at this point in the history
…ody, and transform callbacks

Signed-off-by: John Andersen <[email protected]>
  • Loading branch information
pdxjohnny committed Dec 27, 2023
1 parent f158f05 commit 144cc4b
Showing 1 changed file with 17 additions and 11 deletions.
28 changes: 17 additions & 11 deletions feature/git/dffml_feature_git/github_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,9 +198,6 @@ def make_github_operations(
logger.error(error)
continue

commit_message = make_commit_message(repo, fork)
pull_request_body = make_pull_request_body(repo, fork)

try:
fork.create_git_ref(
ref="refs/heads/" + new_branch_name,
Expand Down Expand Up @@ -236,8 +233,11 @@ def make_github_operations(
else:
logger.info(msg)

commit_message = make_commit_message(repo, fork, old_content)
pull_request_body = make_pull_request_body(repo, fork, old_content)

# Transform the content
content = transform_file_content(old_content)
content = transform_file_content(repo, fork, old_content)

# Update file content
if old_content:
Expand Down Expand Up @@ -298,7 +298,7 @@ def make_github_operations(
"workflows",
"pin_downstream.yml",
)
.read_text()
.read_bytes()
)


Expand All @@ -309,13 +309,19 @@ async def main(repos, file_name):
token,
repo_urls,
new_branch_name,
lambda _upstream, fork: commit_message,
lambda _upstream, fork: pull_request_body.replace(
"REPO_ORG/REPO_NAME", fork.full_name
lambda _upstream, _fork, _old_content: commit_message,
lambda _upstream, fork, _old_content: pull_request_body.replace(
"REPO_ORG/REPO_NAME",
fork.full_name,
),
lambda upstream, _fork, old_content: (
old_content if old_content is not None else file_content
)
.decode()
.replace(
"- master",
f"- {upstream.default_branch}",
),
lambda content: content.upper()
if content is not None
else file_content,
fail_on_not_present=False,
)
return
Expand Down

0 comments on commit 144cc4b

Please sign in to comment.