Added create command
This commit is contained in:
3
main.py
3
main.py
@@ -179,7 +179,7 @@ For detailed help on each command, use:
|
|||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
# All
|
# All
|
||||||
if args.command and not args.command in ["config","list"]:
|
if args.command and not args.command in ["config","list","create"]:
|
||||||
selected = get_selected_repos(args.all,all_repos_list,args.identifiers)
|
selected = get_selected_repos(args.all,all_repos_list,args.identifiers)
|
||||||
# Dispatch commands.
|
# Dispatch commands.
|
||||||
if args.command == "install":
|
if args.command == "install":
|
||||||
@@ -192,6 +192,7 @@ For detailed help on each command, use:
|
|||||||
print("No identifiers provided. Please specify at least one identifier in the format provider/account/repository.")
|
print("No identifiers provided. Please specify at least one identifier in the format provider/account/repository.")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
else:
|
else:
|
||||||
|
selected = get_selected_repos(True,all_repos_list,None)
|
||||||
for identifier in args.identifiers:
|
for identifier in args.identifiers:
|
||||||
create_repo(identifier, config_merged, USER_CONFIG_PATH, BIN_DIR, remote=args.remote, preview=args.preview)
|
create_repo(identifier, config_merged, USER_CONFIG_PATH, BIN_DIR, remote=args.remote, preview=args.preview)
|
||||||
elif args.command in GIT_DEFAULT_COMMANDS:
|
elif args.command in GIT_DEFAULT_COMMANDS:
|
||||||
|
|||||||
@@ -133,20 +133,12 @@ def create_repo(identifier, config_merged, user_config_path, bin_dir, remote=Fal
|
|||||||
subprocess.run(cmd_remote, cwd=repo_dir, shell=True, check=True)
|
subprocess.run(cmd_remote, cwd=repo_dir, shell=True, check=True)
|
||||||
print(f"Remote 'origin' added: {remote_url}")
|
print(f"Remote 'origin' added: {remote_url}")
|
||||||
except subprocess.CalledProcessError:
|
except subprocess.CalledProcessError:
|
||||||
print(f"Failed to add remote using URL: {remote_url}. Exiting.")
|
print(f"Failed to add remote using URL: {remote_url}.")
|
||||||
sys.exit(2)
|
|
||||||
|
|
||||||
cmd_remote = f"git remote add origin {remote_url}"
|
|
||||||
if preview:
|
|
||||||
print(f"[Preview] Would execute: '{cmd_remote}' in {repo_dir}")
|
|
||||||
else:
|
|
||||||
subprocess.run(cmd_remote, cwd=repo_dir, shell=True, check=True)
|
|
||||||
print(f"Remote 'origin' added: {remote_url}")
|
|
||||||
# Push the initial commit to the remote repository
|
# Push the initial commit to the remote repository
|
||||||
cmd_push = "git push -u origin master"
|
cmd_push = "git push -u origin master"
|
||||||
if preview:
|
if preview:
|
||||||
print(f"[Preview] Would execute: '{cmd_push}' in {repo_dir}")
|
print(f"[Preview] Would execute: '{cmd_push}' in {repo_dir}")
|
||||||
else:
|
else:
|
||||||
subprocess.run(cmd_push, cwd=repo_dir, shell=True, check=True)
|
subprocess.run(cmd_push, cwd=repo_dir, shell=True, check=True)
|
||||||
print("Initial push to the remote repository completed.")
|
print("Initial push to the remote repository completed.")
|
||||||
exit(7)
|
|
||||||
Reference in New Issue
Block a user