2
2
import argparse
3
3
import subprocess
4
4
5
+ def get_github_username ():
6
+ """Retrieve GitHub username from local Git configuration."""
7
+ result = subprocess .run (['git' , 'config' , '--get' , 'user.name' ], capture_output = True , text = True )
8
+ if result .returncode == 0 and result .stdout :
9
+ return result .stdout .strip ()
10
+ else :
11
+ raise Exception ("Failed to retrieve GitHub username from Git config." )
12
+
5
13
def update_fork ():
6
14
# Sync your fork's main branch with the original repository's main branch
7
15
print ("Updating fork..." )
@@ -28,11 +36,12 @@ def push_changes(branch_name, commit_message):
28
36
def create_pull_request (branch_name , pr_title , pr_file ):
29
37
# Create a pull request on GitHub using the GitHub CLI
30
38
print ("Creating pull request..." )
39
+ github_username = get_github_username ()
31
40
with open (pr_file , 'r' ) as file :
32
41
pr_body = file .read () # Read the PR description from a markdown file
33
42
subprocess .run (['gh' , 'pr' , 'create' ,
34
43
'--base' , 'main' ,
35
- '--head' , f'{ branch_name } ' ,
44
+ '--head' , f'{ github_username } : { branch_name } ' ,
36
45
'--title' , pr_title ,
37
46
'--body' , pr_body ], check = True ) # Create a pull request with the specified title and markdown body
38
47
print ("Pull request created successfully." )
0 commit comments