-
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.
refactor(CS): make generate_folders_with_repo compliant with CS
- Loading branch information
Showing
1 changed file
with
17 additions
and
12 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 |
---|---|---|
@@ -1,20 +1,25 @@ | ||
#!/usr/bin/env python3 | ||
## | ||
## @Miou-zora Project, Mirror-Generator, 2023 | ||
## generate_folders_with_repo.py | ||
## File description: | ||
## Generate folders with repo and mirror repo in. | ||
## | ||
# @Miou-zora Project, Mirror-Generator, 2023 | ||
|
||
import subprocess | ||
|
||
def generate_folders_with_repo(ssh_key: str, project_name: str, user_name: str, repo_name: str, mirror_name: str): | ||
|
||
def generate_folders_with_repo(ssh_key: str, | ||
project_name: str, | ||
user_name: str, | ||
repo_name: str, | ||
mirror_name: str): | ||
mirror_ssh_link = f"git@github.com:{user_name}/{mirror_name}.git" | ||
actions = [(["mkdir", project_name], "Folder already exist: " + project_name), | ||
(["git", "clone", ssh_key], "Can't clone repository: " + ssh_key), | ||
(["mv", repo_name, project_name], "Can't move folder: " + repo_name), | ||
(["git", "clone", mirror_ssh_link], "Can't clone repository: " + mirror_ssh_link), | ||
(["mv", mirror_name, project_name], "Can't move folder: " + mirror_name)] | ||
actions = [(["mkdir", project_name], | ||
"Folder already exist: " + project_name), | ||
(["git", "clone", ssh_key], | ||
"Can't clone repository: " + ssh_key), | ||
(["mv", repo_name, project_name], | ||
"Can't move folder: " + repo_name), | ||
(["git", "clone", mirror_ssh_link], | ||
"Can't clone repository: " + mirror_ssh_link), | ||
(["mv", mirror_name, project_name], | ||
"Can't move folder: " + mirror_name)] | ||
for action in actions: | ||
if subprocess.run(action[0]).returncode == 1: | ||
raise Exception(action[1]) |