github_rest_api 0.28.0__tar.gz → 0.30.0__tar.gz
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.
- {github_rest_api-0.28.0 → github_rest_api-0.30.0}/.github/workflows/create_pr_dev_to_main.yml +5 -2
- {github_rest_api-0.28.0 → github_rest_api-0.30.0}/.github/workflows/create_pr_to_dev.yml +5 -1
- {github_rest_api-0.28.0 → github_rest_api-0.30.0}/PKG-INFO +1 -1
- {github_rest_api-0.28.0 → github_rest_api-0.30.0}/github_rest_api/actions/utils.py +0 -22
- {github_rest_api-0.28.0 → github_rest_api-0.30.0}/github_rest_api/github.py +33 -5
- github_rest_api-0.30.0/github_rest_api/utils.py +34 -0
- {github_rest_api-0.28.0 → github_rest_api-0.30.0}/pyproject.toml +2 -1
- {github_rest_api-0.28.0 → github_rest_api-0.30.0}/uv.lock +46 -1
- github_rest_api-0.28.0/.github/pr.py +0 -67
- github_rest_api-0.28.0/github_rest_api/utils.py +0 -12
- {github_rest_api-0.28.0 → github_rest_api-0.30.0}/.github/workflows/lint.yml +0 -0
- {github_rest_api-0.28.0 → github_rest_api-0.30.0}/.github/workflows/release.yml +0 -0
- {github_rest_api-0.28.0 → github_rest_api-0.30.0}/.gitignore +0 -0
- {github_rest_api-0.28.0 → github_rest_api-0.30.0}/.gitpod.yml +0 -0
- {github_rest_api-0.28.0 → github_rest_api-0.30.0}/README.md +0 -0
- {github_rest_api-0.28.0 → github_rest_api-0.30.0}/github_rest_api/__init__.py +0 -0
- {github_rest_api-0.28.0 → github_rest_api-0.30.0}/github_rest_api/actions/__init__.py +0 -0
- {github_rest_api-0.28.0 → github_rest_api-0.30.0}/github_rest_api/actions/cargo/__init__.py +0 -0
- {github_rest_api-0.28.0 → github_rest_api-0.30.0}/github_rest_api/actions/cargo/benchmark.py +0 -0
- {github_rest_api-0.28.0 → github_rest_api-0.30.0}/github_rest_api/actions/cargo/profiling.py +0 -0
- {github_rest_api-0.28.0 → github_rest_api-0.30.0}/github_rest_api/actions/cargo/utils.py +0 -0
- {github_rest_api-0.28.0 → github_rest_api-0.30.0}/tests/__init__.py +0 -0
{github_rest_api-0.28.0 → github_rest_api-0.30.0}/.github/workflows/create_pr_dev_to_main.yml
RENAMED
|
@@ -10,8 +10,11 @@ jobs:
|
|
|
10
10
|
- name: Install uv
|
|
11
11
|
run: |
|
|
12
12
|
curl -LsSf https://astral.sh/uv/install.sh | sudo env UV_INSTALL_DIR="/usr/local/bin" sh
|
|
13
|
-
- uses: actions/checkout@v6
|
|
14
13
|
- name: Create PR From dev To main
|
|
15
14
|
run: |
|
|
16
|
-
|
|
15
|
+
curl -sSL https://raw.githubusercontent.com/legendu-net/github_actions_scripts/main/create_pull_request.py \
|
|
16
|
+
| uv run --script - \
|
|
17
|
+
--head-branch dev \
|
|
18
|
+
--base-branch main \
|
|
19
|
+
--token ${{ secrets.GITHUBACTIONS }}
|
|
17
20
|
|
|
@@ -15,5 +15,9 @@ jobs:
|
|
|
15
15
|
- uses: actions/checkout@v6
|
|
16
16
|
- name: Create PR to dev
|
|
17
17
|
run: |
|
|
18
|
-
|
|
18
|
+
curl -sSL https://raw.githubusercontent.com/legendu-net/github_actions_scripts/main/create_pull_request.py \
|
|
19
|
+
| uv run --script - \
|
|
20
|
+
--head-branch ${{ github.ref_name }} \
|
|
21
|
+
--base-branch dev \
|
|
22
|
+
--token ${{ secrets.GITHUBACTIONS }}
|
|
19
23
|
|
|
@@ -73,25 +73,3 @@ def commit_profiling(prof_dir: str | Path):
|
|
|
73
73
|
"""
|
|
74
74
|
porcelain.add(paths=prof_dir)
|
|
75
75
|
porcelain.commit(message="Updating profiling results.")
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
def strip_patch_version(version: str) -> str:
|
|
79
|
-
parts = version.split(".")
|
|
80
|
-
match len(parts):
|
|
81
|
-
case 1:
|
|
82
|
-
return parts[0] + ".0.0"
|
|
83
|
-
case 2 | 3:
|
|
84
|
-
return ".".join(parts[:2]) + ".0"
|
|
85
|
-
case _:
|
|
86
|
-
raise ValueError("Invalid version semantic provided!")
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
def strip_minor_version(version: str) -> str:
|
|
90
|
-
parts = version.split(".")
|
|
91
|
-
match len(parts):
|
|
92
|
-
case 1:
|
|
93
|
-
return parts[0] + ".0.0"
|
|
94
|
-
case 2 | 3:
|
|
95
|
-
return ".".join(parts[:1]) + ".0.0"
|
|
96
|
-
case _:
|
|
97
|
-
raise ValueError("Invalid version semantic provided!")
|
|
@@ -76,6 +76,17 @@ class GitHub:
|
|
|
76
76
|
resp.raise_for_status()
|
|
77
77
|
return resp
|
|
78
78
|
|
|
79
|
+
def patch(self, url, raise_for_status: bool = True, **kwargs) -> requests.Response:
|
|
80
|
+
resp = requests.patch(
|
|
81
|
+
url=url,
|
|
82
|
+
headers=self._headers,
|
|
83
|
+
timeout=10,
|
|
84
|
+
**kwargs,
|
|
85
|
+
)
|
|
86
|
+
if raise_for_status:
|
|
87
|
+
resp.raise_for_status()
|
|
88
|
+
return resp
|
|
89
|
+
|
|
79
90
|
|
|
80
91
|
class Repository(GitHub):
|
|
81
92
|
"""Abstraction of a GitHub repository."""
|
|
@@ -87,11 +98,14 @@ class Repository(GitHub):
|
|
|
87
98
|
"""
|
|
88
99
|
super().__init__(token)
|
|
89
100
|
self._repo = repo
|
|
90
|
-
self.
|
|
91
|
-
self.
|
|
92
|
-
self.
|
|
93
|
-
self.
|
|
94
|
-
self.
|
|
101
|
+
self._url = "https://api.github.com/repos"
|
|
102
|
+
self._url_repo = f"{self._url}/{repo}"
|
|
103
|
+
self._url_transfer = f"{self._url_repo}/transfer"
|
|
104
|
+
self._url_pull = f"{self._url_repo}/pulls"
|
|
105
|
+
self._url_branches = f"{self._url_repo}/branches"
|
|
106
|
+
self._url_refs = f"{self._url_repo}/git/refs"
|
|
107
|
+
self._url_issues = f"{self._url_repo}/issues"
|
|
108
|
+
self._url_releases = f"{self._url_repo}/releases"
|
|
95
109
|
|
|
96
110
|
def get_releases(self) -> list[dict[str, Any]]:
|
|
97
111
|
"""List releases in this repository."""
|
|
@@ -272,6 +286,20 @@ class Repository(GitHub):
|
|
|
272
286
|
timeout=10,
|
|
273
287
|
).json()
|
|
274
288
|
|
|
289
|
+
def archive(self) -> requests.Response:
|
|
290
|
+
return self.patch(
|
|
291
|
+
url=self._url_repo,
|
|
292
|
+
json={"archived": True},
|
|
293
|
+
)
|
|
294
|
+
|
|
295
|
+
def transfer(self, new_owner: str, new_name: str = "") -> requests.Response:
|
|
296
|
+
data = {
|
|
297
|
+
"new_owner": new_owner,
|
|
298
|
+
}
|
|
299
|
+
if new_name:
|
|
300
|
+
data["new_name"] = new_name
|
|
301
|
+
return self.post(url=self._url_transfer, json=data)
|
|
302
|
+
|
|
275
303
|
|
|
276
304
|
class RepositoryType(StrEnum):
|
|
277
305
|
ALL = "all"
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"""Some generally useful util functions."""
|
|
2
|
+
|
|
3
|
+
from itertools import tee, filterfalse
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def partition(pred, iterable):
|
|
7
|
+
"""Use a predicate to partition entries into true entries and false entries.
|
|
8
|
+
:param pred: A function takes one parameter and return a boolean value.
|
|
9
|
+
:param iterable: An iterable of values to partition.
|
|
10
|
+
"""
|
|
11
|
+
it1, it2 = tee(iterable)
|
|
12
|
+
return filter(pred, it1), filterfalse(pred, it2)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def strip_patch_version(version: str) -> str:
|
|
16
|
+
parts = version.split(".")
|
|
17
|
+
match len(parts):
|
|
18
|
+
case 1:
|
|
19
|
+
return parts[0] + ".0.0"
|
|
20
|
+
case 2 | 3:
|
|
21
|
+
return ".".join(parts[:2]) + ".0"
|
|
22
|
+
case _:
|
|
23
|
+
raise ValueError("Invalid version semantic provided!")
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def strip_minor_version(version: str) -> str:
|
|
27
|
+
parts = version.split(".")
|
|
28
|
+
match len(parts):
|
|
29
|
+
case 1:
|
|
30
|
+
return parts[0] + ".0.0"
|
|
31
|
+
case 2 | 3:
|
|
32
|
+
return ".".join(parts[:1]) + ".0.0"
|
|
33
|
+
case _:
|
|
34
|
+
raise ValueError("Invalid version semantic provided!")
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "github_rest_api"
|
|
3
|
-
version = "0.
|
|
3
|
+
version = "0.30.0"
|
|
4
4
|
description = "Simple wrapper of GitHub REST APIs."
|
|
5
5
|
authors = [{ name = "Ben Du", email = "longendu@yahoo.com" }]
|
|
6
6
|
requires-python = ">=3.11,<4"
|
|
@@ -15,6 +15,7 @@ dependencies = [
|
|
|
15
15
|
dev = [
|
|
16
16
|
"deptry>=0.24.0",
|
|
17
17
|
"pyright>=1.1.407",
|
|
18
|
+
"pytest>=9.0.2",
|
|
18
19
|
"ruff>=0.14.10",
|
|
19
20
|
"ty>=0.0.8",
|
|
20
21
|
]
|
|
@@ -168,7 +168,7 @@ wheels = [
|
|
|
168
168
|
|
|
169
169
|
[[package]]
|
|
170
170
|
name = "github-rest-api"
|
|
171
|
-
version = "0.
|
|
171
|
+
version = "0.30.0"
|
|
172
172
|
source = { editable = "." }
|
|
173
173
|
dependencies = [
|
|
174
174
|
{ name = "dulwich" },
|
|
@@ -180,6 +180,7 @@ dependencies = [
|
|
|
180
180
|
dev = [
|
|
181
181
|
{ name = "deptry" },
|
|
182
182
|
{ name = "pyright" },
|
|
183
|
+
{ name = "pytest" },
|
|
183
184
|
{ name = "ruff" },
|
|
184
185
|
{ name = "ty" },
|
|
185
186
|
]
|
|
@@ -195,6 +196,7 @@ requires-dist = [
|
|
|
195
196
|
dev = [
|
|
196
197
|
{ name = "deptry", specifier = ">=0.24.0" },
|
|
197
198
|
{ name = "pyright", specifier = ">=1.1.407" },
|
|
199
|
+
{ name = "pytest", specifier = ">=9.0.2" },
|
|
198
200
|
{ name = "ruff", specifier = ">=0.14.10" },
|
|
199
201
|
{ name = "ty", specifier = ">=0.0.8" },
|
|
200
202
|
]
|
|
@@ -208,6 +210,15 @@ wheels = [
|
|
|
208
210
|
{ url = "https://files.pythonhosted.org/packages/0e/61/66938bbb5fc52dbdf84594873d5b51fb1f7c7794e9c0f5bd885f30bc507b/idna-3.11-py3-none-any.whl", hash = "sha256:771a87f49d9defaf64091e6e6fe9c18d4833f140bd19464795bc32d966ca37ea", size = 71008, upload-time = "2025-10-12T14:55:18.883Z" },
|
|
209
211
|
]
|
|
210
212
|
|
|
213
|
+
[[package]]
|
|
214
|
+
name = "iniconfig"
|
|
215
|
+
version = "2.3.0"
|
|
216
|
+
source = { registry = "https://pypi.org/simple" }
|
|
217
|
+
sdist = { url = "https://files.pythonhosted.org/packages/72/34/14ca021ce8e5dfedc35312d08ba8bf51fdd999c576889fc2c24cb97f4f10/iniconfig-2.3.0.tar.gz", hash = "sha256:c76315c77db068650d49c5b56314774a7804df16fee4402c1f19d6d15d8c4730", size = 20503, upload-time = "2025-10-18T21:55:43.219Z" }
|
|
218
|
+
wheels = [
|
|
219
|
+
{ url = "https://files.pythonhosted.org/packages/cb/b1/3846dd7f199d53cb17f49cba7e651e9ce294d8497c8c150530ed11865bb8/iniconfig-2.3.0-py3-none-any.whl", hash = "sha256:f631c04d2c48c52b84d0d0549c99ff3859c98df65b3101406327ecc7d53fbf12", size = 7484, upload-time = "2025-10-18T21:55:41.639Z" },
|
|
220
|
+
]
|
|
221
|
+
|
|
211
222
|
[[package]]
|
|
212
223
|
name = "nodeenv"
|
|
213
224
|
version = "1.10.0"
|
|
@@ -226,6 +237,15 @@ wheels = [
|
|
|
226
237
|
{ url = "https://files.pythonhosted.org/packages/20/12/38679034af332785aac8774540895e234f4d07f7545804097de4b666afd8/packaging-25.0-py3-none-any.whl", hash = "sha256:29572ef2b1f17581046b3a2227d5c611fb25ec70ca1ba8554b24b0e69331a484", size = 66469, upload-time = "2025-04-19T11:48:57.875Z" },
|
|
227
238
|
]
|
|
228
239
|
|
|
240
|
+
[[package]]
|
|
241
|
+
name = "pluggy"
|
|
242
|
+
version = "1.6.0"
|
|
243
|
+
source = { registry = "https://pypi.org/simple" }
|
|
244
|
+
sdist = { url = "https://files.pythonhosted.org/packages/f9/e2/3e91f31a7d2b083fe6ef3fa267035b518369d9511ffab804f839851d2779/pluggy-1.6.0.tar.gz", hash = "sha256:7dcc130b76258d33b90f61b658791dede3486c3e6bfb003ee5c9bfb396dd22f3", size = 69412, upload-time = "2025-05-15T12:30:07.975Z" }
|
|
245
|
+
wheels = [
|
|
246
|
+
{ url = "https://files.pythonhosted.org/packages/54/20/4d324d65cc6d9205fabedc306948156824eb9f0ee1633355a8f7ec5c66bf/pluggy-1.6.0-py3-none-any.whl", hash = "sha256:e920276dd6813095e9377c0bc5566d94c932c33b27a3e3945d8389c374dd4746", size = 20538, upload-time = "2025-05-15T12:30:06.134Z" },
|
|
247
|
+
]
|
|
248
|
+
|
|
229
249
|
[[package]]
|
|
230
250
|
name = "psutil"
|
|
231
251
|
version = "7.2.1"
|
|
@@ -254,6 +274,15 @@ wheels = [
|
|
|
254
274
|
{ url = "https://files.pythonhosted.org/packages/3e/73/2ce007f4198c80fcf2cb24c169884f833fe93fbc03d55d302627b094ee91/psutil-7.2.1-cp37-abi3-win_arm64.whl", hash = "sha256:0d67c1822c355aa6f7314d92018fb4268a76668a536f133599b91edd48759442", size = 133836, upload-time = "2025-12-29T08:26:43.086Z" },
|
|
255
275
|
]
|
|
256
276
|
|
|
277
|
+
[[package]]
|
|
278
|
+
name = "pygments"
|
|
279
|
+
version = "2.20.0"
|
|
280
|
+
source = { registry = "https://pypi.org/simple" }
|
|
281
|
+
sdist = { url = "https://files.pythonhosted.org/packages/c3/b2/bc9c9196916376152d655522fdcebac55e66de6603a76a02bca1b6414f6c/pygments-2.20.0.tar.gz", hash = "sha256:6757cd03768053ff99f3039c1a36d6c0aa0b263438fcab17520b30a303a82b5f", size = 4955991, upload-time = "2026-03-29T13:29:33.898Z" }
|
|
282
|
+
wheels = [
|
|
283
|
+
{ url = "https://files.pythonhosted.org/packages/f4/7e/a72dd26f3b0f4f2bf1dd8923c85f7ceb43172af56d63c7383eb62b332364/pygments-2.20.0-py3-none-any.whl", hash = "sha256:81a9e26dd42fd28a23a2d169d86d7ac03b46e2f8b59ed4698fb4785f946d0176", size = 1231151, upload-time = "2026-03-29T13:29:30.038Z" },
|
|
284
|
+
]
|
|
285
|
+
|
|
257
286
|
[[package]]
|
|
258
287
|
name = "pyright"
|
|
259
288
|
version = "1.1.408"
|
|
@@ -267,6 +296,22 @@ wheels = [
|
|
|
267
296
|
{ url = "https://files.pythonhosted.org/packages/0c/82/a2c93e32800940d9573fb28c346772a14778b84ba7524e691b324620ab89/pyright-1.1.408-py3-none-any.whl", hash = "sha256:090b32865f4fdb1e0e6cd82bf5618480d48eecd2eb2e70f960982a3d9a4c17c1", size = 6399144, upload-time = "2026-01-08T08:07:37.082Z" },
|
|
268
297
|
]
|
|
269
298
|
|
|
299
|
+
[[package]]
|
|
300
|
+
name = "pytest"
|
|
301
|
+
version = "9.0.2"
|
|
302
|
+
source = { registry = "https://pypi.org/simple" }
|
|
303
|
+
dependencies = [
|
|
304
|
+
{ name = "colorama", marker = "sys_platform == 'win32'" },
|
|
305
|
+
{ name = "iniconfig" },
|
|
306
|
+
{ name = "packaging" },
|
|
307
|
+
{ name = "pluggy" },
|
|
308
|
+
{ name = "pygments" },
|
|
309
|
+
]
|
|
310
|
+
sdist = { url = "https://files.pythonhosted.org/packages/d1/db/7ef3487e0fb0049ddb5ce41d3a49c235bf9ad299b6a25d5780a89f19230f/pytest-9.0.2.tar.gz", hash = "sha256:75186651a92bd89611d1d9fc20f0b4345fd827c41ccd5c299a868a05d70edf11", size = 1568901, upload-time = "2025-12-06T21:30:51.014Z" }
|
|
311
|
+
wheels = [
|
|
312
|
+
{ url = "https://files.pythonhosted.org/packages/3b/ab/b3226f0bd7cdcf710fbede2b3548584366da3b19b5021e74f5bde2a8fa3f/pytest-9.0.2-py3-none-any.whl", hash = "sha256:711ffd45bf766d5264d487b917733b453d917afd2b0ad65223959f59089f875b", size = 374801, upload-time = "2025-12-06T21:30:49.154Z" },
|
|
313
|
+
]
|
|
314
|
+
|
|
270
315
|
[[package]]
|
|
271
316
|
name = "requests"
|
|
272
317
|
version = "2.32.5"
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env -S uv run --script
|
|
2
|
-
#
|
|
3
|
-
# /// script
|
|
4
|
-
# requires-python = ">=3.12"
|
|
5
|
-
# dependencies = [
|
|
6
|
-
# "github-rest-api>=0.25.0",
|
|
7
|
-
# ]
|
|
8
|
-
# ///
|
|
9
|
-
|
|
10
|
-
"""Create a PR from the specified branch to dev.
|
|
11
|
-
The branch is updated (using dev) before creating the PR.
|
|
12
|
-
"""
|
|
13
|
-
|
|
14
|
-
from argparse import ArgumentParser, Namespace
|
|
15
|
-
from github_rest_api import Repository
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
def parse_args(args=None, namespace=None) -> Namespace:
|
|
19
|
-
"""Parse command-line arguments.
|
|
20
|
-
:param args: The arguments to parse.
|
|
21
|
-
If None, the arguments from command-line are parsed.
|
|
22
|
-
:param namespace: An inital Namespace object.
|
|
23
|
-
:return: A namespace object containing parsed options.
|
|
24
|
-
"""
|
|
25
|
-
parser = ArgumentParser(description="Create pull requests to the dev branch.")
|
|
26
|
-
parser.add_argument(
|
|
27
|
-
"--token",
|
|
28
|
-
dest="token",
|
|
29
|
-
required=True,
|
|
30
|
-
help="The personal access token for authentication.",
|
|
31
|
-
)
|
|
32
|
-
parser.add_argument(
|
|
33
|
-
"--head-branch",
|
|
34
|
-
dest="head_branch",
|
|
35
|
-
required=True,
|
|
36
|
-
help="The head branch containing changes to merge.",
|
|
37
|
-
)
|
|
38
|
-
parser.add_argument(
|
|
39
|
-
"--base-branch",
|
|
40
|
-
dest="base_branch",
|
|
41
|
-
required=True,
|
|
42
|
-
help="The base branch to merge changes into.",
|
|
43
|
-
)
|
|
44
|
-
return parser.parse_args(args=args, namespace=namespace)
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
def main():
|
|
48
|
-
"""Main entrance of the script,
|
|
49
|
-
which creates a PR from the specified branch to dev.
|
|
50
|
-
The branch is updated (using dev) before creating the PR.
|
|
51
|
-
"""
|
|
52
|
-
args = parse_args()
|
|
53
|
-
# skip branches with the pattern _*
|
|
54
|
-
if args.head_branch.startswith("_"):
|
|
55
|
-
return
|
|
56
|
-
repo = Repository(args.token, "legendu-net/github_rest_api")
|
|
57
|
-
repo.create_pull_request(
|
|
58
|
-
{
|
|
59
|
-
"base": args.base_branch,
|
|
60
|
-
"head": args.head_branch,
|
|
61
|
-
"title": f"Merge {args.head_branch} Into {args.base_branch}",
|
|
62
|
-
},
|
|
63
|
-
)
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
if __name__ == "__main__":
|
|
67
|
-
main()
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"""Some generally useful util functions."""
|
|
2
|
-
|
|
3
|
-
from itertools import tee, filterfalse
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
def partition(pred, iterable):
|
|
7
|
-
"""Use a predicate to partition entries into true entries and false entries.
|
|
8
|
-
:param pred: A function takes one parameter and return a boolean value.
|
|
9
|
-
:param iterable: An iterable of values to partition.
|
|
10
|
-
"""
|
|
11
|
-
it1, it2 = tee(iterable)
|
|
12
|
-
return filter(pred, it1), filterfalse(pred, it2)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{github_rest_api-0.28.0 → github_rest_api-0.30.0}/github_rest_api/actions/cargo/benchmark.py
RENAMED
|
File without changes
|
{github_rest_api-0.28.0 → github_rest_api-0.30.0}/github_rest_api/actions/cargo/profiling.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|