Skip to content

Commit 17878bd

Browse files
committed
Add RepoInfo
1 parent 63cc6a6 commit 17878bd

File tree

3 files changed

+10
-19
lines changed

3 files changed

+10
-19
lines changed

Diff for: check.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from utils import get_all_registered_checks
55
from typing import Dict, Union
66
from dataclasses import asdict
7+
from checks.utils import get_repo_info
78

89

910
def check(config_file: str, submissions_file: str):
@@ -29,9 +30,10 @@ def check(config_file: str, submissions_file: str):
2930

3031
def check_submission(submission: Submission, config: HackathonConfig) -> Dict[Union[str, property], Union[str, bool]]:
3132
check_outcome = {**asdict(submission), "remarks": ""}
33+
repo_info = get_repo_info(submission.repo_url)
3234

3335
for check_name, checker_class in get_all_registered_checks():
34-
did_pass_check, remarks = checker_class.perform_check(submission, config)
36+
did_pass_check, remarks = checker_class.perform_check(submission, config, repo_info)
3537
check_outcome[check_name] = did_pass_check
3638

3739
if remarks:

Diff for: datatypes.py

+7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from dataclasses import dataclass
22
from typing import List
33
from datetime import datetime
4+
from github import Commit, Repository
45

56
datetime_format = "%d-%m-%Y %H:%M:%S %z"
67

@@ -11,6 +12,12 @@ class Submission:
1112
authors: List[str]
1213

1314

15+
@dataclass
16+
class RepoInfo:
17+
repo: Repository.Repository
18+
commits: List[Commit.Commit]
19+
20+
1421
@dataclass
1522
class HackathonConfig:
1623
start_at: datetime

Diff for: utils.py

-18
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,6 @@
1-
from github import Github
2-
import os
31
from checks import BaseChecker
42
from typing import Tuple, List, Type
53

6-
# GitHub Related Utils
7-
ghub = Github(os.getenv("GITHUB_ACCESS_TOKEN"))
8-
9-
10-
def get_user(github_username):
11-
try:
12-
usr = ghub.get_user(github_username)
13-
except Exception as e:
14-
return None
15-
16-
17-
def get_repo_id(repo_url):
18-
if repo_url.endswith('.git'):
19-
repo_url = repo_url[:-4]
20-
return repo_url.rstrip('/').split("github.com/")[1]
21-
224

235
# Datatype related utils
246
def get_all_registered_checks() -> List[Tuple[property, Type[BaseChecker]]]:

0 commit comments

Comments
 (0)