-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
handle case where user makes a mistake with their github username
- Loading branch information
Showing
1 changed file
with
18 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -85,13 +85,29 @@ def _main() -> None: | |
shutil.rmtree(git_repo) | ||
|
||
# Initialize the repo anew. | ||
subprocess.run(["git", "init", "-b", "main"], check=True) | ||
subprocess.run(["git", "init", "-b", "main"], check=True, capture_output=True) | ||
subprocess.run(["git", "add", "."], check=True) | ||
|
||
# Check if the remote already exists (if this script is being run twice). | ||
# This can happen if the user makes a mistake in their GitHub username. | ||
ret = subprocess.run( | ||
["git", "remote", "get-url", "origin"], | ||
shell=True, | ||
text=True, | ||
capture_output=True, | ||
check=False, | ||
) | ||
# Remote already exists, so set the URL. | ||
if ret.returncode == 0: | ||
remote_command = "set-url" | ||
# Remote doesn't exist, so add the URL. | ||
else: | ||
remote_command = "add" | ||
subprocess.run( | ||
[ | ||
"git", | ||
"remote", | ||
"add", | ||
remote_command, | ||
"origin", | ||
f"[email protected]:{github_username}/{repo_name}.git", | ||
], | ||
|