Skip to content

Commit 8d04875

Browse files
authored
validation added (#150)
1 parent a05fb14 commit 8d04875

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,13 @@ docker build -t checking_repo .
2020
docker run -v $(pwd)/output:/app/output checking_repo [--invites] [--commites] [--etc...] -t <insert_token> -l <insert_list> -o ./output/res.csv
2121
```
2222

23+
## Как создать токен:
24+
1. Заходим в настройки профиля github
25+
2. Листаем вниз и выбираем пункт Developer settings
26+
3. Нажимаем на вкладку Personal access tokens, в выпадающем списке выбираем Tokens(classic)
27+
4. Нажимаем на кнопку Generate new token, в выпадающем окне выбираем Generate new token(classic)
28+
5. Мы попадаем в настройки токена. Вписываем название токена, выбираем длительность действия токена, ставим галочки на нужные вам права, например - (Repo, workflow, user)
29+
6. Нажимаем Generate token, сохраняем код токена и пользуемся.
2330

2431
## Запуск приложения:
2532
1. Логирование commits

main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def parse_args():
6363
help=(
6464
'Path to the file containing the list of repositories. '
6565
'Repositories should be separated by a line break. '
66-
'Names should be in the format <organization or owner>/<name> '
66+
'Names must be in the format <organization or owner>/<name> '
6767
),
6868
)
6969
parser.add_argument(

src/git_logger.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import re
12
from time import sleep
23
import logging
34
import traceback
@@ -35,6 +36,11 @@ def get_tokens_from_file(tokens_path: str) -> list[str]:
3536
def get_repos_from_file(repos_path: str) -> list[str]:
3637
with open(repos_path, 'r') as file:
3738
list_repos = [x for x in file.read().split('\n') if x]
39+
pattern = re.compile(r'[0-9A-Za-z-_\.]+/[0-9A-Za-z-_\.]+')
40+
for repo in list_repos:
41+
if not pattern.fullmatch(repo):
42+
logging.error('Repository name must be in the format <organization or owner>/<name>')
43+
exit(1)
3844

3945
return list_repos
4046

0 commit comments

Comments
 (0)