diff --git a/README.md b/README.md index 79878a0..f173462 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,13 @@ docker build -t checking_repo . docker run -v $(pwd)/output:/app/output checking_repo [--invites] [--commites] [--etc...] -t -l -o ./output/res.csv ``` +## Как создать токен: +1. Заходим в настройки профиля github +2. Листаем вниз и выбираем пункт Developer settings +3. Нажимаем на вкладку Personal access tokens, в выпадающем списке выбираем Tokens(classic) +4. Нажимаем на кнопку Generate new token, в выпадающем окне выбираем Generate new token(classic) +5. Мы попадаем в настройки токена. Вписываем название токена, выбираем длительность действия токена, ставим галочки на нужные вам права, например - (Repo, workflow, user) +6. Нажимаем Generate token, сохраняем код токена и пользуемся. ## Запуск приложения: 1. Логирование commits diff --git a/main.py b/main.py index 4f068a5..78282bc 100644 --- a/main.py +++ b/main.py @@ -63,7 +63,7 @@ def parse_args(): help=( 'Path to the file containing the list of repositories. ' 'Repositories should be separated by a line break. ' - 'Names should be in the format / ' + 'Names must be in the format / ' ), ) parser.add_argument( diff --git a/src/git_logger.py b/src/git_logger.py index e58ec75..5904349 100644 --- a/src/git_logger.py +++ b/src/git_logger.py @@ -1,3 +1,4 @@ +import re from time import sleep import logging import traceback @@ -35,6 +36,11 @@ def get_tokens_from_file(tokens_path: str) -> list[str]: def get_repos_from_file(repos_path: str) -> list[str]: with open(repos_path, 'r') as file: list_repos = [x for x in file.read().split('\n') if x] + pattern = re.compile(r'[0-9A-Za-z-_\.]+/[0-9A-Za-z-_\.]+') + for repo in list_repos: + if not pattern.fullmatch(repo): + logging.error('Repository name must be in the format /') + exit(1) return list_repos