Skip to content

Commit 21f74e1

Browse files
committed
Apply pull_request_template.md when creating pull requests
1 parent 8f88e55 commit 21f74e1

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

eden/scm/sapling/ext/github/submit.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -422,6 +422,19 @@ async def create_serial_strategy_params(
422422
return SerialStrategyParams(refs_to_update, pull_requests_to_create, repository)
423423

424424

425+
def get_pull_request_template(commit: CommitData) -> None | str:
426+
change_context = commit.ctx
427+
for path in [".github/pull_request_template.md", "pull_request_template.md"]:
428+
try:
429+
file_context = change_context.filectx(path)
430+
bytes = file_context.data()
431+
return str(bytes, "utf-8")
432+
except:
433+
pass # Ignore error when file is not found
434+
435+
return None
436+
437+
425438
async def create_pull_requests_serially(
426439
commits: List[Tuple[CommitData, str]],
427440
workflow: SubmitWorkflow,
@@ -450,6 +463,8 @@ async def create_pull_requests_serially(
450463

451464
commit_msg = commit.get_msg()
452465
title, body = title_and_body(commit_msg)
466+
pull_request_template = get_pull_request_template(commit)
467+
body = "\n\n".join(filter(None, [body, pull_request_template]))
453468
result = await gh_submit.create_pull_request(
454469
hostname=repository.hostname,
455470
owner=owner,

0 commit comments

Comments
 (0)