From ab8f20fe1154fe4fff418392df8f2159d9b496ea Mon Sep 17 00:00:00 2001 From: Vladen35 Date: Mon, 22 Sep 2025 00:18:25 +0500 Subject: [PATCH 1/2] validation added --- main.py | 2 +- src/git_logger.py | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) 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..8cabac6 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] + for repo in list_repos: + pattern = r'[0-9A-Za-z-_\.]+/[0-9A-Za-z-_\.]+' + if not re.fullmatch(pattern, repo): + print('Names must be in the format /') + exit(1) return list_repos From 092e70fb7d805ab8f13755856f4b39f6be85916c Mon Sep 17 00:00:00 2001 From: Vladen35 Date: Tue, 23 Sep 2025 01:13:11 +0500 Subject: [PATCH 2/2] =?UTF-8?q?=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=BE=20=D0=BE=D0=BF=D0=B8=D1=81=D0=B0=D0=BD=D0=B8=D0=B5?= =?UTF-8?q?=20=D0=B4=D0=BB=D1=8F=20=D1=81=D0=BE=D0=B7=D0=B4=D0=B0=D0=BD?= =?UTF-8?q?=D0=B8=D1=8F=20=D1=82=D0=BE=D0=BA=D0=B5=D0=BD=D0=B0,=20issue-81?= =?UTF-8?q?=20fix?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 7 +++++++ src/git_logger.py | 6 +++--- 2 files changed, 10 insertions(+), 3 deletions(-) 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/src/git_logger.py b/src/git_logger.py index 8cabac6..5904349 100644 --- a/src/git_logger.py +++ b/src/git_logger.py @@ -36,10 +36,10 @@ 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: - pattern = r'[0-9A-Za-z-_\.]+/[0-9A-Za-z-_\.]+' - if not re.fullmatch(pattern, repo): - print('Names must be in the format /') + if not pattern.fullmatch(repo): + logging.error('Repository name must be in the format /') exit(1) return list_repos