basstler-reviews 4.2.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.
- basstler_reviews-4.2.0/.gitignore +13 -0
- basstler_reviews-4.2.0/LICENSE +202 -0
- basstler_reviews-4.2.0/NOTICE +13 -0
- basstler_reviews-4.2.0/PKG-INFO +12 -0
- basstler_reviews-4.2.0/pyproject.toml +51 -0
- basstler_reviews-4.2.0/src/basstler/templates/upstream_reviews_action_readme.md +11 -0
- basstler_reviews-4.2.0/src/basstler/templates/upstream_reviews_action_workflow.yml +16 -0
- basstler_reviews-4.2.0/src/basstler/upstream_reviews/__init__.py +0 -0
- basstler_reviews-4.2.0/src/basstler/upstream_reviews/__main__.py +165 -0
- basstler_reviews-4.2.0/src/basstler/upstream_reviews/action/__init__.py +0 -0
- basstler_reviews-4.2.0/src/basstler/upstream_reviews/action/__main__.py +200 -0
- basstler_reviews-4.2.0/src/basstler/upstream_reviews/action/branch.py +282 -0
- basstler_reviews-4.2.0/src/basstler/upstream_reviews/action/exchange.py +89 -0
- basstler_reviews-4.2.0/src/basstler/upstream_reviews/action/open_pull_requests.py +219 -0
- basstler_reviews-4.2.0/src/basstler/upstream_reviews/action/read.py +159 -0
- basstler_reviews-4.2.0/src/basstler/upstream_reviews/action/recording.py +268 -0
- basstler_reviews-4.2.0/src/basstler/upstream_reviews/action/run.py +83 -0
- basstler_reviews-4.2.0/src/basstler/upstream_reviews/clients.py +135 -0
- basstler_reviews-4.2.0/src/basstler/upstream_reviews/exceptions.py +322 -0
- basstler_reviews-4.2.0/src/basstler/upstream_reviews/failure_logs.py +230 -0
- basstler_reviews-4.2.0/src/basstler/upstream_reviews/helper/__init__.py +0 -0
- basstler_reviews-4.2.0/src/basstler/upstream_reviews/helper/__main__.py +282 -0
- basstler_reviews-4.2.0/src/basstler/upstream_reviews/helper/fetch.py +237 -0
- basstler_reviews-4.2.0/src/basstler/upstream_reviews/helper/recording.py +367 -0
- basstler_reviews-4.2.0/src/basstler/upstream_reviews/readers.py +414 -0
- basstler_reviews-4.2.0/src/basstler/upstream_reviews/report.py +162 -0
- basstler_reviews-4.2.0/src/basstler/upstream_reviews/request.py +189 -0
- basstler_reviews-4.2.0/tests/__init__.py +0 -0
- basstler_reviews-4.2.0/tests/conftest.py +21 -0
- basstler_reviews-4.2.0/tests/upstream_reviews/__init__.py +0 -0
- basstler_reviews-4.2.0/tests/upstream_reviews/test_action.py +813 -0
- basstler_reviews-4.2.0/tests/upstream_reviews/test_command_line.py +1111 -0
- basstler_reviews-4.2.0/tests/upstream_reviews/test_helper.py +549 -0
- basstler_reviews-4.2.0/tests/upstream_reviews/test_open_pull_requests_action.py +197 -0
- basstler_reviews-4.2.0/tests/upstream_reviews/test_rest.py +250 -0
- basstler_reviews-4.2.0/tests/upstream_reviews/test_review_reading.py +80 -0
- basstler_reviews-4.2.0/tests/upstream_reviews/test_validated_models.py +121 -0
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
__pycache__/
|
|
2
|
+
*.egg-info/
|
|
3
|
+
.venv/
|
|
4
|
+
.pytest_cache/
|
|
5
|
+
|
|
6
|
+
# What the plugin's own session start writes into the project it serves - this
|
|
7
|
+
# repository, when developing it with its own plugin enabled. Personal, never committed.
|
|
8
|
+
CLAUDE.local.md
|
|
9
|
+
.claude/settings.local.json
|
|
10
|
+
|
|
11
|
+
# Everything the last maintenance pass did, written by `python3 -m basstler.maintenance
|
|
12
|
+
# run-report` beside the board. Scratch state, never committed.
|
|
13
|
+
src/basstler/maintenance-report.json
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
basstler
|
|
2
|
+
Copyright 2026 Abdelrhman Bassiouny and the basstler contributors
|
|
3
|
+
|
|
4
|
+
basstler (https://github.com/KAOS-repositories/basstler) is licensed under the
|
|
5
|
+
Apache License, Version 2.0 (see LICENSE). Abdelrhman Bassiouny wrote it
|
|
6
|
+
independently of any employer or institution and maintains it in the
|
|
7
|
+
KAOS-repositories organization on GitHub; contributors keep the copyright on
|
|
8
|
+
their contributions.
|
|
9
|
+
|
|
10
|
+
packages/core/src/basstler/{exceptions,class_property}.py contain code adapted
|
|
11
|
+
from krrood (https://github.com/cram2/cognitive_robot_abstract_machine/tree/main/krrood),
|
|
12
|
+
copyright the krrood authors, which remains licensed under the GNU Lesser
|
|
13
|
+
General Public License, version 3 only (LGPL-3.0-only).
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: basstler-reviews
|
|
3
|
+
Version: 4.2.0
|
|
4
|
+
Summary: Reading an upstream pull request's checks and review threads.
|
|
5
|
+
Project-URL: Source, https://github.com/KAOS-repositories/basstler
|
|
6
|
+
Project-URL: Bug Tracker, https://github.com/KAOS-repositories/basstler/issues
|
|
7
|
+
Author-email: Abdelrhman Bassiouny <bido.bassuny@gmail.com>
|
|
8
|
+
License-Expression: Apache-2.0
|
|
9
|
+
Requires-Python: >=3.12
|
|
10
|
+
Requires-Dist: basstler-core==4.2.0
|
|
11
|
+
Requires-Dist: basstler-git==4.2.0
|
|
12
|
+
Requires-Dist: basstler-github==4.2.0
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling>=1.24", "hatch-vcs>=0.4", "basstler-build"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "basstler-reviews"
|
|
7
|
+
description = "Reading an upstream pull request's checks and review threads."
|
|
8
|
+
requires-python = ">=3.12"
|
|
9
|
+
license = "Apache-2.0"
|
|
10
|
+
license-files = ["LICENSE", "NOTICE"]
|
|
11
|
+
authors = [{name = "Abdelrhman Bassiouny", email = "bido.bassuny@gmail.com"}]
|
|
12
|
+
dynamic = ["version", "dependencies"]
|
|
13
|
+
|
|
14
|
+
[project.urls]
|
|
15
|
+
"Source" = "https://github.com/KAOS-repositories/basstler"
|
|
16
|
+
"Bug Tracker" = "https://github.com/KAOS-repositories/basstler/issues"
|
|
17
|
+
|
|
18
|
+
[tool.hatch.version]
|
|
19
|
+
source = "vcs"
|
|
20
|
+
fallback-version = "0.0.0"
|
|
21
|
+
raw-options = {root = "../.."}
|
|
22
|
+
|
|
23
|
+
# Built with every basstler requirement pinned to this release.
|
|
24
|
+
[tool.hatch.metadata.hooks.basstler-sibling-pins]
|
|
25
|
+
family = "basstler"
|
|
26
|
+
dependencies = [
|
|
27
|
+
"basstler-core",
|
|
28
|
+
"basstler-git",
|
|
29
|
+
"basstler-github",
|
|
30
|
+
]
|
|
31
|
+
|
|
32
|
+
[tool.hatch.build.targets.wheel]
|
|
33
|
+
packages = ["src/basstler"]
|
|
34
|
+
|
|
35
|
+
# The repository's licence and notices, put at the root of the source distribution so
|
|
36
|
+
# the wheel built from it carries them.
|
|
37
|
+
[tool.hatch.build.targets.sdist.force-include]
|
|
38
|
+
"../../LICENSE" = "LICENSE"
|
|
39
|
+
"../../NOTICE" = "NOTICE"
|
|
40
|
+
|
|
41
|
+
# What this distribution's tests need besides itself.
|
|
42
|
+
[dependency-groups]
|
|
43
|
+
dev = [
|
|
44
|
+
"pytest",
|
|
45
|
+
"pytest-xdist",
|
|
46
|
+
"basstler-core",
|
|
47
|
+
"basstler-git",
|
|
48
|
+
"basstler-github",
|
|
49
|
+
"basstler-notes",
|
|
50
|
+
"basstler-stack",
|
|
51
|
+
]
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# basstler upstream reviews
|
|
2
|
+
|
|
3
|
+
Kept by basstler's `/upstream-reviews` skill. Each read pushes a branch of its own under
|
|
4
|
+
`{{ requests }}/`, starting from this one, with a `{{ request }}`. That push runs
|
|
5
|
+
`{{ workflow }}`, which reads the upstream as the request asks and commits `{{ result }}`
|
|
6
|
+
onto the same branch, where the session reads it. Each run also deletes the request
|
|
7
|
+
branches it made, by their `Basstler-request` trailer, whose last commit is over an hour
|
|
8
|
+
old. Nothing here is ever merged anywhere.
|
|
9
|
+
|
|
10
|
+
Install or update it with `/setup-personal-notes`, which runs
|
|
11
|
+
`python -m basstler.setup.steps install-upstream-reviews-action`.
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# Written by basstler's /setup-personal-notes (python -m basstler.setup.steps
|
|
2
|
+
# install-upstream-reviews-action); re-run that to update it rather than editing it here.
|
|
3
|
+
name: Upstream reviews
|
|
4
|
+
|
|
5
|
+
on:
|
|
6
|
+
push:
|
|
7
|
+
branches: ["{{ requests }}/**"]
|
|
8
|
+
|
|
9
|
+
permissions:
|
|
10
|
+
contents: write
|
|
11
|
+
|
|
12
|
+
jobs:
|
|
13
|
+
read:
|
|
14
|
+
uses: {{ repository }}/{{ reusable_workflow }}@{{ branch_or_tag }}
|
|
15
|
+
with:
|
|
16
|
+
basstler_branch_or_tag: {{ branch_or_tag }}
|
|
File without changes
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""
|
|
3
|
+
Report the checks, failing job logs and review threads a fork's pull request has
|
|
4
|
+
collected upstream.
|
|
5
|
+
|
|
6
|
+
It reads through whichever API the place it runs in can reach. A Claude Code cloud
|
|
7
|
+
session's proxy refuses GitHub's GraphQL API but answers REST for the repositories the
|
|
8
|
+
session has attached, with a review-threads route of its own carrying the resolved
|
|
9
|
+
state GitHub otherwise keeps behind GraphQL; anywhere else - a runner, a developer's
|
|
10
|
+
machine - reads through GraphQL. Both readers parse into the same models, so the report
|
|
11
|
+
is the same either way. ``gh`` is what talks to GitHub, rather than a hand-rolled client:
|
|
12
|
+
runners ship it, ``GITHUB_TOKEN`` or the session proxy authenticates it, so no access
|
|
13
|
+
rule is implemented here a fourth time.
|
|
14
|
+
|
|
15
|
+
Every repository name comes from configuration or the runner's own environment, so the
|
|
16
|
+
script works unchanged in any contributor's fork.
|
|
17
|
+
"""
|
|
18
|
+
|
|
19
|
+
from __future__ import annotations
|
|
20
|
+
|
|
21
|
+
import argparse
|
|
22
|
+
import sys
|
|
23
|
+
from pathlib import Path
|
|
24
|
+
|
|
25
|
+
from basstler.environment import GitHubActionsVariable
|
|
26
|
+
from basstler.github.exceptions import GraphQLErrorsReturned, UpstreamReadError
|
|
27
|
+
from basstler.github.repository import Repository
|
|
28
|
+
from basstler.github.stack_configuration import (
|
|
29
|
+
CommittedStackConfiguration,
|
|
30
|
+
MissingUpstreamRepositoryError,
|
|
31
|
+
)
|
|
32
|
+
from basstler.standard_streams import StandardStreamHandler
|
|
33
|
+
from basstler.text_file import TextFile
|
|
34
|
+
from basstler.upstream_reviews.clients import (
|
|
35
|
+
GitHubCommandLineClient,
|
|
36
|
+
)
|
|
37
|
+
from basstler.upstream_reviews.readers import (
|
|
38
|
+
ReadSource,
|
|
39
|
+
)
|
|
40
|
+
from basstler.upstream_reviews.request import UpstreamReadRequest
|
|
41
|
+
|
|
42
|
+
logger = StandardStreamHandler.logger_for(__name__)
|
|
43
|
+
"""
|
|
44
|
+
This module's logger, which is also what its command print through.
|
|
45
|
+
"""
|
|
46
|
+
|
|
47
|
+
# %% configuration
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
def resolve_upstream_repository(
|
|
51
|
+
configuration: CommittedStackConfiguration, override: str | None = None
|
|
52
|
+
) -> Repository:
|
|
53
|
+
"""
|
|
54
|
+
Decide which repository the fork's pull requests are reviewed on.
|
|
55
|
+
|
|
56
|
+
Reads the committed settings only. The per-user layer lives on the personal-notes
|
|
57
|
+
branch, which a runner does not check out, so *override* is the escape hatch for a
|
|
58
|
+
checkout whose upstream differs.
|
|
59
|
+
|
|
60
|
+
:param configuration: The shipped defaults and the project's committed settings.
|
|
61
|
+
:param override: An ``owner/name`` reference outranking the files.
|
|
62
|
+
:return: The upstream repository.
|
|
63
|
+
:raises MissingUpstreamRepositoryError: If neither names one and no override is
|
|
64
|
+
given.
|
|
65
|
+
"""
|
|
66
|
+
if override:
|
|
67
|
+
return Repository.parse(override)
|
|
68
|
+
return configuration.upstream_repository()
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
# %% command line
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
def _parse_arguments(argv: list[str] | None) -> argparse.Namespace:
|
|
75
|
+
"""
|
|
76
|
+
Parse the command line.
|
|
77
|
+
|
|
78
|
+
:param argv: The arguments to parse, defaulting to the process's own.
|
|
79
|
+
:return: The parsed arguments.
|
|
80
|
+
"""
|
|
81
|
+
parser = argparse.ArgumentParser(description=__doc__)
|
|
82
|
+
target = parser.add_mutually_exclusive_group(required=True)
|
|
83
|
+
target.add_argument(
|
|
84
|
+
"--pull-request", type=int, help="the upstream pull request number to read"
|
|
85
|
+
)
|
|
86
|
+
target.add_argument(
|
|
87
|
+
"--branch", help="the fork branch whose upstream pull request to read"
|
|
88
|
+
)
|
|
89
|
+
parser.add_argument(
|
|
90
|
+
"--fork-owner",
|
|
91
|
+
default=GitHubActionsVariable.REPOSITORY_OWNER.read() or "",
|
|
92
|
+
help="the owner whose branches to claim, defaulting to the runner's own",
|
|
93
|
+
)
|
|
94
|
+
parser.add_argument(
|
|
95
|
+
"--upstream", help="an owner/name upstream outranking the configured one"
|
|
96
|
+
)
|
|
97
|
+
parser.add_argument(
|
|
98
|
+
"--source",
|
|
99
|
+
type=ReadSource,
|
|
100
|
+
choices=list(ReadSource),
|
|
101
|
+
default=None,
|
|
102
|
+
help="the API to read through, defaulting to the one this place can reach",
|
|
103
|
+
)
|
|
104
|
+
parser.add_argument(
|
|
105
|
+
"--include-resolved",
|
|
106
|
+
action="store_true",
|
|
107
|
+
help="show threads already marked resolved as well",
|
|
108
|
+
)
|
|
109
|
+
parser.add_argument(
|
|
110
|
+
"--failure-logs",
|
|
111
|
+
action="store_true",
|
|
112
|
+
help="quote the log behind each check that failed",
|
|
113
|
+
)
|
|
114
|
+
return parser.parse_args(argv)
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
def main(argv: list[str] | None = None) -> int:
|
|
118
|
+
"""
|
|
119
|
+
Read one upstream pull request and print its report.
|
|
120
|
+
|
|
121
|
+
A branch that was never promoted upstream is an ordinary answer rather than a crash,
|
|
122
|
+
so this boundary turns the script's own errors into a stated reason. Anything else
|
|
123
|
+
still propagates with its traceback intact.
|
|
124
|
+
|
|
125
|
+
:param argv: The arguments to parse, defaulting to the process's own.
|
|
126
|
+
:return: The process exit status.
|
|
127
|
+
"""
|
|
128
|
+
arguments = _parse_arguments(argv)
|
|
129
|
+
try:
|
|
130
|
+
report = _build_report(arguments)
|
|
131
|
+
except (
|
|
132
|
+
UpstreamReadError,
|
|
133
|
+
GraphQLErrorsReturned,
|
|
134
|
+
MissingUpstreamRepositoryError,
|
|
135
|
+
) as failure:
|
|
136
|
+
logger.error(failure)
|
|
137
|
+
return 1
|
|
138
|
+
logger.info(report)
|
|
139
|
+
summary_path = GitHubActionsVariable.STEP_SUMMARY.read()
|
|
140
|
+
if summary_path:
|
|
141
|
+
TextFile(Path(summary_path)).write(report)
|
|
142
|
+
return 0
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
def _build_report(arguments: argparse.Namespace) -> str:
|
|
146
|
+
"""
|
|
147
|
+
Read the requested pull request and render its report.
|
|
148
|
+
|
|
149
|
+
:param arguments: The parsed command line.
|
|
150
|
+
:return: The rendered markdown.
|
|
151
|
+
"""
|
|
152
|
+
client = GitHubCommandLineClient()
|
|
153
|
+
upstream = resolve_upstream_repository(
|
|
154
|
+
CommittedStackConfiguration(), override=arguments.upstream
|
|
155
|
+
)
|
|
156
|
+
source = arguments.source or ReadSource.detect()
|
|
157
|
+
return UpstreamReadRequest.from_arguments(arguments, upstream).report(
|
|
158
|
+
source.reader(upstream, arguments.fork_owner),
|
|
159
|
+
client,
|
|
160
|
+
arguments.include_resolved,
|
|
161
|
+
)
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
if __name__ == "__main__":
|
|
165
|
+
sys.exit(main())
|
|
File without changes
|