gitcode-api 1.2.18__py3-none-any.whl → 1.2.20__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -21,7 +21,7 @@ def _drop_none_values(mapping: Dict[str, Any]) -> Dict[str, Any]:
21
21
 
22
22
 
23
23
  def _default_decrypt(value: Any) -> str:
24
- """Dummy decryption function, basically a no-op."""
24
+ """Just a dummy decryption function, basically a no-op."""
25
25
  return value
26
26
 
27
27
 
gitcode_api/constants.py CHANGED
@@ -1,8 +1,25 @@
1
1
  """Shared constant values for the GitCode SDK."""
2
2
 
3
+ import re
4
+
3
5
  DEFAULT_BASE_URL = "https://api.gitcode.com/api/v5"
4
6
  DEFAULT_TIMEOUT = 30.0
5
7
  DEFAULT_TOKEN_ENV = "GITCODE_ACCESS_TOKEN"
6
8
  DEFAULT_CA_ENV = "GITCODE_CA_BUNDLE"
9
+ GITCODE_ISSUE_TEMPLATE_PATH_RE: re.Pattern[str] = re.compile(
10
+ r"\.git(code|hub)/ISSUE_TEMPLATE.*\.(md|markdown|ya?ml)$", re.IGNORECASE
11
+ )
12
+ GITCODE_PULL_REQUEST_TEMPLATE_PATH_RE: re.Pattern[str] = re.compile(
13
+ r"\.git(code|hub)/PULL_REQUEST_TEMPLATE.*\.(md|markdown|ya?ml)$", re.IGNORECASE
14
+ )
15
+ GITCODE_TEMPLATE_REPO = ".gitcode"
7
16
 
8
- __all__ = ["DEFAULT_BASE_URL", "DEFAULT_TIMEOUT", "DEFAULT_TOKEN_ENV", "DEFAULT_CA_ENV"]
17
+ __all__ = [
18
+ "DEFAULT_BASE_URL",
19
+ "DEFAULT_TIMEOUT",
20
+ "DEFAULT_TOKEN_ENV",
21
+ "DEFAULT_CA_ENV",
22
+ "GITCODE_ISSUE_TEMPLATE_PATH_RE",
23
+ "GITCODE_PULL_REQUEST_TEMPLATE_PATH_RE",
24
+ "GITCODE_TEMPLATE_REPO",
25
+ ]
@@ -1,19 +1,12 @@
1
1
  """Shared resource base classes for the GitCode SDK."""
2
2
 
3
- import re
4
3
  from typing import Any, Dict, List, Optional, Pattern, Tuple, Union
5
4
 
6
5
  from .._base_client import AsyncAPIClient, SyncAPIClient
7
6
  from .._base_resource import BaseResource
8
7
  from .._exceptions import GitCodeHTTPStatusError
9
8
  from .._models import APIObject, ModelT, as_model, as_model_list
10
-
11
- GITCODE_ISSUE_TEMPLATE_PATH_RE: Pattern[str] = re.compile(
12
- r"\.gitcode/ISSUE_TEMPLATE.*\.(md|markdown|ya?ml)$", re.IGNORECASE
13
- )
14
- GITCODE_PULL_REQUEST_TEMPLATE_PATH_RE: Pattern[str] = re.compile(
15
- r"\.gitcode/PULL_REQUEST_TEMPLATE.*\.(md|markdown|ya?ml)$", re.IGNORECASE
16
- )
9
+ from ..constants import GITCODE_TEMPLATE_REPO
17
10
 
18
11
 
19
12
  def _parse_parent_owner_repo(repo_obj: Any) -> Optional[Tuple[str, str]]:
@@ -50,7 +43,7 @@ def _resolution_sources_sync(client: SyncAPIClient, owner: str, repo: str) -> Li
50
43
  sources.append(pair)
51
44
 
52
45
  add((owner, repo))
53
- add((owner, ".gitcode"))
46
+ add((owner, GITCODE_TEMPLATE_REPO))
54
47
 
55
48
  max_candidates = 64
56
49
  index = 0
@@ -68,7 +61,7 @@ def _resolution_sources_sync(client: SyncAPIClient, owner: str, repo: str) -> Li
68
61
  continue
69
62
  po, pr = parsed
70
63
  add((po, pr))
71
- add((po, ".gitcode"))
64
+ add((po, GITCODE_TEMPLATE_REPO))
72
65
 
73
66
  return sources
74
67
 
