Skip to content

Commit d845611

Browse files
committed
Added a script for testing PyforgejoAPI.
1 parent 1673460 commit d845611

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

ForgejoRepoAPI.py

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
Invite
1414
)
1515
import base64
16+
from pyforgejo import PyforgejoApi
1617

1718
class ForgejoRepoAPI(IRepositoryAPI):
1819
def __init__(self, client):
@@ -256,3 +257,50 @@ def get_comments(self, repo, obj) -> list[Comment]:
256257
def get_invites(self, repo: Repository) -> list[Invite]:
257258
return []
258259

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

Comments
 (0)