@@ -68,7 +68,12 @@ def create_pull_request(
6868 # 5. Add and commit METADATA.pb
6969 subprocess .run (["git" , "-c" , "core.hooksPath=/dev/null" , "add" , str (meta_path )], check = True )
7070 commit_msg = f"Update { family_name } METADATA.pb to upstream { upstream_version or upstream_commit } "
71- subprocess .run (["git" , "-c" , "core.hooksPath=/dev/null" , "commit" , "-m" , commit_msg ], check = True )
71+ subprocess .run ([
72+ "git" , "-c" , "core.hooksPath=/dev/null" ,
73+ "-c" , "user.name=github-actions[bot]" ,
74+ "-c" , "user.email=github-actions[bot]@users.noreply.github.com" ,
75+ "commit" , "-m" , commit_msg
76+ ], check = True )
7277
7378 # 6. Push branch to origin
7479 subprocess .run (["git" , "-c" , "core.hooksPath=/dev/null" , "push" , "origin" , branch_name , "--force" ], check = True )
@@ -120,18 +125,19 @@ def create_pull_request(
120125 # Return to original branch
121126 subprocess .run (["git" , "-c" , "core.hooksPath=/dev/null" , "checkout" , original_branch ], check = False )
122127
123-
124128 return {
125129 "created" : True ,
126130 "branch_name" : branch_name ,
127131 "pr_url" : pr_url or f"https://github.com/{ self .repo_slug } /pulls" ,
128132 "status" : "PR_CREATED" ,
129133 }
130134 except Exception as e :
131- # Return to original branch on failure
132- subprocess .run (["git" , "checkout" , original_branch ], check = False )
135+ # Revert any uncommitted/unstaged changes and restore original branch
136+ subprocess .run (["git" , "-c" , "core.hooksPath=/dev/null" , "checkout" , "--" , "." ], check = False )
137+ subprocess .run (["git" , "-c" , "core.hooksPath=/dev/null" , "checkout" , original_branch ], check = False )
133138 return {
134139 "created" : False ,
135140 "error" : str (e ),
136141 "status" : "PR_CREATION_FAILED" ,
137142 }
143+
0 commit comments