@@ -175,35 +175,36 @@ def init_argparse():
175
175
urllib .request .urlopen (request )
176
176
177
177
# Clone the repo and add the upstream repo
178
+ repo_dir = 'repo'
178
179
execute (['git' , 'clone' , parser .git_protocol + '://' + parser .cac_username + ':' + parser .cac_password + '@'
179
- + parser .git_host + '/' + parser .git_organization + '/' + new_repo + '.git' ])
180
+ + parser .git_host + '/' + parser .git_organization + '/' + new_repo + '.git' , repo_dir ])
180
181
execute (
181
182
['git' , 'remote' , 'add' , 'upstream' ,
182
183
parser .git_protocol + '://' + parser .cac_username + ':' + parser .cac_password + '@'
183
184
+ parser .git_host + '/' + parser .git_organization + '/' + template_repo + '.git' ],
184
- cwd = new_repo )
185
- execute (['git' , 'fetch' , '--all' ], cwd = new_repo )
186
- _ , _ , show_branch_result = execute (['git' , 'show-branch' , 'remotes/origin/' + branch ], cwd = new_repo )
185
+ cwd = repo_dir )
186
+ execute (['git' , 'fetch' , '--all' ], cwd = repo_dir )
187
+ _ , _ , show_branch_result = execute (['git' , 'show-branch' , 'remotes/origin/' + branch ], cwd = repo_dir )
187
188
188
189
if show_branch_result == 0 :
189
190
# Checkout the local branch.
190
191
if branch != 'master' and branch != 'main' :
191
- execute (['git' , 'checkout' , '-b' , branch , 'origin/' + branch ], cwd = new_repo )
192
+ execute (['git' , 'checkout' , '-b' , branch , 'origin/' + branch ], cwd = repo_dir )
192
193
else :
193
- execute (['git' , 'checkout' , branch ], cwd = new_repo )
194
+ execute (['git' , 'checkout' , branch ], cwd = repo_dir )
194
195
195
196
if os .path .exists (new_repo + '/.octopus' ):
196
197
print ('The repo has already been forked.' )
197
198
sys .exit (0 )
198
199
199
200
# Create a new branch representing the forked main branch.
200
- execute (['git' , 'checkout' , '-b' , branch ], cwd = new_repo )
201
+ execute (['git' , 'checkout' , '-b' , branch ], cwd = repo_dir )
201
202
202
203
# Hard reset it to the template main branch.
203
- execute (['git' , 'reset' , '--hard' , 'upstream/' + branch ], cwd = new_repo )
204
+ execute (['git' , 'reset' , '--hard' , 'upstream/' + branch ], cwd = repo_dir )
204
205
205
206
# Push the changes.
206
- execute (['git' , 'push' , 'origin' , branch ], cwd = new_repo )
207
+ execute (['git' , 'push' , 'origin' , branch ], cwd = repo_dir )
207
208
208
209
print (
209
210
'Repo was forked from ' + parser .git_protocol + '://' + parser .git_host + '/' + parser .git_organization + '/' + template_repo + ' to '
0 commit comments