pull-request-fixer 0.1.6__tar.gz → 0.1.8__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.
- {pull_request_fixer-0.1.6 → pull_request_fixer-0.1.8}/.gitignore +1 -1
- pull_request_fixer-0.1.8/LICENSES/Apache-2.0.txt +201 -0
- pull_request_fixer-0.1.8/PKG-INFO +454 -0
- pull_request_fixer-0.1.8/README.md +412 -0
- {pull_request_fixer-0.1.6 → pull_request_fixer-0.1.8}/pyproject.toml +13 -4
- pull_request_fixer-0.1.8/scripts/README.md +87 -0
- {pull_request_fixer-0.1.6 → pull_request_fixer-0.1.8}/src/pull_request_fixer/__init__.py +1 -1
- {pull_request_fixer-0.1.6 → pull_request_fixer-0.1.8}/src/pull_request_fixer/_version.py +2 -2
- {pull_request_fixer-0.1.6 → pull_request_fixer-0.1.8}/src/pull_request_fixer/cli.py +14 -12
- {pull_request_fixer-0.1.6 → pull_request_fixer-0.1.8}/src/pull_request_fixer/exceptions.py +13 -9
- {pull_request_fixer-0.1.6 → pull_request_fixer-0.1.8}/src/pull_request_fixer/models.py +1 -32
- pull_request_fixer-0.1.6/.pre-commit-hooks.yaml +0 -12
- pull_request_fixer-0.1.6/LICENSE +0 -1
- pull_request_fixer-0.1.6/PKG-INFO +0 -686
- pull_request_fixer-0.1.6/README.md +0 -644
- pull_request_fixer-0.1.6/scripts/README.md +0 -120
- pull_request_fixer-0.1.6/src/pull_request_fixer/pr_fixer.py +0 -37
- /pull_request_fixer-0.1.6/LICENSES/Apache-2.0.txt → /pull_request_fixer-0.1.8/LICENSE +0 -0
- {pull_request_fixer-0.1.6 → pull_request_fixer-0.1.8}/src/pull_request_fixer/blocked_pr_scanner.py +0 -0
- {pull_request_fixer-0.1.6 → pull_request_fixer-0.1.8}/src/pull_request_fixer/file_fixer.py +0 -0
- {pull_request_fixer-0.1.6 → pull_request_fixer-0.1.8}/src/pull_request_fixer/git_config.py +0 -0
- {pull_request_fixer-0.1.6 → pull_request_fixer-0.1.8}/src/pull_request_fixer/github_client.py +0 -0
- {pull_request_fixer-0.1.6 → pull_request_fixer-0.1.8}/src/pull_request_fixer/graphql_queries.py +0 -0
- {pull_request_fixer-0.1.6 → pull_request_fixer-0.1.8}/src/pull_request_fixer/pr_file_fixer.py +0 -0
- {pull_request_fixer-0.1.6 → pull_request_fixer-0.1.8}/src/pull_request_fixer/pr_scanner.py +0 -0
- {pull_request_fixer-0.1.6 → pull_request_fixer-0.1.8}/src/pull_request_fixer/progress_tracker.py +0 -0
- {pull_request_fixer-0.1.6 → pull_request_fixer-0.1.8}/src/pull_request_fixer/py.typed +0 -0
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
|
@@ -0,0 +1,454 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: pull-request-fixer
|
|
3
|
+
Version: 0.1.8
|
|
4
|
+
Summary: Fix GitHub pull request titles, descriptions and files, for one pull request or across an organization
|
|
5
|
+
Project-URL: Homepage, https://github.com/lfreleng-actions/pull-request-fixer
|
|
6
|
+
Project-URL: Repository, https://github.com/lfreleng-actions/pull-request-fixer.git
|
|
7
|
+
Project-URL: Bug Tracker, https://github.com/lfreleng-actions/pull-request-fixer/issues
|
|
8
|
+
Author-email: The Linux Foundation <releng@linuxfoundation.org>
|
|
9
|
+
License: Apache-2.0
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Keywords: automation,commit-message,github,pr,pull-request,regex
|
|
12
|
+
Classifier: Development Status :: 4 - Beta
|
|
13
|
+
Classifier: Environment :: Console
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
16
|
+
Classifier: Operating System :: OS Independent
|
|
17
|
+
Classifier: Programming Language :: Python :: 3
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
23
|
+
Classifier: Topic :: Software Development :: Quality Assurance
|
|
24
|
+
Classifier: Topic :: Software Development :: Version Control :: Git
|
|
25
|
+
Requires-Python: >=3.10
|
|
26
|
+
Requires-Dist: aiolimiter>=1.2.1
|
|
27
|
+
Requires-Dist: dependamerge>=0.9.1
|
|
28
|
+
Requires-Dist: httpx[http2]>=0.28.1
|
|
29
|
+
Requires-Dist: pydantic>=2.12.5
|
|
30
|
+
Requires-Dist: rich>=14.2.0
|
|
31
|
+
Requires-Dist: tenacity>=9.1.2
|
|
32
|
+
Requires-Dist: typer>=0.20.0
|
|
33
|
+
Provides-Extra: dev
|
|
34
|
+
Requires-Dist: mypy>=1.19.0; extra == 'dev'
|
|
35
|
+
Requires-Dist: pre-commit>=4.5.0; extra == 'dev'
|
|
36
|
+
Requires-Dist: pytest-asyncio>=1.3.0; extra == 'dev'
|
|
37
|
+
Requires-Dist: pytest-cov>=7.0.0; extra == 'dev'
|
|
38
|
+
Requires-Dist: pytest-mock>=3.15.1; extra == 'dev'
|
|
39
|
+
Requires-Dist: pytest>=9.0.2; extra == 'dev'
|
|
40
|
+
Requires-Dist: ruff>=0.14.8; extra == 'dev'
|
|
41
|
+
Description-Content-Type: text/markdown
|
|
42
|
+
|
|
43
|
+
<!--
|
|
44
|
+
SPDX-License-Identifier: Apache-2.0
|
|
45
|
+
SPDX-FileCopyrightText: 2025 The Linux Foundation
|
|
46
|
+
-->
|
|
47
|
+
|
|
48
|
+
# 🛠️ Pull Request Fixer
|
|
49
|
+
|
|
50
|
+
A Python command-line tool that repairs GitHub pull requests in place. It
|
|
51
|
+
can work on one pull request or scan a whole GitHub organization, and it
|
|
52
|
+
can:
|
|
53
|
+
|
|
54
|
+
- set a pull request's **title** to the subject line of its first commit
|
|
55
|
+
- set a pull request's **description** to the body of its first commit,
|
|
56
|
+
minus Git trailers such as `Signed-off-by:`
|
|
57
|
+
- apply regex **search/replace or line removal to files** on the pull
|
|
58
|
+
request's branch, then push the result back to the pull request
|
|
59
|
+
|
|
60
|
+
A common use is unblocking automated pull requests (Dependabot,
|
|
61
|
+
pre-commit.ci and similar) that fail a semantic title check or carry a
|
|
62
|
+
small, mechanical defect across a whole organization.
|
|
63
|
+
|
|
64
|
+
By default the tool only touches **blocked** pull requests: those with
|
|
65
|
+
merge conflicts, those behind their base branch, or those with failing
|
|
66
|
+
checks.
|
|
67
|
+
|
|
68
|
+
## Contents
|
|
69
|
+
|
|
70
|
+
- [Installation](#installation)
|
|
71
|
+
- [Quick start](#quick-start)
|
|
72
|
+
- [Targets](#targets)
|
|
73
|
+
- [Which pull requests get processed](#which-pull-requests-get-processed)
|
|
74
|
+
- [Fixing titles and descriptions](#fixing-titles-and-descriptions)
|
|
75
|
+
- [Fixing files](#fixing-files)
|
|
76
|
+
- [Pull request comments](#pull-request-comments)
|
|
77
|
+
- [Options](#options)
|
|
78
|
+
- [Authentication](#authentication)
|
|
79
|
+
- [Exit status](#exit-status)
|
|
80
|
+
- [Troubleshooting](#troubleshooting)
|
|
81
|
+
- [Development](#development)
|
|
82
|
+
|
|
83
|
+
## Installation
|
|
84
|
+
|
|
85
|
+
The tool needs Python 3.10 or newer. File fixing also needs `git` on
|
|
86
|
+
`PATH`, except with `--update-method api --pr-content-only`.
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
pip install pull-request-fixer
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
Or with uv:
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
uv tool install pull-request-fixer
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
## Quick start
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
export GITHUB_TOKEN=ghp_xxxxxxxxxxxxx
|
|
102
|
+
|
|
103
|
+
# Preview title fixes for blocked pull requests across an organization
|
|
104
|
+
pull-request-fixer myorg --fix-title --dry-run
|
|
105
|
+
|
|
106
|
+
# Fix titles and descriptions for real
|
|
107
|
+
pull-request-fixer myorg --fix-title --fix-body
|
|
108
|
+
|
|
109
|
+
# Fix the title of one pull request
|
|
110
|
+
pull-request-fixer https://github.com/owner/repo/pull/123 --fix-title
|
|
111
|
+
|
|
112
|
+
# Remove 'type:' lines from the inputs section of a root action.yaml
|
|
113
|
+
pull-request-fixer https://github.com/owner/repo/pull/123 \
|
|
114
|
+
--fix-files \
|
|
115
|
+
--file-pattern '^\./action\.yaml$' \
|
|
116
|
+
--search-pattern '^\s+type:\s+\S' \
|
|
117
|
+
--remove-lines \
|
|
118
|
+
--context-start '^inputs:' \
|
|
119
|
+
--context-end '^runs:' \
|
|
120
|
+
--dry-run --show-diff
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
The tool needs at least one of `--fix-title`, `--fix-body` or
|
|
124
|
+
`--fix-files`; without one it prints a warning and exits.
|
|
125
|
+
|
|
126
|
+
## Targets
|
|
127
|
+
|
|
128
|
+
`TARGET` is the only positional argument. It can be:
|
|
129
|
+
|
|
130
|
+
| Form | Example | Mode |
|
|
131
|
+
| ----------------- | ---------------------------------------- | ------------ |
|
|
132
|
+
| Organization name | `myorg` | Organization |
|
|
133
|
+
| Organization URL | `https://github.com/myorg` | Organization |
|
|
134
|
+
| Pull request URL | `https://github.com/owner/repo/pull/123` | Single PR |
|
|
135
|
+
|
|
136
|
+
The tool works with GitHub.com; it does not support GitHub Enterprise
|
|
137
|
+
Server hosts.
|
|
138
|
+
|
|
139
|
+
In **organization mode** the tool validates the token, scans every
|
|
140
|
+
repository in the organization for open pull requests, then processes the
|
|
141
|
+
matching pull requests in parallel.
|
|
142
|
+
|
|
143
|
+
In **single PR mode** the tool processes the one pull request. Unless you
|
|
144
|
+
pass `--no-blocked-only`, it reports a closed or merged pull request and
|
|
145
|
+
exits without changing it; `--fix-files` always refuses closed pull
|
|
146
|
+
requests.
|
|
147
|
+
|
|
148
|
+
## Which pull requests get processed
|
|
149
|
+
|
|
150
|
+
Both modes process only blocked pull requests unless you pass
|
|
151
|
+
`--no-blocked-only`. The tool reuses the blocking logic from
|
|
152
|
+
[dependamerge][dependamerge], so both tools agree on which pull requests
|
|
153
|
+
count as blocked. A pull request counts as blocked when it has:
|
|
154
|
+
|
|
155
|
+
- merge conflicts (`mergeable: CONFLICTING` or merge state `dirty`)
|
|
156
|
+
- a head branch behind its base branch (merge state `behind`)
|
|
157
|
+
- one or more failing status checks or check runs
|
|
158
|
+
|
|
159
|
+
The organization scan skips draft pull requests unless you pass
|
|
160
|
+
`--include-drafts`.
|
|
161
|
+
|
|
162
|
+
In single PR mode, if the pull request is not blocked, the tool prints
|
|
163
|
+
`pull request is NOT in a blocked state` and exits with status 1. Add
|
|
164
|
+
`--no-blocked-only` to process it anyway.
|
|
165
|
+
|
|
166
|
+
## Fixing titles and descriptions
|
|
167
|
+
|
|
168
|
+
Both fixes read the **first** (oldest) commit on the pull request.
|
|
169
|
+
|
|
170
|
+
### `--fix-title`
|
|
171
|
+
|
|
172
|
+
Sets the pull request title to the first commit's subject line, when the
|
|
173
|
+
two differ.
|
|
174
|
+
|
|
175
|
+
### `--fix-body`
|
|
176
|
+
|
|
177
|
+
Sets the pull request description to the first commit's message body,
|
|
178
|
+
when the commit has a body. The tool strips trailing Git trailers from
|
|
179
|
+
the body. It recognizes these trailers, case-insensitively:
|
|
180
|
+
|
|
181
|
+
`Signed-off-by:`, `Co-authored-by:`, `Reviewed-by:`, `Tested-by:`,
|
|
182
|
+
`Acked-by:`, `Cc:`, `Reported-by:`, `Suggested-by:`, `Fixes:`,
|
|
183
|
+
`See-also:`, `Link:`, `Bug:`, `Change-Id:`
|
|
184
|
+
|
|
185
|
+
For example, given this first commit:
|
|
186
|
+
|
|
187
|
+
```text
|
|
188
|
+
Fix: Correct race condition in calendar refresh
|
|
189
|
+
|
|
190
|
+
Serialize refreshes so concurrent updates cannot interleave.
|
|
191
|
+
|
|
192
|
+
Signed-off-by: Jane Doe <jane@example.com>
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
`--fix-title` sets the title to
|
|
196
|
+
`Fix: Correct race condition in calendar refresh`, and `--fix-body` sets
|
|
197
|
+
the description to
|
|
198
|
+
`Serialize refreshes so concurrent updates cannot interleave.`
|
|
199
|
+
|
|
200
|
+
After updating a title or description, the tool asks GitHub to re-run any
|
|
201
|
+
of the pull request's check runs that ended as failed, cancelled, timed
|
|
202
|
+
out or action required. This lets checks such as a semantic pull request
|
|
203
|
+
title check pick up the change. Re-running checks is best-effort; the
|
|
204
|
+
tool ignores checks that GitHub refuses to re-run.
|
|
205
|
+
|
|
206
|
+
## Fixing files
|
|
207
|
+
|
|
208
|
+
`--fix-files` edits files on the pull request's head branch. When you
|
|
209
|
+
pass `--fix-files`, the tool **ignores** `--fix-title` and `--fix-body`;
|
|
210
|
+
run the tool twice to do both.
|
|
211
|
+
|
|
212
|
+
`--fix-files` needs:
|
|
213
|
+
|
|
214
|
+
- `--file-pattern`: a Python regular expression for the files to edit
|
|
215
|
+
- `--search-pattern`: a Python regular expression for the content to
|
|
216
|
+
change
|
|
217
|
+
- one action: `--replacement TEXT` or `--remove-lines`
|
|
218
|
+
|
|
219
|
+
### Selecting files
|
|
220
|
+
|
|
221
|
+
The tool tests `--file-pattern` with `re.search` against each file's
|
|
222
|
+
repository-relative path, both as `path/to/file` and as
|
|
223
|
+
`./path/to/file`. The pattern can match anywhere in the path, and `.`
|
|
224
|
+
matches any character, so `./action.yaml` also matches
|
|
225
|
+
`sub/dir/action.yaml`. Anchor and escape the pattern to match one file:
|
|
226
|
+
|
|
227
|
+
<!-- markdownlint-disable MD013 -->
|
|
228
|
+
|
|
229
|
+
| Pattern | Matches |
|
|
230
|
+
| ---------------------- | ------------------------------------------- |
|
|
231
|
+
| `^\./action\.yaml$` | `action.yaml` at the repository root only |
|
|
232
|
+
| `(^\|/)action\.ya?ml$` | `action.yaml` or `action.yml` in any folder |
|
|
233
|
+
| `\.github/workflows/` | every file under `.github/workflows/` |
|
|
234
|
+
|
|
235
|
+
<!-- markdownlint-enable MD013 -->
|
|
236
|
+
|
|
237
|
+
By default the tool considers every matching file in the repository at
|
|
238
|
+
the pull request's head commit. Add `--pr-content-only` to restrict it to
|
|
239
|
+
files the pull request already changes.
|
|
240
|
+
|
|
241
|
+
### Search and replace
|
|
242
|
+
|
|
243
|
+
With `--replacement`, the tool runs `re.sub` over each file's whole
|
|
244
|
+
content with `re.MULTILINE` set, so `^` and `$` match at line boundaries.
|
|
245
|
+
The replacement supports back-references such as `\1`. An empty
|
|
246
|
+
replacement (`--replacement ''`) deletes the matched text.
|
|
247
|
+
|
|
248
|
+
```bash
|
|
249
|
+
pull-request-fixer https://github.com/owner/repo/pull/456 \
|
|
250
|
+
--fix-files \
|
|
251
|
+
--file-pattern '\.py$' \
|
|
252
|
+
--search-pattern '\bold_function_name\b' \
|
|
253
|
+
--replacement 'new_function_name'
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
### Line removal
|
|
257
|
+
|
|
258
|
+
With `--remove-lines`, the tool deletes every line that matches
|
|
259
|
+
`--search-pattern`. Two optional patterns limit where removal applies:
|
|
260
|
+
|
|
261
|
+
- `--context-start`: removal begins after a line matching this pattern
|
|
262
|
+
- `--context-end`: removal stops at a line matching this pattern
|
|
263
|
+
|
|
264
|
+
The tool always keeps the marker lines themselves. Without
|
|
265
|
+
`--context-start`, removal applies from the top of the file. After a
|
|
266
|
+
`--context-end` match, removal stays off until the next
|
|
267
|
+
`--context-start` match.
|
|
268
|
+
|
|
269
|
+
### Update methods
|
|
270
|
+
|
|
271
|
+
`--update-method` chooses how the tool writes file changes back:
|
|
272
|
+
|
|
273
|
+
<!-- markdownlint-disable MD013 -->
|
|
274
|
+
|
|
275
|
+
| Behaviour | `git` (default) | `api` |
|
|
276
|
+
| ------------------------ | --------------------------------------- | ----------------------------------------- |
|
|
277
|
+
| How | Clone, amend, `--force-with-lease` push | GitHub Git Data API |
|
|
278
|
+
| Commit | Amends the branch's **last** commit | Adds a **new** commit |
|
|
279
|
+
| Commit message | Unchanged | `Fix N file(s) in PR #N` with no sign-off |
|
|
280
|
+
| Signing | Your local Git signing setup | No signature from your keys |
|
|
281
|
+
| Pull requests from forks | Supported, with push access to the fork | Not supported |
|
|
282
|
+
| File modes | Preserved | Rewritten as `100644` |
|
|
283
|
+
| Needs `git` | Yes | Unless `--pr-content-only` set |
|
|
284
|
+
|
|
285
|
+
<!-- markdownlint-enable MD013 -->
|
|
286
|
+
|
|
287
|
+
Because the `git` method amends the existing commit, it keeps that
|
|
288
|
+
commit's message, author and any `Signed-off-by:` trailer, which suits
|
|
289
|
+
repositories that enforce DCO sign-off or signed commits.
|
|
290
|
+
|
|
291
|
+
The `api` method reads and writes the head branch in the pull request's
|
|
292
|
+
**base** repository, so it only works when the branch lives there, as it
|
|
293
|
+
does for Dependabot and pre-commit.ci pull requests. Its commits carry no
|
|
294
|
+
DCO sign-off. It normally writes all changes in one commit; if that
|
|
295
|
+
batch commit fails, it falls back to one `Fix <path>` commit per file.
|
|
296
|
+
|
|
297
|
+
### Git identity and signing
|
|
298
|
+
|
|
299
|
+
These flags apply to the `git` method only:
|
|
300
|
+
|
|
301
|
+
- default: copy `user.name`, `user.email` and the commit signing settings
|
|
302
|
+
(`commit.gpgsign`, `gpg.format`, `user.signingkey` and related keys)
|
|
303
|
+
from your global Git configuration
|
|
304
|
+
- `--disable-signing`: use your identity but turn signing off
|
|
305
|
+
- `--bot-identity`: commit as `pull-request-fixer
|
|
306
|
+
<noreply@linuxfoundation.org>` without signing
|
|
307
|
+
|
|
308
|
+
If your global Git configuration has no `user.name` or `user.email`, the
|
|
309
|
+
tool falls back to the bot identity. You cannot combine `--bot-identity`
|
|
310
|
+
with `--disable-signing`.
|
|
311
|
+
|
|
312
|
+
### Previewing changes
|
|
313
|
+
|
|
314
|
+
`--dry-run` makes no changes. `--show-diff` prints a unified diff for each
|
|
315
|
+
changed file; organization dry runs always print diffs.
|
|
316
|
+
|
|
317
|
+
## Pull request comments
|
|
318
|
+
|
|
319
|
+
When the tool changes a pull request (not in dry-run mode), it posts a
|
|
320
|
+
comment describing the change. For title and description fixes:
|
|
321
|
+
|
|
322
|
+
```markdown
|
|
323
|
+
## 🛠️ Pull Request Fixer
|
|
324
|
+
|
|
325
|
+
Automatically fixed pull request metadata:
|
|
326
|
+
- Updated pull request title to match commit
|
|
327
|
+
- Updated pull request description to match commit body message
|
|
328
|
+
|
|
329
|
+
---
|
|
330
|
+
*This fix was automatically applied by [pull-request-fixer](https://github.com/lfreleng-actions/pull-request-fixer)*
|
|
331
|
+
```
|
|
332
|
+
|
|
333
|
+
For file fixes, the comment shows the command options used and the diff
|
|
334
|
+
for each file. When the diffs total more than 40 lines, it lists the
|
|
335
|
+
changed files instead.
|
|
336
|
+
|
|
337
|
+
## Options
|
|
338
|
+
|
|
339
|
+
<!-- markdownlint-disable MD013 -->
|
|
340
|
+
|
|
341
|
+
| Option | Short | Default | Description |
|
|
342
|
+
| ------------------- | ----- | --------------- | ----------------------------------------------------------------- |
|
|
343
|
+
| `--token` | `-t` | `$GITHUB_TOKEN` | GitHub token |
|
|
344
|
+
| `--fix-title` | | off | Set the title to the first commit's subject |
|
|
345
|
+
| `--fix-body` | | off | Set the description to the first commit's body, minus trailers |
|
|
346
|
+
| `--fix-files` | | off | Edit files with regex; overrides `--fix-title` and `--fix-body` |
|
|
347
|
+
| `--file-pattern` | | | Regex for file paths (required with `--fix-files`) |
|
|
348
|
+
| `--search-pattern` | | | Regex for file content (required with `--fix-files`) |
|
|
349
|
+
| `--replacement` | | | Replacement text; supports back-references |
|
|
350
|
+
| `--remove-lines` | | off | Delete matching lines instead of replacing |
|
|
351
|
+
| `--context-start` | | | Regex for the line after which removal begins |
|
|
352
|
+
| `--context-end` | | | Regex for the line at which removal stops |
|
|
353
|
+
| `--pr-content-only` | | off | Only edit files the pull request already changes |
|
|
354
|
+
| `--show-diff` | | off | Print a unified diff for each changed file |
|
|
355
|
+
| `--update-method` | | `git` | `git` (clone, amend, push) or `api` (new commit through the API) |
|
|
356
|
+
| `--disable-signing` | | off | `git` method: use your identity without signing |
|
|
357
|
+
| `--bot-identity` | | off | `git` method: commit as the bot identity without signing |
|
|
358
|
+
| `--include-drafts` | | off | Include draft pull requests |
|
|
359
|
+
| `--no-blocked-only` | | off | Process pull requests regardless of blocked state |
|
|
360
|
+
| `--dry-run` | | off | Preview changes without applying them |
|
|
361
|
+
| `--workers` | `-j` | CPU cores | Parallel workers, 1-32; defaults to the performance core count |
|
|
362
|
+
| `--verbose` | `-v` | off | Debug logging |
|
|
363
|
+
| `--quiet` | `-q` | off | Errors only |
|
|
364
|
+
| `--log-level` | | `INFO` | Logging level |
|
|
365
|
+
| `--version` | | | Print the version and exit |
|
|
366
|
+
| `--help` | `-h` | | Print the version and help, then exit |
|
|
367
|
+
|
|
368
|
+
<!-- markdownlint-enable MD013 -->
|
|
369
|
+
|
|
370
|
+
## Authentication
|
|
371
|
+
|
|
372
|
+
Pass a GitHub token with `--token` or the `GITHUB_TOKEN` environment
|
|
373
|
+
variable. The token needs:
|
|
374
|
+
|
|
375
|
+
- read access to the repositories you scan, and `read:org` to list an
|
|
376
|
+
organization's repositories and read check status
|
|
377
|
+
- write access to pull requests to change titles, descriptions and
|
|
378
|
+
comments
|
|
379
|
+
- push access to the pull request's head repository for `--fix-files`;
|
|
380
|
+
with the `git` method on a pull request from a fork, that means the fork
|
|
381
|
+
|
|
382
|
+
With a classic personal access token, grant `repo` (or `public_repo` for
|
|
383
|
+
public repositories only) and `read:org`. In organization mode the tool
|
|
384
|
+
validates the token first and warns when it cannot see those scopes.
|
|
385
|
+
Tokens issued to GitHub Actions do not report scopes, so the tool skips
|
|
386
|
+
that check for them.
|
|
387
|
+
|
|
388
|
+
## Exit status
|
|
389
|
+
|
|
390
|
+
| Status | Meaning |
|
|
391
|
+
| ------ | ------------------------------------------------------------------- |
|
|
392
|
+
| `0` | Run completed; also when single PR mode finds a closed or merged PR |
|
|
393
|
+
| `1` | Missing target, fix option or token; API error; PR not blocked |
|
|
394
|
+
| `2` | Unknown option or out-of-range value, such as `--workers 33` |
|
|
395
|
+
|
|
396
|
+
An organization run exits `0` even when updating some pull requests
|
|
397
|
+
fails. Check the `❌ Failed updates:` line in its summary.
|
|
398
|
+
|
|
399
|
+
## Troubleshooting
|
|
400
|
+
|
|
401
|
+
**`✅ No blocked PRs found!`** — the organization has no open pull
|
|
402
|
+
requests that count as blocked. Use `--no-blocked-only` to process all
|
|
403
|
+
open pull requests, or `--include-drafts` to include drafts.
|
|
404
|
+
|
|
405
|
+
**`pull request is NOT in a blocked state`** — single PR mode only
|
|
406
|
+
processes blocked pull requests by default. Add `--no-blocked-only`.
|
|
407
|
+
|
|
408
|
+
**Token validation failed or scope warnings** — check that the token has
|
|
409
|
+
not expired and has the access listed under
|
|
410
|
+
[Authentication](#authentication).
|
|
411
|
+
|
|
412
|
+
**`Push rejected` errors** — someone pushed to the pull request branch
|
|
413
|
+
while the tool worked on it; run the tool again.
|
|
414
|
+
|
|
415
|
+
**Rate limiting** — reduce `--workers`, or wait for the limit to reset.
|
|
416
|
+
|
|
417
|
+
**Unexpected files changed** — anchor `--file-pattern` as shown in
|
|
418
|
+
[Selecting files](#selecting-files), and preview with
|
|
419
|
+
`--dry-run --show-diff`.
|
|
420
|
+
|
|
421
|
+
Use `--verbose` for debug logging. The `scripts/` directory holds
|
|
422
|
+
diagnostic scripts for GraphQL and organization access problems; see
|
|
423
|
+
[scripts/README.md](scripts/README.md).
|
|
424
|
+
|
|
425
|
+
## Development
|
|
426
|
+
|
|
427
|
+
```bash
|
|
428
|
+
git clone https://github.com/lfreleng-actions/pull-request-fixer.git
|
|
429
|
+
cd pull-request-fixer
|
|
430
|
+
uv sync --extra dev
|
|
431
|
+
prek install -t pre-commit -t commit-msg
|
|
432
|
+
uv run pytest
|
|
433
|
+
uv run bash scripts/integration-test.sh
|
|
434
|
+
```
|
|
435
|
+
|
|
436
|
+
The test dependencies live in the `dev` extra, so plain `uv sync` leaves
|
|
437
|
+
`pytest` missing. See [CONTRIBUTING.md](CONTRIBUTING.md) for the
|
|
438
|
+
contribution workflow, [SETUP.md](SETUP.md) for installation and CI use,
|
|
439
|
+
[IMPLEMENTATION.md](IMPLEMENTATION.md) for the internals, and
|
|
440
|
+
[TESTING.md](TESTING.md) for testing against live pull requests.
|
|
441
|
+
|
|
442
|
+
## License
|
|
443
|
+
|
|
444
|
+
Apache-2.0
|
|
445
|
+
|
|
446
|
+
## Related projects
|
|
447
|
+
|
|
448
|
+
- [dependamerge][dependamerge]: bulk pull request management for GitHub
|
|
449
|
+
organizations; this tool uses its blocked pull request detection
|
|
450
|
+
- [markdown-table-fixer][mtf]: fixes markdown table formatting; this
|
|
451
|
+
project began as a fork of its codebase
|
|
452
|
+
|
|
453
|
+
[dependamerge]: https://github.com/lfreleng-actions/dependamerge
|
|
454
|
+
[mtf]: https://github.com/lfreleng-actions/markdown-table-fixer
|