2929from importlib .resources import as_file , files
3030from string import Template
3131
32- from click_extra import TableFormat , render_table
33-
3432
3533def _unescape_dollars (text : str ) -> str :
3634 r"""Replace ``\$`` with ``$`` in template text.
@@ -142,7 +140,7 @@ def render_template(*names: str, **kwargs: str) -> str:
142140 append_footer = True
143141 result = "\n \n " .join (parts )
144142 if append_footer :
145- result += "\n \n " + generated_footer ( )
143+ result += "\n \n --- \n \n " + render_template ( "generated-footer" )
146144 result = re .sub (r"\n{3,}" , "\n \n " , result )
147145 if append_footer :
148146 result += "\n "
@@ -250,28 +248,28 @@ def generate_pr_metadata_block() -> str:
250248 workflow_url = (
251249 f"{ server_url } /{ repository } /blob/{ sha } /.github/workflows/{ workflow_file } "
252250 )
251+ commit_url = f"{ server_url } /{ repository } /commit/{ sha } "
253252
254- rows = [
255- ["**Trigger**" , f"`{ event_name } `" ],
256- ["**Actor**" , f"@{ actor } " ],
257- ]
253+ rerun_row = ""
258254 if triggering_actor and triggering_actor != actor :
259- rows .append (["**Re-run by**" , f"@{ triggering_actor } " ])
260- rows += [
261- ["**Ref**" , f"`{ ref_name } `" ],
262- ["**Commit**" , f"[`{ sha [:8 ]} `]({ server_url } /{ repository } /commit/{ sha } )" ],
263- ["**Job**" , f"`{ job } `" ],
264- ["**Workflow**" , f"[`{ workflow_file } `]({ workflow_url } )" ],
265- ["**Run**" , f"[#{ run_number } .{ run_attempt } ]({ run_url } )" ],
266- ]
267- table = render_table (
268- rows ,
269- headers = ["Field" , "Value" ],
270- table_format = TableFormat .GITHUB ,
255+ rerun_row = f"| **Re-run by** | @{ triggering_actor } |\n "
256+
257+ return render_template (
258+ "pr-metadata" ,
259+ event_name = event_name ,
260+ actor = actor ,
261+ rerun_row = rerun_row ,
262+ ref_name = ref_name ,
263+ sha_short = sha [:8 ],
264+ commit_url = commit_url ,
265+ job = job ,
266+ workflow_file = workflow_file ,
267+ workflow_url = workflow_url ,
268+ run_number = run_number ,
269+ run_attempt = run_attempt ,
270+ run_url = run_url ,
271271 )
272272
273- return render_template ("pr-metadata" , table = table )
274-
275273
276274def _repo_url () -> str :
277275 """Build repository URL from ``GITHUB_SERVER_URL`` and ``GITHUB_REPOSITORY``."""
@@ -301,23 +299,16 @@ def generate_refresh_tip() -> str:
301299 return render_template ("refresh-tip" , workflow_dispatch_url = workflow_dispatch_url )
302300
303301
304- def generated_footer () -> str :
305- """Render the attribution footer from the ``generated-footer`` template.
306-
307- Single source of truth for the attribution line appended to all PR and
308- issue bodies produced by repomatic.
309-
310- :return: A markdown string with a horizontal rule and the attribution line.
311- """
312- return "---\n \n " + render_template ("generated-footer" )
313-
314302
315303def build_pr_body (prefix : str , metadata_block : str ) -> str :
316- """Concatenate prefix, refresh tip, metadata block, and footer into a PR body.
304+ """Concatenate prefix, refresh tip, and metadata block into a PR body.
305+
306+ The ``metadata_block`` already includes the attribution footer (appended
307+ automatically by :func:`render_template`).
317308
318309 :param prefix: Content to prepend before the metadata block. Can be empty.
319310 :param metadata_block: The collapsible metadata block from
320- :func:`generate_pr_metadata_block`.
311+ :func:`generate_pr_metadata_block`, with footer .
321312 :return: The complete PR body string.
322313 """
323314 parts : list [str ] = []
@@ -327,5 +318,4 @@ def build_pr_body(prefix: str, metadata_block: str) -> str:
327318 if tip :
328319 parts .append (tip )
329320 parts .append (metadata_block )
330- parts .append (generated_footer ())
331321 return "\n \n \n " .join (parts )
0 commit comments