@@ -86,6 +86,17 @@ def get_pr_stack_from_number(ref: str, repo: Repository) -> List[int]:
8686    return  pr_stack 
8787
8888
89+ def  get_differential_revision (pr , repo : Repository ) ->  str :
90+     body  =  repo .get_pull (pr .number ).body 
91+     matches  =  re .findall (r"Differential Revision: .*" , body )
92+     count  =  len (matches )
93+     if  count  ==  1 :
94+         # If there's more than one Differential Revision, let's just return empty 
95+         # so that we can disambiguate manually. 
96+         return  matches [0 ]
97+     return  "" 
98+ 
99+ 
89100def  create_prs_for_orig_branch (pr_stack : List [int ], repo : Repository ):
90101    # For the first PR, we want to merge to `main` branch, and we will update 
91102    # as we go through the stack 
@@ -100,13 +111,15 @@ def create_prs_for_orig_branch(pr_stack: List[int], repo: Repository):
100111        # The PR we want to create is then "branch_to_merge" <- gh/user/x/orig 
101112        # gh/user/x/orig is the clean diff between gh/user/x/base <- gh/user/x/head 
102113        orig_branch_merge_head  =  pr .base .ref .replace ("base" , "orig" )
114+         differential_revision_text  =  get_differential_revision (pr , repo )
103115        bot_metadata  =  f"""This PR was created by the merge bot to help merge the original PR into the main branch. 
104116ghstack PR number: https://github.com/pytorch/executorch/pull/{ pr .number }   by @{ pr .user .login }  
105117^ Please use this as the source of truth for the PR details, comments, and reviews 
106118ghstack PR base: https://github.com/pytorch/executorch/tree/{ pr .base .ref }  
107119ghstack PR head: https://github.com/pytorch/executorch/tree/{ pr .head .ref }  
108120Merge bot PR base: https://github.com/pytorch/executorch/tree/{ orig_branch_merge_base }  
109121Merge bot PR head: https://github.com/pytorch/executorch/tree/{ orig_branch_merge_head }  
122+ { differential_revision_text } 
110123@diff-train-skip-merge""" 
111124
112125        existing_orig_pr  =  repo .get_pulls (
0 commit comments