@@ -86,7 +79,7 @@ async def _resolution_sources_async(client: AsyncAPIClient, owner: str, repo: st
86
79
  sources.append(pair)
87
80
 
88
81
  add((owner, repo))
89
- add((owner, ".gitcode"))
82
+ add((owner, GITCODE_TEMPLATE_REPO))
90
83
 
91
84
  max_candidates = 64
92
85
  index = 0
@@ -104,7 +97,7 @@ async def _resolution_sources_async(client: AsyncAPIClient, owner: str, repo: st
104
97
  continue
105
98
  po, pr = parsed
106
99
  add((po, pr))
107
- add((po, ".gitcode"))
100
+ add((po, GITCODE_TEMPLATE_REPO))
108
101
 
109
102
  return sources
110
103
 
@@ -210,6 +203,8 @@ def list_gitcode_template_rows_sync(
210
203
  acc: List[Tuple[str, str, str, str]] = []
211
204
  try:
212
205
  _walk_dot_gitcode_contents_sync(client, so, sr, ".gitcode", acc)
206
+ if sr != GITCODE_TEMPLATE_REPO:
207
+ _walk_dot_gitcode_contents_sync(client, so, sr, ".github", acc)
213
208
  except GitCodeHTTPStatusError:
214
209
  continue
215
210
  rows = [(t_o, t_r, p, s) for t_o, t_r, p, s in acc if path_pattern.match(p)]
@@ -224,10 +219,13 @@ async def list_gitcode_template_rows_async(
224
219
  repo: str,
225
220
  path_pattern: Pattern[str],
226
221
  ) -> List[Tuple[str, str, str, str]]:
222
+ """Return ``(template_owner, template_repo, path, sha)`` from the first resolution source with matches."""
227
223
  for so, sr in await _resolution_sources_async(client, owner, repo):
228
224
  acc: List[Tuple[str, str, str, str]] = []
229
225
  try:
230
226
  await _walk_dot_gitcode_contents_async(client, so, sr, ".gitcode", acc)
227
+ if sr != GITCODE_TEMPLATE_REPO:
228
+ await _walk_dot_gitcode_contents_async(client, so, sr, ".github", acc)
231
229
  except GitCodeHTTPStatusError:
232
230
  continue
233
231
  rows = [(t_o, t_r, p, s) for t_o, t_r, p, s in acc if path_pattern.match(p)]
@@ -242,6 +240,8 @@ def get_gitcode_template_body_sync(
242
240
  path_pattern: Pattern[str],
243
241
  owner: str,
244
242
  repo: str,
243
+ encoding: str = "utf-8",
244
+ **decoding_kwargs,
245
245
  ) -> str:
246
246
  """Fetch raw template text from the first resolution source that serves ``path``."""
247
247
  if not path_pattern.match(path):
@@ -262,7 +262,7 @@ def get_gitcode_template_body_sync(
262
262
  last_error = exc
263
263
  continue
264
264
  if isinstance(raw, bytes):
265
- return raw.decode("utf-8")
265
+ return raw.decode(encoding=encoding, **decoding_kwargs)
266
266
  if isinstance(raw, str):
267
267
  return raw
268
268
  return str(raw)
@@ -281,7 +281,10 @@ async def get_gitcode_template_body_async(
281
281
  path_pattern: Pattern[str],
282
282
  owner: str,
283
283
  repo: str,
284
+ encoding: str = "utf-8",
285
+ **decoding_kwargs,
284
286
  ) -> str:
287
+ """Fetch raw template text from the first resolution source that serves ``path``."""
285
288
  if not path_pattern.match(path):
286
289
  raise GitCodeHTTPStatusError(
287
290
  "Path does not match the expected GitCode template pattern for this resource.",
@@ -300,7 +303,7 @@ async def get_gitcode_template_body_async(
300
303
  last_error = exc
301
304
  continue
302
305
  if isinstance(raw, bytes):
303
- return raw.decode("utf-8")
306
+ return raw.decode(encoding=encoding, **decoding_kwargs)
304
307
  if isinstance(raw, str):
305
308
  return raw
306
309
  return str(raw)
@@ -909,37 +909,106 @@ class AsyncSearchResource(AsyncResource):
909
909
  see ``docs/rest_api/search`` and the synchronous methods for field meanings.
910
910
  """
911
911
 
912
- async def users(self, *, q: str, **params) -> List[SearchUser]:
912
+ async def users(
913
+ self,
914
+ *,
915
+ q: str,
916
+ page: Optional[int] = None,
917
+ per_page: Optional[int] = None,
918
+ sort: Optional[str] = None,
919
+ order: Optional[str] = None,
920
+ ) -> List[SearchUser]:
913
921
  """Search users.
914
922
 
915
- :param q: Search keywords (required).
916
- :param params: Optional query parameters merged into the request, such as ``page``,
917
- ``per_page``, ``sort``, and ``order`` (same meanings as :meth:`SearchResource.users`).
923
+ :param q: Search keywords.
924
+ :param page: Page number.
925
+ :param per_page: Page size.
926
+ :param sort: Optional sort field such as ``joined_at``.
927
+ :param order: Sort order, usually ``asc`` or ``desc``.
918
928
  :returns: Matching user search results.
919
929
  """
920
- return await self._models("GET", self._client._path("search", "users"), SearchUser, params={"q": q, **params})
930
+ return await self._models(
931
+ "GET",
932
+ self._client._path("search", "users"),
933
+ SearchUser,
934
+ params={"q": q, "page": page, "per_page": per_page, "sort": sort, "order": order},
935
+ )
921
936
 
922
- async def issues(self, *, q: str, **params) -> List[SearchIssue]:
937
+ async def issues(
938
+ self,
939
+ *,
940
+ q: str,
941
+ page: Optional[int] = None,
942
+ per_page: Optional[int] = None,
943
+ sort: Optional[str] = None,
944
+ order: Optional[str] = None,
945
+ repo: Optional[str] = None,
946
+ state: Optional[str] = None,
947
+ ) -> List[SearchIssue]:
923
948
  """Search issues.
924
949
 
925
- :param q: Search keywords (required).
926
- :param params: Optional query parameters merged into the request, such as ``page``,
927
- ``per_page``, ``sort``, ``order``, ``repo``, and ``state`` (see :meth:`SearchResource.issues`).
950
+ :param q: Search keywords.
951
+ :param page: Page number.
952
+ :param per_page: Page size.
953
+ :param sort: Optional sort field.
954
+ :param order: Sort order, usually ``asc`` or ``desc``.
955
+ :param repo: Optional repository path filter.
956
+ :param state: Optional issue state filter.
928
957
  :returns: Matching issue search results.
929
958
  """
930
- return await self._models("GET", self._client._path("search", "issues"), SearchIssue, params={"q": q, **params})
959
+ return await self._models(
960
+ "GET",
961
+ self._client._path("search", "issues"),
962
+ SearchIssue,
963
+ params={
964
+ "q": q,
965
+ "page": page,
966
+ "per_page": per_page,
967
+ "sort": sort,
968
+ "order": order,
969
+ "repo": repo,
970
+ "state": state,
971
+ },
972
+ )
931
973
 
932
- async def repositories(self, *, q: str, **params) -> List[SearchRepository]:
974
+ async def repositories(
975
+ self,
976
+ *,
977
+ q: str,
978
+ page: Optional[int] = None,
979
+ per_page: Optional[int] = None,
980
+ sort: Optional[str] = None,
981
+ order: Optional[str] = None,
982
+ owner: Optional[str] = None,
983
+ fork: Optional[str] = None,
984
+ language: Optional[str] = None,
985
+ ) -> List[SearchRepository]:
933
986
  """Search repositories.
934
987
 
935
- :param q: Search keywords (required).
936
- :param params: Optional query parameters merged into the request, such as ``page``,
937
- ``per_page``, ``sort``, ``order``, ``owner``, ``fork``, and ``language``
938
- (see :meth:`SearchResource.repositories`).
988
+ :param q: Search keywords.
989
+ :param page: Page number.
990
+ :param per_page: Page size.
991
+ :param sort: Optional sort field such as ``stars_count``.
992
+ :param order: Sort order, usually ``asc`` or ``desc``.
993
+ :param owner: Optional owner path filter.
994
+ :param fork: Optional fork visibility filter.
995
+ :param language: Optional programming language filter.
939
996
  :returns: Matching repository search results.
940
997
  """
941
998
  return await self._models(
942
- "GET", self._client._path("search", "repositories"), SearchRepository, params={"q": q, **params}
999
+ "GET",
1000
+ self._client._path("search", "repositories"),
1001
+ SearchRepository,
1002
+ params={
1003
+ "q": q,
1004
+ "page": page,
1005
+ "per_page": per_page,
1006
+ "sort": sort,
1007
+ "order": order,
1008
+ "owner": owner,
1009
+ "fork": fork,
1010
+ "language": language,
1011
+ },
943
1012
  )
944
1013
 
945
1014
 
@@ -25,9 +25,8 @@ from .._models import (
25
25
  UserSummary,
26
26
  as_model,
27
27
  )
28
+ from ..constants import GITCODE_ISSUE_TEMPLATE_PATH_RE, GITCODE_PULL_REQUEST_TEMPLATE_PATH_RE
28
29
  from ._shared import (
29
- GITCODE_ISSUE_TEMPLATE_PATH_RE,
30
- GITCODE_PULL_REQUEST_TEMPLATE_PATH_RE,
31
30
  AsyncResource,
32
31
  SyncResource,
33
32
  get_gitcode_template_body_async,
@@ -420,6 +419,8 @@ class IssuesResource(SyncResource):
420
419
  are appended, deduplicated, and visited in order). The first source with matching
421
420
  templates wins.
422
421
 
422
+ Version 1.2.19: Now also supporting GitHub-mirrored repos with a ``.github/`` folder.
423
+
423
424
  :param owner: Repository owner path. Uses the client default when omitted.
424
425
  :param repo: Repository name. Uses the client default when omitted.
425
426
  :returns: Template metadata entries (paths and SHAs); empty when none match.
@@ -441,7 +442,15 @@ class IssuesResource(SyncResource):
441
442
  for template_owner, template_repo, path, sha in rows
442
443
  ]
443
444
 
444
- def get_template(self, *, path: str, owner: Optional[str] = None, repo: Optional[str] = None) -> str:
445
+ def get_template(
446
+ self,
447
+ *,
448
+ path: str,
449
+ owner: Optional[str] = None,
450
+ repo: Optional[str] = None,
451
+ encoding: str = "utf-8",
452
+ **decoding_kwargs,
453
+ ) -> str:
445
454
  """Load a single issue template file body from the default branch.
446
455
 
447
456
  Uses the same resolution order as :meth:`list_templates`. The path must match the
@@ -451,11 +460,20 @@ class IssuesResource(SyncResource):
451
460
  ``.gitcode/ISSUE_TEMPLATE/config.yml``.
452
461
  :param owner: Repository owner path. Uses the client default when omitted.
453
462
  :param repo: Repository name. Uses the client default when omitted.
454
- :returns: Decoded template file contents (UTF-8).
463
+ :param encoding: Codec to use when decoding raw file bytes. Default ``utf-8``.
464
+ :param decoding_kwargs: Keyword arguments forwarded to :meth:`bytes.decode`, such as
465
+ ``errors`` (``"strict"``, ``"ignore"``, or ``"replace"``).
466
+ :returns: Decoded template file contents.
455
467
  """
456
468
  resolved_owner, resolved_repo = self._client._resolve_repo_context(owner, repo)
457
469
  return get_gitcode_template_body_sync(
458
- self._client, path, GITCODE_ISSUE_TEMPLATE_PATH_RE, resolved_owner, resolved_repo
470
+ self._client,
471
+ path,
472
+ GITCODE_ISSUE_TEMPLATE_PATH_RE,
473
+ resolved_owner,
474
+ resolved_repo,
475
+ encoding=encoding,
476
+ **decoding_kwargs,
459
477
  )
460
478
 
461
479
 
@@ -490,7 +508,7 @@ class PullsResource(SyncResource):
490
508
  ``since``, ``author``, ``assignee``, ``reviewer``, ``milestone_number``, ``labels`` (comma-separated),
491
509
  ``merged_after``, ``merged_before``, ``created_after``, ``created_before``, ``updated_after``,
492
510
  ``updated_before``, ``only_count`` (boolean), and ISO 8601 timestamps (URL-encoded when sent).
493
- :returns: A list of pull requests, or an :class:`~gitcode_api._models.APIObject` when the response is a count object.
511
+ :returns: A list of pull requests, or an :class:`~gitcode_api._models.APIObject` for count-only responses.
494
512
  """
495
513
  path = self._client._repo_path("pulls", owner=owner, repo=repo)
496
514
  response = self._request(
@@ -1067,6 +1085,8 @@ class PullsResource(SyncResource):
1067
1085
  are appended, deduplicated, and visited in order). The first source with matching
1068
1086
  templates wins.
1069
1087
 
1088
+ Version 1.2.19: Now also supporting GitHub-mirrored repos with a ``.github/`` folder.
1089
+
1070
1090
  :param owner: Repository owner path. Uses the client default when omitted.
1071
1091
  :param repo: Repository path. Uses the client default when omitted.
1072
1092
  :returns: Template metadata entries (paths and SHAs); empty when none match.
@@ -1088,7 +1108,15 @@ class PullsResource(SyncResource):
1088
1108
  for template_owner, template_repo, path, sha in rows
1089
1109
  ]
1090
1110
 
1091
- def get_template(self, *, path: str, owner: Optional[str] = None, repo: Optional[str] = None) -> str:
1111
+ def get_template(
1112
+ self,
1113
+ *,
1114
+ path: str,
1115
+ owner: Optional[str] = None,
1116
+ repo: Optional[str] = None,
1117
+ encoding: str = "utf-8",
1118
+ **decoding_kwargs,
1119
+ ) -> str:
1092
1120
  """Load a single pull request template file body from the default branch.
1093
1121
 
1094
1122
  Uses the same resolution order as :meth:`list_templates`. The path must match the
@@ -1097,11 +1125,20 @@ class PullsResource(SyncResource):
1097
1125
  :param path: Repository-relative path such as ``.gitcode/PULL_REQUEST_TEMPLATE.md``.
1098
1126
  :param owner: Repository owner path. Uses the client default when omitted.
1099
1127
  :param repo: Repository path. Uses the client default when omitted.
1100
- :returns: Decoded template file contents (UTF-8).
1128
+ :param encoding: Codec to use when decoding raw file bytes. Default ``utf-8``.
1129
+ :param decoding_kwargs: Keyword arguments forwarded to :meth:`bytes.decode`, such as
1130
+ ``errors`` (``"strict"``, ``"ignore"``, or ``"replace"``).
1131
+ :returns: Decoded template file contents.
1101
1132
  """
1102
1133
  resolved_owner, resolved_repo = self._client._resolve_repo_context(owner, repo)
1103
1134
  return get_gitcode_template_body_sync(
1104
- self._client, path, GITCODE_PULL_REQUEST_TEMPLATE_PATH_RE, resolved_owner, resolved_repo
1135
+ self._client,
1136
+ path,
1137
+ GITCODE_PULL_REQUEST_TEMPLATE_PATH_RE,
1138
+ resolved_owner,
1139
+ resolved_repo,
1140
+ encoding=encoding,
1141
+ **decoding_kwargs,
1105
1142
  )
1106
1143
 
1107
1144
 
@@ -1411,16 +1448,39 @@ class AsyncIssuesResource(AsyncResource):
1411
1448
  parameter descriptions aligned with ``docs/rest_api`` (Issues API).
1412
1449
  """
1413
1450
 
1414
- async def list(self, *, owner: Optional[str] = None, repo: Optional[str] = None, **params) -> List[Issue]:
1451
+ async def list(
1452
+ self,
1453
+ *,
1454
+ owner: Optional[str] = None,
1455
+ repo: Optional[str] = None,
1456
+ state: Optional[str] = None,
1457
+ sort: Optional[str] = None,
1458
+ direction: Optional[str] = None,
1459
+ page: Optional[int] = None,
1460
+ per_page: Optional[int] = None,
1461
+ ) -> List[Issue]:
1415
1462
  """List issues for a repository.
1416
1463
 
1417
1464
  :param owner: Repository owner path. Uses the client default when omitted.
1418
1465
  :param repo: Repository name. Uses the client default when omitted.
1419
- :param params: Query parameters such as ``state``, ``sort``, ``direction``, ``page``, ``per_page``.
1466
+ :param state: Issue state filter such as ``open`` or ``closed`` (see Issues API).
1467
+ :param sort: Optional sort field.
1468
+ :param direction: Optional sort direction.
1469
+ :param page: Page number.
1470
+ :param per_page: Page size.
1420
1471
  :returns: Matching issues.
1421
1472
  """
1422
1473
  return await self._models(
1423
- "GET", self._client._repo_path("issues", owner=owner, repo=repo), Issue, params=params
1474
+ "GET",
1475
+ self._client._repo_path("issues", owner=owner, repo=repo),
1476
+ Issue,
1477
+ params={
1478
+ "state": state,
1479
+ "sort": sort,
1480
+ "direction": direction,
1481
+ "page": page,
1482
+ "per_page": per_page,
1483
+ },
1424
1484
  )
1425
1485
 
1426
1486
  async def get(self, *, number: Union[int, str], owner: Optional[str] = None, repo: Optional[str] = None) -> Issue:
@@ -1519,21 +1579,28 @@ class AsyncIssuesResource(AsyncResource):
1519
1579
  )
1520
1580
 
1521
1581
  async def list_comments(
1522
- self, *, number: Union[int, str], owner: Optional[str] = None, repo: Optional[str] = None, **params
1582
+ self,
1583
+ *,
1584
+ number: Union[int, str],
1585
+ owner: Optional[str] = None,
1586
+ repo: Optional[str] = None,
1587
+ page: Optional[int] = None,
1588
+ per_page: Optional[int] = None,
1523
1589
  ) -> List[IssueComment]:
1524
1590
  """List comments for an issue.
1525
1591
 
1526
1592
  :param number: Repository-local issue number.
1527
1593
  :param owner: Repository owner path. Uses the client default when omitted.
1528
1594
  :param repo: Repository path (name). Uses the client default when omitted.
1529
- :param params: Optional query parameters (for example ``page``, ``per_page``).
1595
+ :param page: Current page number (query).
1596
+ :param per_page: Page size; maximum per REST API is typically 100.
1530
1597
  :returns: Issue comments.
1531
1598
  """
1532
1599
  return await self._models(
1533
1600
  "GET",
1534
1601
  self._client._repo_path("issues", number, "comments", owner=owner, repo=repo),
1535
1602
  IssueComment,
1536
- params=params,
1603
+ params={"page": page, "per_page": per_page},
1537
1604
  )
1538
1605
 
1539
1606
  async def create_comment(
@@ -1701,19 +1768,22 @@ class AsyncIssuesResource(AsyncResource):
1701
1768
  "GET", self._client._path("enterprises", enterprise, "issues", issue_id, "labels"), Label
1702
1769
  )
1703
1770
 
1704
- async def list_operation_logs(self, *, owner: str, number: Union[int, str], **params) -> List[IssueOperationLog]:
1771
+ async def list_operation_logs(
1772
+ self, *, owner: str, number: Union[int, str], page: Optional[int] = None, per_page: Optional[int] = None
1773
+ ) -> List[IssueOperationLog]:
1705
1774
  """List operation (audit) logs for an issue.
1706
1775
 
1707
1776
  :param owner: Repository owner path (path segment ``repos/{owner}/...`` for this endpoint).
1708
1777
  :param number: Repository-local issue number.
1709
- :param params: Optional query parameters (for example ``page``, ``per_page``).
1778
+ :param page: Page number.
1779
+ :param per_page: Page size.
1710
1780
  :returns: Operation log entries.
1711
1781
  """
1712
1782
  return await self._models(
1713
1783
  "GET",
1714
1784
  self._client._path("repos", owner, "issues", number, "operate_logs"),
1715
1785
  IssueOperationLog,
1716
- params=params,
1786
+ params={"page": page, "per_page": per_page},
1717
1787
  )
1718
1788
 
1719
1789
  async def list_templates(
@@ -1734,6 +1804,8 @@ class AsyncIssuesResource(AsyncResource):
1734
1804
  are appended, deduplicated, and visited in order). The first source with matching
1735
1805
  templates wins.
1736
1806
 
1807
+ Version 1.2.19: Now also supporting GitHub-mirrored repos with a ``.github/`` folder.
1808
+
1737
1809
  :param owner: Repository owner path. Uses the client default when omitted.
1738
1810
  :param repo: Repository name. Uses the client default when omitted.
1739
1811
  :returns: Template metadata entries (paths and SHAs); empty when none match.
@@ -1755,7 +1827,15 @@ class AsyncIssuesResource(AsyncResource):
1755
1827
  for template_owner, template_repo, path, sha in rows
1756
1828
  ]
1757
1829
 
1758
- async def get_template(self, *, path: str, owner: Optional[str] = None, repo: Optional[str] = None) -> str:
1830
+ async def get_template(
1831
+ self,
1832
+ *,
1833
+ path: str,
1834
+ owner: Optional[str] = None,
1835
+ repo: Optional[str] = None,
1836
+ encoding: str = "utf-8",
1837
+ **decoding_kwargs,
1838
+ ) -> str:
1759
1839
  """Load a single issue template file body from the default branch.
1760
1840
 
1761
1841
  Uses the same resolution order as :meth:`list_templates`. The path must match the
@@ -1765,11 +1845,20 @@ class AsyncIssuesResource(AsyncResource):
1765
1845
  ``.gitcode/ISSUE_TEMPLATE/config.yml``.
1766
1846
  :param owner: Repository owner path. Uses the client default when omitted.
1767
1847
  :param repo: Repository name. Uses the client default when omitted.
1768
- :returns: Decoded template file contents (UTF-8).
1848
+ :param encoding: Codec to use when decoding raw file bytes. Default ``utf-8``.
1849
+ :param decoding_kwargs: Keyword arguments forwarded to :meth:`bytes.decode`, such as
1850
+ ``errors`` (``"strict"``, ``"ignore"``, or ``"replace"``).
1851
+ :returns: Decoded template file contents.
1769
1852
  """
1770
1853
  resolved_owner, resolved_repo = self._client._resolve_repo_context(owner, repo)
1771
1854
  return await get_gitcode_template_body_async(
1772
- self._client, path, GITCODE_ISSUE_TEMPLATE_PATH_RE, resolved_owner, resolved_repo
1855
+ self._client,
1856
+ path,
1857
+ GITCODE_ISSUE_TEMPLATE_PATH_RE,
1858
+ resolved_owner,
1859
+ resolved_repo,
1860
+ encoding=encoding,
1861
+ **decoding_kwargs,
1773
1862
  )
1774
1863
 
1775
1864
 
@@ -1781,21 +1870,47 @@ class AsyncPullsResource(AsyncResource):
1781
1870
  """
1782
1871
 
1783
1872
  async def list(
1784
- self, *, owner: Optional[str] = None, repo: Optional[str] = None, **params
1873
+ self,
1874
+ *,
1875
+ owner: Optional[str] = None,
1876
+ repo: Optional[str] = None,
1877
+ state: Optional[str] = None,
1878
+ sort: Optional[str] = None,
1879
+ direction: Optional[str] = None,
1880
+ page: Optional[int] = None,
1881
+ per_page: Optional[int] = None,
1882
+ **params,
1785
1883
  ) -> Union[List[PullRequest], PullRequestCount]:
1786
1884
  """List pull requests for a repository.
1787
1885
 
1788
- When ``only_count`` is true in ``params``, the API returns a JSON object with counts per state
1789
- instead of an array (see Pull Request API).
1886
+ When ``only_count`` is true in ``params`` (or passed via ``**params``), the API returns a
1887
+ JSON object with counts per state instead of an array (see Pull Request API).
1790
1888
 
1791
1889
  :param owner: Repository owner path. Uses the client default when omitted.
1792
1890
  :param repo: Repository path (name). Uses the client default when omitted.
1793
- :param params: Query parameters: ``state``, ``sort``, ``direction``, ``page``, ``per_page``, ``base``,
1794
- ``since``, ``author``, ``assignee``, ``reviewer``, ``milestone_number``, ``labels``, time filters,
1795
- ``only_count``, and other fields documented under ``docs/rest_api``.
1891
+ :param state: PR state filter: ``all``, ``open``, ``closed``, ``locked``, ``merged`` (default ``all`` in API).
1892
+ :param sort: Sort field, typically ``created`` or ``updated``.
1893
+ :param direction: ``asc`` or ``desc`` (API default is usually ``desc``).
1894
+ :param page: Current page number.
1895
+ :param per_page: Page size (max 100 per API documentation).
1896
+ :param params: Extra query parameters from the Pull Request API, for example ``base``,
1897
+ ``since``, ``author``, ``assignee``, ``reviewer``, ``milestone_number``, ``labels`` (comma-separated),
1898
+ ``merged_after``, ``merged_before``, ``created_after``, ``created_before``, ``updated_after``,
1899
+ ``updated_before``, ``only_count`` (boolean), and ISO 8601 timestamps (URL-encoded when sent).
1796
1900
  :returns: A list of pull requests, or an :class:`~gitcode_api._models.APIObject` for count-only responses.
1797
1901
  """
1798
- response = await self._request("GET", self._client._repo_path("pulls", owner=owner, repo=repo), params=params)
1902
+ response = await self._request(
1903
+ "GET",
1904
+ self._client._repo_path("pulls", owner=owner, repo=repo),
1905
+ params={
1906
+ "state": state,
1907
+ "sort": sort,
1908
+ "direction": direction,
1909
+ "page": page,
1910
+ "per_page": per_page,
1911
+ **params,
1912
+ },
1913
+ )
1799
1914
  if isinstance(response, dict):
1800
1915
  return as_model(response, PullRequestCount)
1801
1916
  return [as_model(item, PullRequest) for item in response]
@@ -1981,21 +2096,28 @@ class AsyncPullsResource(AsyncResource):
1981
2096
  )
1982
2097
 
1983
2098
  async def list_comments(
1984
- self, *, number: Union[int, str], owner: Optional[str] = None, repo: Optional[str] = None, **params
2099
+ self,
2100
+ *,
2101
+ number: Union[int, str],
2102
+ owner: Optional[str] = None,
2103
+ repo: Optional[str] = None,
2104
+ page: Optional[int] = None,
2105
+ per_page: Optional[int] = None,
1985
2106
  ) -> List[PullRequestComment]:
1986
2107
  """List comments on a pull request.
1987
2108
 
1988
2109
  :param number: Pull request number.
1989
2110
  :param owner: Repository owner path. Uses the client default when omitted.
1990
2111
  :param repo: Repository path. Uses the client default when omitted.
1991
- :param params: Optional query parameters (for example ``page``, ``per_page``).
2112
+ :param page: Page number.
2113
+ :param per_page: Page size.
1992
2114
  :returns: Pull request review comments.
1993
2115
  """
1994
2116
  return await self._models(
1995
2117
  "GET",
1996
2118
  self._client._repo_path("pulls", number, "comments", owner=owner, repo=repo),
1997
2119
  PullRequestComment,
1998
- params=params,
2120
+ params={"page": page, "per_page": per_page},
1999
2121
  )
2000
2122
 
2001
2123
  async def create_comment(
@@ -2328,6 +2450,8 @@ class AsyncPullsResource(AsyncResource):
2328
2450
  are appended, deduplicated, and visited in order). The first source with matching
2329
2451
  templates wins.
2330
2452
 
2453
+ Version 1.2.19: Now also supporting GitHub-mirrored repos with a ``.github/`` folder.
2454
+
2331
2455
  :param owner: Repository owner path. Uses the client default when omitted.
2332
2456
  :param repo: Repository path. Uses the client default when omitted.
2333
2457
  :returns: Template metadata entries (paths and SHAs); empty when none match.
@@ -2349,7 +2473,15 @@ class AsyncPullsResource(AsyncResource):
2349
2473
  for template_owner, template_repo, path, sha in rows
2350
2474
  ]
2351
2475
 
2352
- async def get_template(self, *, path: str, owner: Optional[str] = None, repo: Optional[str] = None) -> str:
2476
+ async def get_template(
2477
+ self,
2478
+ *,
2479
+ path: str,
2480
+ owner: Optional[str] = None,
2481
+ repo: Optional[str] = None,
2482
+ encoding: str = "utf-8",
2483
+ **decoding_kwargs,
2484
+ ) -> str:
2353
2485
  """Load a single pull request template file body from the default branch.
2354
2486
 
2355
2487
  Uses the same resolution order as :meth:`list_templates`. The path must match the
@@ -2358,11 +2490,20 @@ class AsyncPullsResource(AsyncResource):
2358
2490
  :param path: Repository-relative path such as ``.gitcode/PULL_REQUEST_TEMPLATE.md``.
2359
2491
  :param owner: Repository owner path. Uses the client default when omitted.
2360
2492
  :param repo: Repository path. Uses the client default when omitted.
2361
- :returns: Decoded template file contents (UTF-8).
2493
+ :param encoding: Codec to use when decoding raw file bytes. Default ``utf-8``.
2494
+ :param decoding_kwargs: Keyword arguments forwarded to :meth:`bytes.decode`, such as
2495
+ ``errors`` (``"strict"``, ``"ignore"``, or ``"replace"``).
2496
+ :returns: Decoded template file contents.
2362
2497
  """
2363
2498
  resolved_owner, resolved_repo = self._client._resolve_repo_context(owner, repo)
2364
2499
  return await get_gitcode_template_body_async(
2365
- self._client, path, GITCODE_PULL_REQUEST_TEMPLATE_PATH_RE, resolved_owner, resolved_repo
2500
+ self._client,
2501
+ path,
2502
+ GITCODE_PULL_REQUEST_TEMPLATE_PATH_RE,
2503
+ resolved_owner,
2504
+ resolved_repo,
2505
+ encoding=encoding,
2506
+ **decoding_kwargs,
2366
2507
  )
2367
2508
 
2368
2509
 
@@ -1133,46 +1133,181 @@ class AsyncReposResource(AsyncResource):
1133
1133
  """
1134
1134
  return await self._model("GET", self._client._repo_path(owner=owner, repo=repo), Repository)
1135
1135
 
1136
- async def list_user(self, **params) -> List[Repository]:
1136
+ async def list_user(
1137
+ self,
1138
+ *,
1139
+ visibility: Optional[str] = None,
1140
+ affiliation: Optional[str] = None,
1141
+ type: Optional[str] = None,
1142
+ sort: Optional[str] = None,
1143
+ direction: Optional[str] = None,
1144
+ q: Optional[str] = None,
1145
+ page: Optional[int] = None,
1146
+ per_page: Optional[int] = None,
1147
+ ) -> List[Repository]:
1137
1148
  """List repositories visible to the authenticated user.
1138
1149
 
1139
- Pass query parameters as keyword arguments (same names as :meth:`ReposResource.list_user`,
1140
- for example ``visibility``, ``affiliation``, ``type``, ``sort``, ``direction``, ``q``, ``page``, ``per_page``).
1141
-
1142
- :param params: Query parameters for ``GET /user/repos``.
1150
+ :param visibility: Visibility filter such as ``public``, ``private``, or ``all``.
1151
+ :param affiliation: Ownership filter accepted by the REST API.
1152
+ :param type: Repository type filter.
1153
+ :param sort: Sort field such as ``created`` or ``full_name``.
1154
+ :param direction: Sort direction.
1155
+ :param q: Optional keyword filter.
1156
+ :param page: Page number.
1157
+ :param per_page: Page size.
1143
1158
  :returns: Matching repositories.
1144
1159
  """
1145
- return await self._models("GET", self._client._path("user", "repos"), Repository, params=params)
1160
+ return await self._models(
1161
+ "GET",
1162
+ self._client._path("user", "repos"),
1163
+ Repository,
1164
+ params={
1165
+ "visibility": visibility,
1166
+ "affiliation": affiliation,
1167
+ "type": type,
1168
+ "sort": sort,
1169
+ "direction": direction,
1170
+ "q": q,
1171
+ "page": page,
1172
+ "per_page": per_page,
1173
+ },
1174
+ )
1146
1175
 
1147
- async def list_for_owner(self, *, owner: str, **params) -> List[Repository]:
1176
+ async def list_for_owner(
1177
+ self,
1178
+ *,
1179
+ owner: str,
1180
+ type: Optional[str] = None,
1181
+ sort: Optional[str] = None,
1182
+ direction: Optional[str] = None,
1183
+ page: Optional[int] = None,
1184
+ per_page: Optional[int] = None,
1185
+ ) -> List[Repository]:
1148
1186
  """List public repositories for a user or owner path.
1149
1187
 
1150
1188
  :param owner: Repository owner path or username.
1151
- :param params: Query parameters such as ``type``, ``sort``, ``direction``, ``page``, ``per_page``.
1189
+ :param type: Repository type filter.
1190
+ :param sort: Sort field.
1191
+ :param direction: Sort direction.
1192
+ :param page: Page number.
1193
+ :param per_page: Page size.
1152
1194
  :returns: Matching repositories.
1153
1195
  """
1154
- return await self._models("GET", self._client._path("users", owner, "repos"), Repository, params=params)
1196
+ return await self._models(
1197
+ "GET",
1198
+ self._client._path("users", owner, "repos"),
1199
+ Repository,
1200
+ params={
1201
+ "type": type,
1202
+ "sort": sort,
1203
+ "direction": direction,
1204
+ "page": page,
1205
+ "per_page": per_page,
1206
+ },
1207
+ )
1155
1208
 
1156
- async def create_personal(self, *, name: str, **payload) -> Repository:
1209
+ async def create_personal(
1210
+ self,
1211
+ *,
1212
+ name: str,
1213
+ description: Optional[str] = None,
1214
+ path: Optional[str] = None,
1215
+ private: Optional[bool] = None,
1216
+ auto_init: Optional[bool] = None,
1217
+ has_issues: Optional[bool] = None,
1218
+ has_wiki: Optional[bool] = None,
1219
+ default_branch: Optional[str] = None,
1220
+ gitignore_template: Optional[str] = None,
1221
+ license_template: Optional[str] = None,
1222
+ ) -> Repository:
1157
1223
  """Create a repository for the authenticated user.
1158
1224
 
1159
- :param name: Repository name (also written into ``payload``).
1160
- :param payload: Additional JSON fields; see :meth:`ReposResource.create_personal` for supported keys.
1225
+ :param name: Repository name.
1226
+ :param description: Repository description.
1227
+ :param path: Optional repository path.
1228
+ :param private: Whether the repository should be private.
1229
+ :param auto_init: Whether to initialize the repository with a README.
1230
+ :param has_issues: Whether issues are enabled.
1231
+ :param has_wiki: Whether wiki support is enabled.
1232
+ :param default_branch: Default branch name when initializing.
1233
+ :param gitignore_template: Optional gitignore template.
1234
+ :param license_template: Optional license template.
1161
1235
  :returns: Created repository metadata.
1162
1236
  """
1163
- payload["name"] = name
1164
- return await self._model("POST", self._client._path("user", "repos"), Repository, json=payload)
1237
+ return await self._model(
1238
+ "POST",
1239
+ self._client._path("user", "repos"),
1240
+ Repository,
1241
+ json={
1242
+ "name": name,
1243
+ "description": description,
1244
+ "path": path,
1245
+ "private": private,
1246
+ "auto_init": auto_init,
1247
+ "has_issues": has_issues,
1248
+ "has_wiki": has_wiki,
1249
+ "default_branch": default_branch,
1250
+ "gitignore_template": gitignore_template,
1251
+ "license_template": license_template,
1252
+ },
1253
+ )
1165
1254
 
1166
- async def create_for_org(self, *, org: str, name: str, **payload) -> Repository:
1255
+ async def create_for_org(
1256
+ self,
1257
+ *,
1258
+ org: str,
1259
+ name: str,
1260
+ description: Optional[str] = None,
1261
+ homepage: Optional[str] = None,
1262
+ path: Optional[str] = None,
1263
+ private: Optional[bool] = None,
1264
+ public: Optional[int] = None,
1265
+ auto_init: Optional[bool] = None,
1266
+ has_issues: Optional[bool] = None,
1267
+ has_wiki: Optional[bool] = None,
1268
+ can_comment: Optional[bool] = None,
1269
+ default_branch: Optional[str] = None,
1270
+ gitignore_template: Optional[str] = None,
1271
+ license_template: Optional[str] = None,
1272
+ ) -> Repository:
1167
1273
  """Create a repository under an organization.
1168
1274
 
1169
1275
  :param org: Organization path or login.
1170
- :param name: Repository name (also written into ``payload``).
1171
- :param payload: Additional JSON fields; see :meth:`ReposResource.create_for_org`.
1276
+ :param name: Repository name.
1277
+ :param description: Repository description.
1278
+ :param homepage: Repository homepage URL.
1279
+ :param path: Optional repository path.
1280
+ :param private: Whether the repository should be private.
1281
+ :param public: Visibility mode used by the GitCode API.
1282
+ :param auto_init: Whether to initialize the repository with a README.
1283
+ :param has_issues: Whether issues are enabled.
1284
+ :param has_wiki: Whether wiki support is enabled.
1285
+ :param can_comment: Whether comments are enabled.
1286
+ :param default_branch: Default branch name when initializing.
1287
+ :param gitignore_template: Optional gitignore template.
1288
+ :param license_template: Optional license template.
1172
1289
  :returns: Created repository metadata.
1173
1290
  """
1174
- payload["name"] = name
1175
- return await self._model("POST", self._client._path("orgs", org, "repos"), Repository, json=payload)
1291
+ return await self._model(
1292
+ "POST",
1293
+ self._client._path("orgs", org, "repos"),
1294
+ Repository,
1295
+ json={
1296
+ "name": name,
1297
+ "description": description,
1298
+ "homepage": homepage,
1299
+ "path": path,
1300
+ "private": private,
1301
+ "public": public,
1302
+ "auto_init": auto_init,
1303
+ "has_issues": has_issues,
1304
+ "has_wiki": has_wiki,
1305
+ "can_comment": can_comment,
1306
+ "default_branch": default_branch,
1307
+ "gitignore_template": gitignore_template,
1308
+ "license_template": license_template,
1309
+ },
1310
+ )
1176
1311
 
1177
1312
  async def update(self, *, owner: Optional[str] = None, repo: Optional[str] = None, **changes) -> Repository:
1178
1313
  """Update repository metadata.
@@ -1192,47 +1327,77 @@ class AsyncReposResource(AsyncResource):
1192
1327
  """
1193
1328
  await self._request("DELETE", self._client._repo_path(owner=owner, repo=repo))
1194
1329
 
1195
- async def fork(self, *, owner: Optional[str] = None, repo: Optional[str] = None, **payload) -> Repository:
1330
+ async def fork(
1331
+ self,
1332
+ *,
1333
+ owner: Optional[str] = None,
1334
+ repo: Optional[str] = None,
1335
+ namespace: Optional[str] = None,
1336
+ path: Optional[str] = None,
1337
+ name: Optional[str] = None,
1338
+ ) -> Repository:
1196
1339
  """Fork a repository.
1197
1340
 
1198
- :param owner: Source repository owner path. Uses the client default when omitted.
1199
- :param repo: Source repository name. Uses the client default when omitted.
1200
- :param payload: JSON body fields such as ``namespace``, ``path``, and ``name`` (see :meth:`ReposResource.fork`).
1341
+ :param owner: Source repository owner path.
1342
+ :param repo: Source repository name.
1343
+ :param namespace: Optional destination namespace.
1344
+ :param path: Optional destination repository path.
1345
+ :param name: Optional destination repository name.
1201
1346
  :returns: Forked repository metadata.
1202
1347
  """
1203
1348
  return await self._model(
1204
- "POST", self._client._repo_path("forks", owner=owner, repo=repo), Repository, json=payload
1349
+ "POST",
1350
+ self._client._repo_path("forks", owner=owner, repo=repo),
1351
+ Repository,
1352
+ json={"namespace": namespace, "path": path, "name": name},
1205
1353
  )
1206
1354
 
1207
1355
  async def list_forks(
1208
- self, *, owner: Optional[str] = None, repo: Optional[str] = None, **params
1356
+ self,
1357
+ *,
1358
+ owner: Optional[str] = None,
1359
+ repo: Optional[str] = None,
1360
+ sort: Optional[str] = None,
1361
+ page: Optional[int] = None,
1362
+ per_page: Optional[int] = None,
1209
1363
  ) -> List[Repository]:
1210
1364
  """List forks of a repository.
1211
1365
 
1212
1366
  :param owner: Repository owner path. Uses the client default when omitted.
1213
1367
  :param repo: Repository name. Uses the client default when omitted.
1214
- :param params: Query parameters such as ``sort``, ``page``, ``per_page``.
1368
+ :param sort: Optional sort field.
1369
+ :param page: Page number.
1370
+ :param per_page: Page size.
1215
1371
  :returns: Fork repositories.
1216
1372
  """
1217
1373
  return await self._models(
1218
- "GET", self._client._repo_path("forks", owner=owner, repo=repo), Repository, params=params
1374
+ "GET",
1375
+ self._client._repo_path("forks", owner=owner, repo=repo),
1376
+ Repository,
1377
+ params={"sort": sort, "page": page, "per_page": per_page},
1219
1378
  )
1220
1379
 
1221
1380
  async def list_contributors(
1222
- self, *, owner: Optional[str] = None, repo: Optional[str] = None, **params
1381
+ self,
1382
+ *,
1383
+ owner: Optional[str] = None,
1384
+ repo: Optional[str] = None,
1385
+ page: Optional[int] = None,
1386
+ per_page: Optional[int] = None,
1223
1387
  ) -> List[Contributor]:
1224
1388
  """List repository contributors.
1225
1389
 
1226
1390
  :param owner: Repository owner path. Uses the client default when omitted.
1227
1391
  :param repo: Repository name. Uses the client default when omitted.
1228
- :param params: Query parameters such as ``page`` and ``per_page``.
1392
+ :param page: Page number.
1393
+ :param per_page: Page size.
1229
1394
  :returns: Contributors for the repository.
1230
1395
  """
1231
1396
  return await self._models(
1232
1397
  "GET",
1233
1398
  self._client._repo_path("contributors", owner=owner, repo=repo),
1234
1399
  Contributor,
1235
- params=params,
1400
+ params={"page": page, "per_page": per_page},
1236
1401
  )
1237
1402
 
1238
1403
  async def list_languages(self, *, owner: Optional[str] = None, repo: Optional[str] = None) -> Dict[str, int]:
@@ -1245,34 +1410,49 @@ class AsyncReposResource(AsyncResource):
1245
1410
  return await self._request("GET", self._client._repo_path("languages", owner=owner, repo=repo))
1246
1411
 
1247
1412
  async def list_stargazers(
1248
- self, *, owner: Optional[str] = None, repo: Optional[str] = None, **params
1413
+ self,
1414
+ *,
1415
+ owner: Optional[str] = None,
1416
+ repo: Optional[str] = None,
1417
+ page: Optional[int] = None,
1418
+ per_page: Optional[int] = None,
1249
1419
  ) -> List[UserSummary]:
1250
1420
  """List users who starred a repository.
1251
1421
 
1252
1422
  :param owner: Repository owner path. Uses the client default when omitted.
1253
1423
  :param repo: Repository name. Uses the client default when omitted.
1254
- :param params: Query parameters such as ``page`` and ``per_page``.
1424
+ :param page: Page number.
1425
+ :param per_page: Page size.
1255
1426
  :returns: Users who starred the repository.
1256
1427
  """
1257
1428
  return await self._models(
1258
- "GET", self._client._repo_path("stargazers", owner=owner, repo=repo), UserSummary, params=params
1429
+ "GET",
1430
+ self._client._repo_path("stargazers", owner=owner, repo=repo),
1431
+ UserSummary,
1432
+ params={"page": page, "per_page": per_page},
1259
1433
  )
1260
1434
 
1261
1435
  async def list_subscribers(
1262
- self, *, owner: Optional[str] = None, repo: Optional[str] = None, **params
1436
+ self,
1437
+ *,
1438
+ owner: Optional[str] = None,
1439
+ repo: Optional[str] = None,
1440
+ page: Optional[int] = None,
1441
+ per_page: Optional[int] = None,
1263
1442
  ) -> List[UserSummary]:
1264
1443
  """List users watching a repository.
1265
1444
 
1266
1445
  :param owner: Repository owner path. Uses the client default when omitted.
1267
1446
  :param repo: Repository name. Uses the client default when omitted.
1268
- :param params: Query parameters such as ``page`` and ``per_page``.
1447
+ :param page: Page number.
1448
+ :param per_page: Page size.
1269
1449
  :returns: Subscribers for the repository.
1270
1450
  """
1271
1451
  return await self._models(
1272
1452
  "GET",
1273
1453
  self._client._repo_path("subscribers", owner=owner, repo=repo),
1274
1454
  UserSummary,
1275
- params=params,
1455
+ params={"page": page, "per_page": per_page},
1276
1456
  )
1277
1457
 
1278
1458
  async def update_module_settings(
@@ -1559,16 +1739,26 @@ class AsyncReposResource(AsyncResource):
1559
1739
  )
1560
1740
 
1561
1741
  async def list_events(
1562
- self, *, owner: Optional[str] = None, repo: Optional[str] = None, **params
1742
+ self,
1743
+ *,
1744
+ owner: Optional[str] = None,
1745
+ repo: Optional[str] = None,
1746
+ page: Optional[int] = None,
1747
+ per_page: Optional[int] = None,
1563
1748
  ) -> List[APIObject]:
1564
1749
  """List repository events.
1565
1750
 
1566
1751
  :param owner: Repository owner path. Uses the client default when omitted.
1567
1752
  :param repo: Repository name. Uses the client default when omitted.
1568
- :param params: Query parameters such as ``page`` and ``per_page``.
1753
+ :param page: Page number.
1754
+ :param per_page: Page size.
1569
1755
  :returns: Repository event payloads.
1570
1756
  """
1571
- data = await self._request("GET", self._client._repo_path("events", owner=owner, repo=repo), params=params)
1757
+ data = await self._request(
1758
+ "GET",
1759
+ self._client._repo_path("events", owner=owner, repo=repo),
1760
+ params={"page": page, "per_page": per_page},
1761
+ )
1572
1762
  return [as_model(item, APIObject) for item in data]
1573
1763
 
1574
1764
 
@@ -1788,16 +1978,31 @@ class AsyncBranchesResource(AsyncResource):
1788
1978
  Mirrors :class:`BranchesResource` (``docs/rest_api/repos/branch``).
1789
1979
  """
1790
1980
 
1791
- async def list(self, *, owner: Optional[str] = None, repo: Optional[str] = None, **params) -> List[Branch]:
1981
+ async def list(
1982
+ self,
1983
+ *,
1984
+ owner: Optional[str] = None,
1985
+ repo: Optional[str] = None,
1986
+ sort: Optional[str] = None,
1987
+ direction: Optional[str] = None,
1988
+ page: Optional[int] = None,
1989
+ per_page: Optional[int] = None,
1990
+ ) -> List[Branch]:
1792
1991
  """List branches in a repository.
1793
1992
 
1794
1993
  :param owner: Repository owner path. Uses the client default when omitted.
1795
1994
  :param repo: Repository name. Uses the client default when omitted.
1796
- :param params: Query parameters such as ``sort``, ``direction``, ``page``, ``per_page``.
1995
+ :param sort: Optional sort field such as ``name`` or ``updated``.
1996
+ :param direction: Sort direction, usually ``asc`` or ``desc``.
1997
+ :param page: Page number.
1998
+ :param per_page: Page size.
1797
1999
  :returns: Repository branches.
1798
2000
  """
1799
2001
  return await self._models(
1800
- "GET", self._client._repo_path("branches", owner=owner, repo=repo), Branch, params=params
2002
+ "GET",
2003
+ self._client._repo_path("branches", owner=owner, repo=repo),
2004
+ Branch,
2005
+ params={"sort": sort, "direction": direction, "page": page, "per_page": per_page},
1801
2006
  )
1802
2007
 
1803
2008
  async def get(self, *, branch: str, owner: Optional[str] = None, repo: Optional[str] = None) -> BranchDetail:
@@ -1846,16 +2051,31 @@ class AsyncCommitsResource(AsyncResource):
1846
2051
  Mirrors :class:`CommitsResource` (``docs/rest_api/repos/commit``).
1847
2052
  """
1848
2053
 
1849
- async def list(self, *, owner: Optional[str] = None, repo: Optional[str] = None, **params) -> List[CommitSummary]:
2054
+ async def list(
2055
+ self,
2056
+ *,
2057
+ owner: Optional[str] = None,
2058
+ repo: Optional[str] = None,
2059
+ sha: Optional[str] = None,
2060
+ path: Optional[str] = None,
2061
+ page: Optional[int] = None,
2062
+ per_page: Optional[int] = None,
2063
+ ) -> List[CommitSummary]:
1850
2064
  """List commits in a repository.
1851
2065
 
1852
2066
  :param owner: Repository owner path. Uses the client default when omitted.
1853
2067
  :param repo: Repository name. Uses the client default when omitted.
1854
- :param params: Query parameters such as ``sha``, ``path``, ``page``, ``per_page``.
2068
+ :param sha: Optional starting SHA or ref.
2069
+ :param path: Optional file path filter.
2070
+ :param page: Page number.
2071
+ :param per_page: Page size.
1855
2072
  :returns: Matching commits.
1856
2073
  """
1857
2074
  return await self._models(
1858
- "GET", self._client._repo_path("commits", owner=owner, repo=repo), CommitSummary, params=params
2075
+ "GET",
2076
+ self._client._repo_path("commits", owner=owner, repo=repo),
2077
+ CommitSummary,
2078
+ params={"sha": sha, "path": path, "page": page, "per_page": per_page},
1859
2079
  )
1860
2080
 
1861
2081
  async def get(self, *, sha: str, owner: Optional[str] = None, repo: Optional[str] = None) -> Commit:
@@ -1884,17 +2104,26 @@ class AsyncCommitsResource(AsyncResource):
1884
2104
  )
1885
2105
 
1886
2106
  async def list_comments(
1887
- self, *, owner: Optional[str] = None, repo: Optional[str] = None, **params
2107
+ self,
2108
+ *,
2109
+ owner: Optional[str] = None,
2110
+ repo: Optional[str] = None,
2111
+ page: Optional[int] = None,
2112
+ per_page: Optional[int] = None,
1888
2113
  ) -> List[CommitComment]:
1889
2114
  """List commit comments for a repository.
1890
2115
 
1891
2116
  :param owner: Repository owner path. Uses the client default when omitted.
1892
2117
  :param repo: Repository name. Uses the client default when omitted.
1893
- :param params: Query parameters such as ``page`` and ``per_page``.
2118
+ :param page: Page number.
2119
+ :param per_page: Page size.
1894
2120
  :returns: Commit comments.
1895
2121
  """
1896
2122
  return await self._models(
1897
- "GET", self._client._repo_path("comments", owner=owner, repo=repo), CommitComment, params=params
2123
+ "GET",
2124
+ self._client._repo_path("comments", owner=owner, repo=repo),
2125
+ CommitComment,
2126
+ params={"page": page, "per_page": per_page},
1898
2127
  )
1899
2128
 
1900
2129
  async def get_comment(
gitcode_api/version.txt CHANGED
@@ -1 +1 @@
1
- 1.2.18
1
+ 1.2.20
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: gitcode-api
3
- Version: 1.2.18
3
+ Version: 1.2.20
4
4
  Summary: Easy to use Python SDK for the GitCode REST API. Providing builtin CLI tool, and optional LLM integration (MCP, OpenAI tool, and openJiuwen tool) for agents. Community-maintained.
5
5
  Author-email: Hugo Huang <hugo@hugohuang.com>
6
6
  License-Expression: MIT
@@ -37,7 +37,7 @@ Dynamic: license-file
37
37
 
38
38
  # GitCode-API
39
39
 
40
- [![PyPI - Version](https://img.shields.io/pypi/v/gitcode-api?link=https%3A%2F%2Fpypi.org%2Fproject%2Fgitcode-api%2F&uuid=f049bfb2e9a847dfb667888d9e54d163)](https://pypi.org/project/gitcode-api) [![PyPI Downloads](https://static.pepy.tech/personalized-badge/gitcode-api?period=total&units=INTERNATIONAL_SYSTEM&left_color=GRAY&right_color=RED&left_text=downloads&uuid=3d4c578403ac4d8aab1c59a48425e14b)](https://pepy.tech/projects/gitcode-api) [![CodeFactor](https://www.codefactor.io/repository/github/trenza1ore/gitcode-api/badge)](https://www.codefactor.io/repository/github/trenza1ore/gitcode-api)
40
+ [![PyPI - Version](https://img.shields.io/pypi/v/gitcode-api?link=https%3A%2F%2Fpypi.org%2Fproject%2Fgitcode-api%2F&uuid=07b9a0e809feb403999bf97670a5d29f)](https://pypi.org/project/gitcode-api) [![PyPI Downloads](https://static.pepy.tech/personalized-badge/gitcode-api?period=total&units=INTERNATIONAL_SYSTEM&left_color=GRAY&right_color=RED&left_text=downloads&uuid=07b9a0e809feb403999bf97670a5d29f)](https://pepy.tech/projects/gitcode-api) [![CodeFactor](https://www.codefactor.io/repository/github/trenza1ore/gitcode-api/badge)](https://www.codefactor.io/repository/github/trenza1ore/gitcode-api)
41
41
  [![Install in Cursor](https://img.shields.io/badge/Install_in-Cursor-000000?logoColor=white)](https://cursor.com/en/install-mcp?name=GitCode%20API&config=eyJjb21tYW5kIjoidXZ4IiwiYXJncyI6WyItLWZyb20iLCJnaXRjb2RlLWFwaVttY3BdIiwiZ2l0Y29kZS1hcGkiLCJzZXJ2ZSJdLCJlbnYiOnsiR0lUQ09ERV9BQ0NFU1NfVE9LRU4iOiIke2lucHV0OmdpdGNvZGVfYWNjZXNzX3Rva2VufSJ9LCJpbnB1dHMiOlt7ImlkIjoiZ2l0Y29kZV9hY2Nlc3NfdG9rZW4iLCJ0eXBlIjoicHJvbXB0U3RyaW5nIiwiZGVzY3JpcHRpb24iOiJFbnRlciBHSVRDT0RFX0FDQ0VTU19UT0tFTiIsInBhc3N3b3JkIjp0cnVlfV19) [![Install in VS Code](https://img.shields.io/badge/Install_in-VS_Code-0098FF?logo=visualstudiocode&logoColor=white)](https://vscode.dev/redirect/mcp/install?name=GitCode%20API&config=%7B%22command%22%3A%22uvx%22%2C%22args%22%3A%5B%22--from%22%2C%22gitcode-api%5Bmcp%5D%22%2C%22gitcode-api%22%2C%22serve%22%5D%2C%22env%22%3A%7B%22GITCODE_ACCESS_TOKEN%22%3A%22%24%7Binput%3Agitcode_access_token%7D%22%7D%2C%22inputs%22%3A%5B%7B%22id%22%3A%22gitcode_access_token%22%2C%22type%22%3A%22promptString%22%2C%22description%22%3A%22Enter%20GITCODE_ACCESS_TOKEN%22%2C%22password%22%3Atrue%7D%5D%7D)
42
42
  [![GitHub Badge](https://img.shields.io/badge/github-repo-blue?logo=github&link=https%3A%2F%2Fgithub.com%2FTrenza1ore%2FGitCode-API)](https://github.com/Trenza1ore/GitCode-API) [![GitCode Badge](https://img.shields.io/badge/gitcode-repo-brown?logo=gitcode&link=https%3A%2F%2Fgitcode.com%2FSushiNinja%2FGitCode-API)](https://gitcode.com/SushiNinja/GitCode-API)
43
43
 
@@ -1,31 +1,31 @@
1
1
  gitcode_api/__init__.py,sha256=94gg5E1bAWozIR6PBYIPdZMfj-VyBFJp_rQQda2Qagk,1672
2
2
  gitcode_api/__main__.py,sha256=Yd8P4MSNcWFqUTKnUaNibbWX4Vd-MVVNmhPFaohzqcA,137
3
- gitcode_api/_base_client.py,sha256=qG-d6wlMwjvbK4bi4m4dwHNZR9wP2tSS9qiWFTIIsFA,13960
3
+ gitcode_api/_base_client.py,sha256=FiNCI68jZMF3MibCBD-yUZ14c17Di3V5kT4xISnxKqk,13967
4
4
  gitcode_api/_base_resource.py,sha256=mlKe1b_1AKcqxhptaCpP-AOjKkLNzCbYG-Pkp1HYWrA,2238
5
5
  gitcode_api/_cli_banner.py,sha256=S6i8dnzCXrxytrboxNh_gz-x95u6w9E-Yz6IkTz2PJk,1576
6
6
  gitcode_api/_client.py,sha256=bmZxBHdfshM5Kv_EurHUVu8rsEj0k3Up3ATSIPaFrvc,8258
7
7
  gitcode_api/_exceptions.py,sha256=T5N8gBGmPSktDkLP5P_hxbzOHw3W378TzxN1xja40pA,1140
8
8
  gitcode_api/_models.py,sha256=ip0xgdWao8Z3ATfSaPn3KzG81OXd25RVB1ansOaJaUM,110586
9
9
  gitcode_api/cli.py,sha256=7ZrpWIh5zZdftMhbMjldiuvijig8qKLFiQbof93Cy6k,18792
10
- gitcode_api/constants.py,sha256=UYfSkmoRc71kIkgFYS5NFUoFhdbcXvnGV-EiJnvbELI,296
10
+ gitcode_api/constants.py,sha256=uzcI7dVq4Qx_toYtnIphUh1IGepv9NuOdJ4DCswiYgo,769
11
11
  gitcode_api/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
12
12
  gitcode_api/run_mcp.py,sha256=3_JOrjg9_yL-0M-H-F8mPgxdVKh7K2ggipu7UHeNCg0,147
13
13
  gitcode_api/utils.py,sha256=51QmPTQPeNsPSGf2IzhwmiEO1H2GkJrp2A7vkzhOOag,1351
14
- gitcode_api/version.txt,sha256=EEaCKUK2jb-KMegeJfWHxBHsQs-nsTSYst95cj6LJIo,7
14
+ gitcode_api/version.txt,sha256=W_OzohOH75vkjkKEkmQ_CHtziKl_5BIa7mxCW86poc4,7
15
15
  gitcode_api/llm/__init__.py,sha256=rU75ZlJvTWNVxBLc3QzdfWmSjqVc9z6hfQ8z6jVVKOk,1693
16
16
  gitcode_api/llm/_tool.py,sha256=b65iUiHo1H29uA6mFM3WlD0zZlISsENx1tpEqlkiUoA,16239
17
17
  gitcode_api/llm/jiuwen.py,sha256=qca2y4544xoRYFOCMbkjiUZZLpJGMcBkK4w5bqs60-4,4276
18
18
  gitcode_api/llm/mcp.py,sha256=eeAuEETZ4THw31wbcnQaTlZQJ-9ZolvsejQY630OqHs,5702
19
19
  gitcode_api/llm/openai.py,sha256=FSPA0Jv-k4n1Ud92TDfP1TWRlW4FB7smaLwY331nagk,3257
20
20
  gitcode_api/resources/__init__.py,sha256=nsCKW0bFDZ5ombJZxLThmO82sOuF7o4OKUMRkAmwbwk,1725
21
- gitcode_api/resources/_shared.py,sha256=07f4Zk_bk6JKjEwubZ6iSd1Lq1rGi7CyWjvcMNMcYpo,15402
22
- gitcode_api/resources/account.py,sha256=mnc2p7wI-nBnHFNdWPNiHfmZpT6d3RDQC777gewtm4M,38801
23
- gitcode_api/resources/collaboration.py,sha256=TK0QXG_ymE4vbtHyP3Y-M39oG9zQE44UU5-UnPhF2WM,112388
21
+ gitcode_api/resources/_shared.py,sha256=UWGtQwoUYRZ0rvqH4MHR9Up7roQAr9RRyO08RoQx01o,15820
22
+ gitcode_api/resources/account.py,sha256=OMuGxfxazYBz8Ii1PumKPJlgcmgmZu9ztJqvKC-FgfM,40359
23
+ gitcode_api/resources/collaboration.py,sha256=pdQkkm8xl5EQgGVj2WXSx1TFclDlYMCzi0nBtNDFXuI,116558
24
24
  gitcode_api/resources/misc.py,sha256=w7bq8rmgKr2ScBKeWZ3EZJmAdylDdPtSPrhi3AQre7w,34747
25
- gitcode_api/resources/repositories.py,sha256=EAK2znZhEsgVUu-NDEQslSEEYJzvb-kHuh4mW57y6sc,78178
26
- gitcode_api-1.2.18.dist-info/licenses/LICENSE,sha256=gOACXuWhMu6PJKVLr9RQbxX3HULnZIGNXCaMFJIXhoA,1067
27
- gitcode_api-1.2.18.dist-info/METADATA,sha256=QsYuYvwW_j8YWO2FV6YnK6HBOCu9BDLjfIjUaYL_8SI,23592
28
- gitcode_api-1.2.18.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
29
- gitcode_api-1.2.18.dist-info/entry_points.txt,sha256=dIPylJcgohIE2RRIlt3In2WzcwDK8TOdkL_ReKuij4o,53
30
- gitcode_api-1.2.18.dist-info/top_level.txt,sha256=gIlg0ptyOUHJT64ajOjWIhRPYgIQnMIvnhhnesw9fxU,12
31
- gitcode_api-1.2.18.dist-info/RECORD,,
25
+ gitcode_api/resources/repositories.py,sha256=T-xy1gVzqudfpm2J8na1RrRTrMRYCbYI65e4w3f13n4,84402
26
+ gitcode_api-1.2.20.dist-info/licenses/LICENSE,sha256=gOACXuWhMu6PJKVLr9RQbxX3HULnZIGNXCaMFJIXhoA,1067
27
+ gitcode_api-1.2.20.dist-info/METADATA,sha256=Ws6gsVCzz_lwTWxxSO_tlokn-1W6nUqdqP-ma90C64I,23592
28
+ gitcode_api-1.2.20.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
29
+ gitcode_api-1.2.20.dist-info/entry_points.txt,sha256=dIPylJcgohIE2RRIlt3In2WzcwDK8TOdkL_ReKuij4o,53
30
+ gitcode_api-1.2.20.dist-info/top_level.txt,sha256=gIlg0ptyOUHJT64ajOjWIhRPYgIQnMIvnhhnesw9fxU,12
31
+ gitcode_api-1.2.20.dist-info/RECORD,,