Skip to content

Commit 217adfa

Browse files
committed
Factored out creation of the GitHub PR URL into a function in github_utils
1 parent 15387af commit 217adfa

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

codeflash/code_utils/github_utils.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,6 @@ def require_github_app_or_exit(owner: str, repo: str) -> None:
2626
f"Note: if you want to find optimizations without opening PRs, you can run Codeflash with the --no-pr flag.{LF}"
2727
)
2828
apologize_and_exit()
29+
30+
def github_pr_url(owner: str, repo: str, pr_number: str) -> str:
31+
return f"https://github.com/{owner}/{repo}/pull/{pr_number}"

codeflash/result/create_pr.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
get_repo_owner_and_name,
1616
git_root_dir,
1717
)
18+
from codeflash.code_utils.github_utils import github_pr_url
1819
from codeflash.github.PrComment import FileDiffContent, PrComment
1920

2021
if TYPE_CHECKING:
@@ -133,7 +134,7 @@ def check_create_pr(
133134
)
134135
if response.ok:
135136
pr_number = response.text
136-
pr_url = f"https://github.com/{owner}/{repo}/pull/{pr_number}"
137+
pr_url = github_pr_url(owner, repo, pr_number)
137138
logger.info(f"Successfully created a new PR #{pr_number} with the optimized code: {pr_url}")
138139
else:
139140
logger.error(

0 commit comments

Comments
 (0)