|
13 | 13 | Invite |
14 | 14 | ) |
15 | 15 | import base64 |
| 16 | +from pyforgejo import PyforgejoApi |
16 | 17 |
|
17 | 18 | class ForgejoRepoAPI(IRepositoryAPI): |
18 | 19 | def __init__(self, client): |
@@ -256,3 +257,50 @@ def get_comments(self, repo, obj) -> list[Comment]: |
256 | 257 | def get_invites(self, repo: Repository) -> list[Invite]: |
257 | 258 | return [] |
258 | 259 |
|
| 260 | + |
| 261 | +# Точка входа для тестирования |
| 262 | +if __name__ == "__main__": |
| 263 | + client = PyforgejoApi(api_key="token", base_url="https://codeberg.org/api/v1") |
| 264 | + api = ForgejoRepoAPI(client) |
| 265 | + |
| 266 | + repo = api.get_repository("harabat/pyforgejo") |
| 267 | + if not repo: |
| 268 | + print("Repository not found.") |
| 269 | + exit() |
| 270 | + |
| 271 | + # Вывод информации о репозитории |
| 272 | + print(f"Repository: {repo.name}, URL: {repo.url}") |
| 273 | + |
| 274 | + # Получение коммитов |
| 275 | + commits = api.get_commits(repo) |
| 276 | + print(f"Total commits: {len(commits)}") |
| 277 | + for commit in commits[:10]: # Выведем первые 10 коммитов |
| 278 | + print( |
| 279 | + f"Commit: {commit._id}, Message: {commit.message}, Author: {commit.author.username}" |
| 280 | + ) |
| 281 | + |
| 282 | + # Получение контрибьюторов |
| 283 | + contributors = api.get_contributors(repo) |
| 284 | + print(f"Total contributors: {len(contributors)}") |
| 285 | + for contributor in contributors: |
| 286 | + print(f"Contributor: {contributor.username}, Email: {contributor.email}") |
| 287 | + |
| 288 | + # Получение issues |
| 289 | + issues = api.get_issues(repo) |
| 290 | + print(f"Total issues: {len(issues)}") |
| 291 | + for issue in issues[:10]: # Выведем первые 10 issues |
| 292 | + print(f"Issue: {issue._id}, Title: {issue.title}, State: {issue.state}") |
| 293 | + |
| 294 | + # Получение pull requests |
| 295 | + pulls = api.get_pull_requests(repo) |
| 296 | + print(f"Total pull requests: {len(pulls)}") |
| 297 | + for pull in pulls[:10]: # Выведем первые 10 pull requests |
| 298 | + print(f"Pull Request: {pull._id}, Title: {pull.title}, State: {pull.state}") |
| 299 | + |
| 300 | + # Получение веток |
| 301 | + branches = api.get_branches(repo) |
| 302 | + print(f"Total branches: {len(branches)}") |
| 303 | + for branch in branches: |
| 304 | + print( |
| 305 | + f"Branch: {branch.name}, Last Commit: {branch.last_commit._id if branch.last_commit else 'None'}" |
| 306 | + ) |
0 commit comments