File tree Expand file tree Collapse file tree 1 file changed +27
-0
lines changed
Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Original file line number Diff line number Diff line change 1+ class GitHubRepoAPI (IRepositoryAPI ):
2+
3+ def __init__ (self , client ):
4+ self .client = client
5+
6+ def get_repository (self , id : str ) -> Optional [Repository ]:
7+ try :
8+ repo = self .client .get_repo (id )
9+ return Repository (repo .full_name , repo .name , repo .html_url )
10+ except Exception as e :
11+ logging .error (f"Failed to get repository { id } from GitHub: { e } " )
12+ return None
13+
14+ def get_commits (self , repo : Repository ) -> List [Commit ]:
15+ try :
16+ commits = self .client .get_repo (repo .id ).get_commits ()
17+ return [
18+ Commit (
19+ c .sha ,
20+ c .commit .message ,
21+ Contributor (c .author .login if c .author else "unknown" , c .commit .author .email ),
22+ c .commit .author .date
23+ ) for c in commits
24+ ]
25+ except Exception as e :
26+ logging .error (f"Failed to get commits from GitHub for repo { repo .name } : { e } " )
27+ return []
You can’t perform that action at this time.
0 commit comments