From 999ca709163f15759c27957405eae9b34859efa8 Mon Sep 17 00:00:00 2001
From: SantaSpeen
Date: Sun, 10 Apr 2022 11:59:49 +0300
Subject: [PATCH] Fix requirements; Update flags; Fix urls in README files;
---
CODEOWNERS | 1 -
README.md | 16 +++++++++++++---
READMEru.md | 2 +-
main.py | 27 ++++++++++++++-------------
requirements.txt | 1 +
5 files changed, 29 insertions(+), 18 deletions(-)
delete mode 100644 CODEOWNERS
diff --git a/CODEOWNERS b/CODEOWNERS
deleted file mode 100644
index e3ce99b..0000000
--- a/CODEOWNERS
+++ /dev/null
@@ -1 +0,0 @@
-main.py @SantaSpeen
diff --git a/README.md b/README.md
index 36e3003..4842555 100644
--- a/README.md
+++ b/README.md
@@ -6,7 +6,7 @@
-Russian localization: [here](https://gitflic.ru/project/dbi471/git-switch/blob?file=READMEru.md)
+Русская локализация: [нажать сюда](https://gitflic.ru/project/dbi471/git-switch/blob?file=READMEru.md)
A tool that will help you copy repositories from GitHub into GitFlic.
@@ -26,13 +26,23 @@ If you don't have python installed, download it from [http://python.org/](http:/
# Shell
$ python3 main.py --help
+Usage: main.py [OPTIONS]
+
+Options:
+ --gf_token TEXT Your GitFlic token. [required]
+ --gh_token TEXT Your GitHub token. [required]
+ --clone_folder PATH Directory where to download repositories.
+ --apply_private Need to copy private repositories?
+ --apply_organisations Need to copy organisations repositories?
+ --use_ssh Use SSH mode to upload repositories.
+ --help Show this message and exit.
```
Then:
* Get GitHub token from: [https://github.com/settings/tokens](https://github.com/settings/tokens)
-* Get GitFlic token from: [https://github.com/settings/tokens](https://gitflic.ru/settings/oauth/token)
+* Get GitFlic token from: [https://gitflic.ru/settings/oauth/token](https://gitflic.ru/settings/oauth/token)
-If you are using 2AF into GitFlic select ssh connection using the key: `--use_ssh true`.
+If you are using 2AF into GitFlic select ssh connection using the key: `--use_ssh`.
The script will copy all the necessary repositories to `./cloned-repos//`, then push it to GitFlic
diff --git a/READMEru.md b/READMEru.md
index 8a668af..d52d029 100644
--- a/READMEru.md
+++ b/READMEru.md
@@ -30,7 +30,7 @@ $ python3 main.py --help
Изучив аргументы:
* Получите GitHub токен отсюда: [https://github.com/settings/tokens](https://github.com/settings/tokens)
-* Получите GitFlic токен отсюда: [https://github.com/settings/tokens](https://gitflic.ru/settings/oauth/token)
+* Получите GitFlic токен отсюда: [https://gitflic.ru/settings/oauth/token](https://gitflic.ru/settings/oauth/token)
Если у вас подключена 2AF в GitFlic используйте ssh: `--use_ssh true`.
diff --git a/main.py b/main.py
index 521167a..1404d50 100644
--- a/main.py
+++ b/main.py
@@ -7,26 +7,25 @@
Программа была отрефакторена: @SantaSpeen
"""
-# Типы. Используется для <того, что бы тебя любило IDE>.
-from typing import NoReturn, Union
-
# Удобная и встроенная в Python библиотека логирования. Подробнее: https://docs.python.org/3.10/library/logging.html
import logging
# Встроенные библиотеки. Нужны для некоторых функций прогрммы.
import os
import sys
import time
+# Типы. Используется для <того, что бы тебя любило IDE>.
+from typing import NoReturn, Union
# Библиотека для работы с аргументами. Подробнее: https://click.palletsprojects.com/en/8.0.x
import click
-# Библиотека для работы c GitHub API. Подробнее: https://github.com/PyGithub/PyGithub
-from github import Github, AuthenticatedUser, PaginatedList
-# Библиотека для работы с Gitflic API. Подробнее: https://github.com/SantaSpeen/gitflic
-from gitflic import GitflicAuth, Gitflic
-# Библиотека для работы с git. Подробнее про систему git: https://habr.com/ru/post/588801/
-from git import Repo
#
import requests
+# Библиотека для работы с git. Подробнее про систему git: https://habr.com/ru/post/588801/
+from git import Repo
+# Библиотека для работы с Gitflic API. Подробнее: https://github.com/SantaSpeen/gitflic
+from gitflic import GitflicAuth, Gitflic
+# Библиотека для работы c GitHub API. Подробнее: https://github.com/PyGithub/PyGithub
+from github import Github, AuthenticatedUser, PaginatedList
# Инициализируем логирование
log_format = "%(asctime)s - %(name)-5s - %(levelname)-5s - %(message)s"
@@ -181,10 +180,12 @@ class GitSwitch:
@click.command()
@click.option("--gf_token", help="Your GitFlic token.", type=str, required=True)
@click.option("--gh_token", help="Your GitHub token.", type=str, required=True)
-@click.option("--apply_private", help="Need to copy private repositories?", default=False, required=False)
-@click.option("--apply_organisations", help="Need to copy organisations repositories?", default=False, required=False)
-@click.option("--use_ssh", help="Use SSH mode to upload repositories.", default=False, required=False)
-@click.option("--clone_folder", help="Directory where to download repositories.", default="./cloned-repos", required=False)
+@click.option("--clone_folder", help="Directory where to download repositories.", default="./cloned-repos",
+ required=False, type=click.Path())
+@click.option("--apply_private", help="Need to copy private repositories?", default=False, required=False, is_flag=True)
+@click.option("--apply_organisations", help="Need to copy organisations repositories?", default=False, required=False,
+ is_flag=True)
+@click.option("--use_ssh", help="Use SSH mode to upload repositories.", default=False, required=False, is_flag=True)
def main(**kwargs):
log.info("New log start.")
log.info(f"Local time: {time.asctime()}")
diff --git a/requirements.txt b/requirements.txt
index 0649ade..b6bc6ba 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -2,3 +2,4 @@ click==8.1.1
requests==2.27.1
PyGithub==1.55
gitflic==1.1
+gitpython==3.1.27