github2gerrit 0.1.5__py3-none-any.whl → 0.1.7__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.
@@ -0,0 +1,24 @@
1
+ github2gerrit/__init__.py,sha256=N1Vj1HJ28LKCJLAynQdm5jFGQQAz9YSMzZhEfvbBgow,886
2
+ github2gerrit/cli.py,sha256=heW3rwfUwPiBVIPyxDq49kF7fdtKunJAUer9z31mg_o,45538
3
+ github2gerrit/commit_normalization.py,sha256=u4AZigz3qOpz5XYpUOq3WUqsY-o08YrkgaT160eyIIs,16594
4
+ github2gerrit/config.py,sha256=sTiujlOjCsJbaA-Ftr5XR--9nxs7XH8uEWD-IbGqLYk,17370
5
+ github2gerrit/core.py,sha256=Mjo_TNocFE5HDmRTxh54LEHAEw5y1u6lc1qItEZ76GA,105180
6
+ github2gerrit/duplicate_detection.py,sha256=5j6EDz2P3GnnT2JkR1tGbzWCjA6TV0l5VjsEMs-tfCM,26544
7
+ github2gerrit/external_api.py,sha256=EVHh__v6lRq_ojpBI_nkGZ31AQSZ9NG8tDqVUid23XY,17638
8
+ github2gerrit/gerrit_rest.py,sha256=NmC95hb2hLpnko8Uu3OwPEKktNv-k3qrmuA7A2q-H0Y,10562
9
+ github2gerrit/gerrit_urls.py,sha256=pw4rjIQeQ-i-vbPqsOZjZpdz7FO03pnMUMWc8L9Mcic,12893
10
+ github2gerrit/github_api.py,sha256=1cTZMunDx6_oLNR3Z__ya6vsw0_PFS5ww3jQla5SVFA,8229
11
+ github2gerrit/gitutils.py,sha256=3ob1K7dlKeWYYYOPXIIJ56p2N49lm1yj8XHHg2zSlhw,25929
12
+ github2gerrit/models.py,sha256=sRS4rPMF_wjV19HMFTzhHXFMfsLFzm9TFb1JydJsSyQ,1875
13
+ github2gerrit/pr_content_filter.py,sha256=w4MqSZ4uLX-3Da1DL_A56zVQa7xJ4h5jHMNteOOG2AE,16896
14
+ github2gerrit/similarity.py,sha256=xPqdypI-Fmpeb74K4lcqZBxj17i8avS_x73dXckeicA,15268
15
+ github2gerrit/ssh_agent_setup.py,sha256=fvKuMdF9Hv5ioaSu_alzLcjeoQLGGFRLS2wb46KdNzE,11889
16
+ github2gerrit/ssh_common.py,sha256=f0QQmnj6yIW74N3ZjGkYmJryEstjEOmq41EIXOZdGTM,8102
17
+ github2gerrit/ssh_discovery.py,sha256=zH0tX9VN1pn8DLM1J9QQquoKBhA9gk5drXHvMSHNNLg,13021
18
+ github2gerrit/utils.py,sha256=ADE5YZe1h3PB3cgfxbsCuYU-Xs-1CMHrDHxfIdariFE,3369
19
+ github2gerrit-0.1.7.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
20
+ github2gerrit-0.1.7.dist-info/METADATA,sha256=4EZvJoxh9EhKSxcHrv-SJ1IHE7rbe5VYFH7WhKzxJD0,30930
21
+ github2gerrit-0.1.7.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
22
+ github2gerrit-0.1.7.dist-info/entry_points.txt,sha256=MxN2_liIKo3-xJwtAulAeS5GcOS6JS96nvwOQIkP3W8,56
23
+ github2gerrit-0.1.7.dist-info/top_level.txt,sha256=bWTYXjvuu4sSU90KLT1JlnjD7xV_iXZ-vKoulpjLTy8,14
24
+ github2gerrit-0.1.7.dist-info/RECORD,,
@@ -1,555 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: github2gerrit
3
- Version: 0.1.5
4
- Summary: Submit a GitHub pull request to a Gerrit repository.
5
- Author-email: Matthew Watkins <mwatkins@linuxfoundation.org>
6
- License-Expression: Apache-2.0
7
- Project-URL: Homepage, https://github.com//lfreleng-actions/github2gerrit
8
- Project-URL: Repository, https://github.com//lfreleng-actions/github2gerrit
9
- Project-URL: Issues, https://github.com//lfreleng-actions/github2gerrit/issues
10
- Keywords: github,gerrit,ci,actions,typer,cli
11
- Classifier: Development Status :: 4 - Beta
12
- Classifier: Environment :: Console
13
- Classifier: Intended Audience :: Developers
14
- Classifier: Programming Language :: Python :: 3
15
- Classifier: Programming Language :: Python :: 3 :: Only
16
- Classifier: Programming Language :: Python :: 3.11
17
- Classifier: Programming Language :: Python :: 3.12
18
- Classifier: Programming Language :: Python :: 3.13
19
- Classifier: Topic :: Software Development :: Build Tools
20
- Classifier: Topic :: Software Development :: Version Control
21
- Classifier: Typing :: Typed
22
- Requires-Python: <3.14,>=3.11
23
- Description-Content-Type: text/markdown
24
- License-File: LICENSE
25
- Requires-Dist: typer>=0.12.5
26
- Requires-Dist: PyGithub>=2.3.0
27
- Requires-Dist: pygerrit2>=2.0.0
28
- Requires-Dist: git-review>=2.3.1
29
- Provides-Extra: dev
30
- Requires-Dist: pytest>=8.3.2; extra == "dev"
31
- Requires-Dist: pytest-cov>=5.0.0; extra == "dev"
32
- Requires-Dist: coverage[toml]>=7.6.1; extra == "dev"
33
- Requires-Dist: ruff>=0.6.3; extra == "dev"
34
- Requires-Dist: black>=24.8.0; extra == "dev"
35
- Requires-Dist: mypy>=1.11.2; extra == "dev"
36
- Requires-Dist: pytest-mock>=3.14.0; extra == "dev"
37
- Requires-Dist: types-requests>=2.31.0; extra == "dev"
38
- Requires-Dist: types-click>=7.1.8; extra == "dev"
39
- Dynamic: license-file
40
-
41
- <!--
42
- SPDX-License-Identifier: Apache-2.0
43
- SPDX-FileCopyrightText: 2025 The Linux Foundation
44
- -->
45
-
46
- # github2gerrit
47
-
48
- Submit a GitHub pull request to a Gerrit repository, implemented in Python.
49
-
50
- This action is a drop‑in replacement for the shell‑based
51
- `lfit/github2gerrit` composite action. It mirrors the same inputs,
52
- outputs, environment variables, and secrets so you can adopt it without
53
- changing existing configuration in your organizations.
54
-
55
- The tool expects a `.gitreview` file in the repository to derive Gerrit
56
- connection details and the destination project. It uses `git` over SSH
57
- and `git-review` semantics to push to `refs/for/<branch>` and relies on
58
- Gerrit `Change-Id` trailers to create or update changes.
59
-
60
- Note: the initial versions focus on compatibility and clear logging.
61
- The behavior matches the existing action, and this implementation
62
- refactors it to Python with typed modules and test support.
63
-
64
- ## How it works (high level)
65
-
66
- - Discover pull request context and inputs.
67
- - Check for duplicate changes to prevent spam from automated tools.
68
- - Read `.gitreview` for Gerrit host, port, and project.
69
- - Set up `git` user config and SSH for Gerrit.
70
- - Prepare commits:
71
- - one‑by‑one cherry‑pick with `Change-Id` trailers, or
72
- - squash into a single commit and keep or reuse `Change-Id`.
73
- - Optionally replace the commit message with PR title and body.
74
- - Push with a topic to `refs/for/<branch>` using `git-review` behavior.
75
- - Query Gerrit for the resulting URL, change number, and patchset SHA.
76
- - Add a back‑reference comment in Gerrit to the GitHub PR and run URL.
77
- - Comment on the GitHub PR with the Gerrit change URL(s).
78
- - Optionally close the PR (mirrors the shell action policy).
79
-
80
- ## Requirements
81
-
82
- - Repository contains a `.gitreview` file. If you cannot provide it,
83
- you must pass `GERRIT_SERVER`, `GERRIT_SERVER_PORT`, and
84
- `GERRIT_PROJECT` via the reusable workflow interface.
85
- - SSH key for Gerrit and known hosts are available to the workflow.
86
- - The default `GITHUB_TOKEN` is available for PR metadata and comments.
87
- - The workflow grants permissions required for PR interactions:
88
- - `pull-requests: write` (to comment on and close PRs)
89
- - `issues: write` (to create PR comments via the Issues API)
90
- - The workflow runs with `pull_request_target` or via
91
- `workflow_dispatch` using a valid PR context.
92
-
93
- ### Note on sitecustomize.py
94
-
95
- This repository includes a sitecustomize.py that is automatically
96
- imported by Python’s site initialization. It exists to make pytest and
97
- coverage runs in CI more robust by:
98
-
99
- - assigns a unique COVERAGE_FILE per process to avoid mixing data across runs
100
- - proactively removing stale .coverage artifacts in common base directories.
101
-
102
- The logic runs during pytest sessions and is best effort.
103
- It never interferes with normal execution. Maintainers can keep it to
104
- stabilize coverage reporting for parallel/xdist runs.
105
-
106
- ## Duplicate detection
107
-
108
- By default, the tool checks for duplicate changes to prevent spam
109
- submissions from automated tools like Dependabot. It compares PR titles,
110
- content, and files changed against recent PRs (last 7 days) and will
111
- exit with an error when it finds duplicates.
112
-
113
- ### Examples of detected duplicates
114
-
115
- - Identical Dependabot PRs: "Bump package from 1.0 to 1.1"
116
- - Sequential dependency updates: "Bump package 1.0→1.1", "Bump package 1.1→1.2"
117
- - Similar bug fixes with slightly different wording
118
-
119
- ### Allowing duplicates
120
-
121
- Use `--allow-duplicates` or set `ALLOW_DUPLICATES=true` to override:
122
-
123
- ```bash
124
- # CLI usage
125
- github2gerrit --allow-duplicates https://github.com/org/repo
126
-
127
- # GitHub Actions
128
- uses: onap/github2gerrit@main
129
- with:
130
- ALLOW_DUPLICATES: 'true'
131
- ```
132
-
133
- When allowed, duplicates generate warnings but processing continues.
134
- The tool exits with code 3 when it detects duplicates and they are not allowed.
135
-
136
- ## Usage
137
-
138
- This action runs as part of a workflow that triggers on
139
- `pull_request_target` and also supports manual runs via
140
- `workflow_dispatch`.
141
-
142
- Minimal example:
143
-
144
- ```yaml
145
- name: github2gerrit
146
-
147
- on:
148
- pull_request_target:
149
- types: [opened, reopened, edited, synchronize]
150
- workflow_dispatch:
151
-
152
- permissions:
153
- contents: read
154
- pull-requests: write
155
- issues: write
156
-
157
- jobs:
158
- submit-to-gerrit:
159
- runs-on: ubuntu-latest
160
- steps:
161
- - name: Submit PR to Gerrit
162
- id: g2g
163
- uses: lfit/github2gerrit@main
164
- with:
165
- SUBMIT_SINGLE_COMMITS: "false"
166
- USE_PR_AS_COMMIT: "false"
167
- FETCH_DEPTH: "10"
168
- GERRIT_KNOWN_HOSTS: ${{ vars.GERRIT_KNOWN_HOSTS }}
169
- GERRIT_SSH_PRIVKEY_G2G: ${{ secrets.GERRIT_SSH_PRIVKEY_G2G }}
170
- GERRIT_SSH_USER_G2G: ${{ vars.GERRIT_SSH_USER_G2G }}
171
- GERRIT_SSH_USER_G2G_EMAIL: ${{ vars.GERRIT_SSH_USER_G2G_EMAIL }}
172
- ORGANIZATION: ${{ github.repository_owner }}
173
- REVIEWERS_EMAIL: ""
174
- ISSUE_ID: "" # Optional: adds 'Issue-ID: ...' trailer to the commit message
175
- ```
176
-
177
- The action reads `.gitreview`. If `.gitreview` is absent, you must
178
- supply Gerrit connection details through a reusable workflow or by
179
- setting the corresponding environment variables before invoking the
180
- action. The shell action enforces `.gitreview` for the composite
181
- variant; this Python action mirrors that behavior for compatibility.
182
-
183
- ## Command Line Usage and Debugging
184
-
185
- ### Direct Command Line Usage
186
-
187
- You can run the tool directly from the command line to process GitHub pull requests:
188
-
189
- ```bash
190
- # Process a specific pull request
191
- github2gerrit https://github.com/owner/repo/pull/123
192
-
193
- # Process all open pull requests in a repository
194
- github2gerrit https://github.com/owner/repo
195
-
196
- # Run in CI mode (reads from environment variables)
197
- github2gerrit
198
- ```
199
-
200
- ### Available Options
201
-
202
- ```bash
203
- github2gerrit --help
204
- ```
205
-
206
- Key options include:
207
-
208
- - `--verbose` / `-v`: Enable verbose debug logging
209
- - `--dry-run`: Check configuration without making changes
210
- - `--submit-single-commits`: Submit each commit individually
211
- - `--use-pr-as-commit`: Use PR title/body as commit message
212
- - `--issue-id`: Add an Issue-ID trailer (e.g., "Issue-ID: ABC-123")
213
- to the commit message
214
- - `--preserve-github-prs`: Don't close GitHub PRs after submission
215
-
216
- ### Debugging and Troubleshooting
217
-
218
- When encountering issues, enable verbose logging to see detailed execution:
219
-
220
- ```bash
221
- # Using the CLI flag
222
- github2gerrit --verbose https://github.com/owner/repo/pull/123
223
-
224
- # Using environment variable
225
- G2G_LOG_LEVEL=DEBUG github2gerrit https://github.com/owner/repo/pull/123
226
-
227
- # Alternative environment variable
228
- G2G_VERBOSE=true github2gerrit https://github.com/owner/repo/pull/123
229
- ```
230
-
231
- Debug output includes:
232
-
233
- - Git command execution and output
234
- - SSH connection attempts
235
- - Gerrit API interactions
236
- - Branch resolution logic
237
- - Change-Id processing
238
-
239
- Common issues and solutions:
240
-
241
- 1. **Configuration Validation Errors**: The tool provides clear error messages when
242
- required configuration is missing or invalid. Look for messages starting with
243
- "Configuration validation failed:" that specify missing inputs like
244
- `GERRIT_KNOWN_HOSTS`, `GERRIT_SSH_PRIVKEY_G2G`, etc.
245
- 2. **SSH Permission Denied**: Ensure `GERRIT_SSH_PRIVKEY_G2G` and
246
- `GERRIT_KNOWN_HOSTS` are properly set
247
- 3. **Branch Not Found**: Check that the target branch exists in both GitHub and Gerrit
248
- 4. **Change-Id Issues**: Enable debug logging to see Change-Id generation and validation
249
- 5. **Gerrit API Errors**: Verify Gerrit server connectivity and project permissions
250
-
251
- > **Note**: The tool displays configuration errors cleanly without Python tracebacks.
252
- > If you see a traceback in the output, please report it as a bug.
253
-
254
- ### Environment Variables
255
-
256
- The tool respects these environment variables for configuration:
257
-
258
- - `G2G_LOG_LEVEL`: Set to `DEBUG` for verbose output (default: `INFO`)
259
- - `G2G_VERBOSE`: Set to `true` to enable debug logging
260
- - `GERRIT_SSH_PRIVKEY_G2G`: SSH private key content
261
- - `GERRIT_KNOWN_HOSTS`: SSH known hosts entries
262
- - `GERRIT_SSH_USER_G2G`: Gerrit SSH username
263
- - `DRY_RUN`: Set to `true` for check mode
264
-
265
- ## Advanced usage
266
-
267
- You can explicitly install the SSH key and provide a custom SSH configuration
268
- before invoking this action. This is useful when:
269
-
270
- - You want to override the port/host used by SSH
271
- - You need to define host aliases or SSH options
272
- - Your Gerrit instance uses a non-standard HTTP base path (e.g. /r)
273
-
274
- Example:
275
-
276
- ```yaml
277
- name: github2gerrit (advanced)
278
-
279
- on:
280
- pull_request_target:
281
- types: [opened, reopened, edited, synchronize]
282
- workflow_dispatch:
283
-
284
- permissions:
285
- contents: read
286
- pull-requests: write
287
- issues: write
288
-
289
- jobs:
290
- submit-to-gerrit:
291
- runs-on: ubuntu-latest
292
- steps:
293
- - name: Install SSH key and custom SSH config
294
- <!-- markdownlint-disable-next-line MD013 -->
295
- uses: shimataro/ssh-key-action@d4fffb50872869abe2d9a9098a6d9c5aa7d16be4 # v2.7.0
296
- with:
297
- key: ${{ secrets.GERRIT_SSH_PRIVKEY_G2G }}
298
- name: "id_rsa"
299
- known_hosts: ${{ vars.GERRIT_KNOWN_HOSTS }}
300
- config: |
301
- Host ${{ vars.GERRIT_SERVER }}
302
- User ${{ vars.GERRIT_SSH_USER_G2G }}
303
- Port ${{ vars.GERRIT_SERVER_PORT }}
304
- PubkeyAcceptedKeyTypes +ssh-rsa
305
- IdentityFile ~/.ssh/id_rsa
306
-
307
- - name: Submit PR to Gerrit (with explicit overrides)
308
- id: g2g
309
- uses: lfit/github2gerrit@main
310
- with:
311
- # Behavior
312
- SUBMIT_SINGLE_COMMITS: "false"
313
- USE_PR_AS_COMMIT: "false"
314
- FETCH_DEPTH: "10"
315
-
316
- # Required SSH/identity
317
- GERRIT_KNOWN_HOSTS: ${{ vars.GERRIT_KNOWN_HOSTS }}
318
- GERRIT_SSH_PRIVKEY_G2G: ${{ secrets.GERRIT_SSH_PRIVKEY_G2G }}
319
- GERRIT_SSH_USER_G2G: ${{ vars.GERRIT_SSH_USER_G2G }}
320
- GERRIT_SSH_USER_G2G_EMAIL: ${{ vars.GERRIT_SSH_USER_G2G_EMAIL }}
321
-
322
- # Optional overrides when .gitreview is missing or to force values
323
- GERRIT_SERVER: ${{ vars.GERRIT_SERVER }}
324
- GERRIT_SERVER_PORT: ${{ vars.GERRIT_SERVER_PORT }}
325
- GERRIT_PROJECT: ${{ vars.GERRIT_PROJECT }}
326
-
327
- # Optional Gerrit REST base path and credentials (if required)
328
- # e.g. '/r' for some deployments
329
- GERRIT_HTTP_BASE_PATH: ${{ vars.GERRIT_HTTP_BASE_PATH }}
330
- GERRIT_HTTP_USER: ${{ vars.GERRIT_HTTP_USER }}
331
- GERRIT_HTTP_PASSWORD: ${{ secrets.GERRIT_HTTP_PASSWORD }}
332
-
333
- ORGANIZATION: ${{ github.repository_owner }}
334
- REVIEWERS_EMAIL: ""
335
- ```
336
-
337
- Notes:
338
-
339
- - If both this step and the action define SSH configuration, the last
340
- configuration applied in the runner wins.
341
- - For most users, you can rely on the action’s built-in SSH setup. Use this
342
- advanced configuration when you need custom SSH behavior or hosts.
343
-
344
- ## GitHub Enterprise support
345
-
346
- - Direct-URL mode accepts enterprise GitHub hosts when explicitly enabled.
347
- Default: off (use github.com by default). Enable via the CLI flag
348
- --allow-ghe-urls or by setting ALLOW_GHE_URLS="true".
349
- - In GitHub Actions, this action works with GitHub Enterprise when the
350
- workflow runs in that enterprise environment and provides a valid
351
- GITHUB_TOKEN. For direct-URL runs outside Actions, ensure ORGANIZATION
352
- and GITHUB_REPOSITORY reflect the target repository.
353
-
354
- ## Inputs
355
-
356
- All inputs are strings, matching the composite action.
357
-
358
- - SUBMIT_SINGLE_COMMITS
359
- - Submit one commit at a time to Gerrit. Default: "false".
360
- - USE_PR_AS_COMMIT
361
- - Use PR title and body as the commit message. Default: "false".
362
- - FETCH_DEPTH
363
- - Depth used when checking out the repository. Default: "10".
364
- - GERRIT_KNOWN_HOSTS
365
- - SSH known hosts content for the Gerrit host. Required.
366
- - GERRIT_SSH_PRIVKEY_G2G
367
- - SSH private key for Gerrit. Required.
368
- - GERRIT_SSH_USER_G2G
369
- - Gerrit SSH username. Required.
370
- - GERRIT_SSH_USER_G2G_EMAIL
371
- - Gerrit SSH user email (used for commit identity). Required.
372
- - ORGANIZATION
373
- - Organization name, defaults to `github.repository_owner`.
374
- - REVIEWERS_EMAIL
375
- - Comma separated reviewer emails. If empty, defaults to
376
- `GERRIT_SSH_USER_G2G_EMAIL`.
377
- - ALLOW_GHE_URLS
378
- - Allow non-github.com GitHub Enterprise URLs in direct URL mode. Default: "false".
379
- - Set to "true" to allow non-github.com enterprise hosts.
380
-
381
- Optional inputs when `.gitreview` is not present (parity with
382
- the reusable workflow):
383
-
384
- - GERRIT_SERVER
385
- - Gerrit host, e.g. `git.opendaylight.org`. Default: "".
386
- - GERRIT_SERVER_PORT
387
- - Gerrit port, default "29418".
388
- - GERRIT_PROJECT
389
- - Gerrit project name, e.g. `releng/builder`. Default: "".
390
-
391
- ## Outputs
392
-
393
- - url
394
- - Gerrit change URL(s). Multi‑line when the action submits more than one change.
395
- - change_number
396
- - Gerrit change number(s). Multi‑line when the action submits more than one change.
397
-
398
- These outputs mirror the composite action. They are also exported into
399
- the environment as:
400
-
401
- - GERRIT_CHANGE_REQUEST_URL
402
- - GERRIT_CHANGE_REQUEST_NUM
403
-
404
- ## Known Keys
405
-
406
- The table below lists all the configuration directives supported by the tool,
407
- along with the corresponding environment variable (also GitHub action input)
408
- and the corresponding CLI flags.
409
-
410
- <!-- markdownlint-disable MD013 -->
411
-
412
- | Environment Variable / GitHub Input | Configuration Directive | CLI Flag | Description |
413
- |-------------------------------------|-------------------------|----------|-------------|
414
- | `SUBMIT_SINGLE_COMMITS` | `submit_single_commits` | `--submit-single-commits` | Submit one commit at a time to the Gerrit repository |
415
- | `USE_PR_AS_COMMIT` | `use_pr_as_commit` | `--use-pr-as-commit` | Use PR title and body as the commit message |
416
- | `FETCH_DEPTH` | `fetch_depth` | `--fetch-depth` | Fetch-depth for the clone (default: 10) |
417
- | `GERRIT_KNOWN_HOSTS` | `gerrit_known_hosts` | `--gerrit-known-hosts` | Known hosts entries for Gerrit SSH |
418
- | `GERRIT_SSH_PRIVKEY_G2G` | `gerrit_ssh_privkey_g2g` | `--gerrit-ssh-privkey-g2g` | SSH private key for Gerrit (string content) |
419
- | `GERRIT_SSH_USER_G2G` | `gerrit_ssh_user_g2g` | `--gerrit-ssh-user-g2g` | Gerrit SSH user |
420
- | `GERRIT_SSH_USER_G2G_EMAIL` | `gerrit_ssh_user_g2g_email` | `--gerrit-ssh-user-g2g-email` | Email address for the Gerrit SSH user |
421
- | `ORGANIZATION` | `organization` | `--organization` | Organization (defaults to GITHUB_REPOSITORY_OWNER when unset) |
422
- | `REVIEWERS_EMAIL` | `reviewers_email` | `--reviewers-email` | Comma-separated list of reviewer emails |
423
- | `ALLOW_GHE_URLS` | `allow_ghe_urls` | `--allow-ghe-urls` | Allow non-github.com GitHub Enterprise URLs in direct URL mode |
424
- | `PRESERVE_GITHUB_PRS` | `preserve_github_prs` | `--preserve-github-prs` | Do not close GitHub PRs after pushing to Gerrit |
425
- | `DRY_RUN` | `dry_run` | `--dry-run` | Check settings and PR metadata; do not write to Gerrit |
426
- | `GERRIT_SERVER` | `gerrit_server` | `--gerrit-server` | Gerrit server hostname (optional; .gitreview preferred) |
427
- | `GERRIT_SERVER_PORT` | `gerrit_server_port` | `--gerrit-server-port` | Gerrit SSH port (default: 29418) |
428
- | `GERRIT_PROJECT` | `gerrit_project` | `--gerrit-project` | Gerrit project (optional; .gitreview preferred) |
429
- | `ISSUE_ID` | `issue_id` | `--issue-id` | Issue ID to include in commit message (e.g., Issue-ID: ABC-123) |
430
- | `ALLOW_DUPLICATES` | `allow_duplicates` | `--allow-duplicates` | Allow submitting duplicate changes without error |
431
- | `G2G_VERBOSE` | `g2g_verbose` | `--verbose` / `-v` | Enable verbose debug logging |
432
- | `G2G_SKIP_GERRIT_COMMENTS` | `g2g_skip_gerrit_comments` | N/A | Skip adding back-reference comments to Gerrit changes |
433
- | `GITHUB_TOKEN` | `github_token` | N/A | GitHub API token for accessing repository and PR data |
434
- | `PR_NUMBER` | `pr_number` | N/A | Pull request number (set automatically in CI) |
435
- | `SYNC_ALL_OPEN_PRS` | `sync_all_open_prs` | N/A | Process all open pull requests (internal use) |
436
- | `GERRIT_HTTP_BASE_PATH` | `gerrit_http_base_path` | N/A | HTTP base path for Gerrit API (e.g., "/r") |
437
- | `GERRIT_HTTP_USER` | `gerrit_http_user` | N/A | Gerrit HTTP username for REST API authentication |
438
- | `GERRIT_HTTP_PASSWORD` | `gerrit_http_password` | N/A | Gerrit HTTP password/token for REST API authentication |
439
-
440
- <!-- markdownlint-enable MD013 -->
441
-
442
- ### Configuration Precedence
443
-
444
- The tool follows this precedence order for configuration values:
445
-
446
- 1. **CLI flags** (highest priority)
447
- 2. **Environment variables**
448
- 3. **Configuration file values**
449
- 4. **Tool defaults** (lowest priority)
450
-
451
- ### Configuration File Format
452
-
453
- Configuration files use INI format with organization-specific sections:
454
-
455
- ```ini
456
- [default]
457
- GERRIT_SERVER = "gerrit.example.org"
458
- PRESERVE_GITHUB_PRS = "true"
459
-
460
- [onap]
461
- ISSUE_ID = "CIMAN-33"
462
- REVIEWERS_EMAIL = "user@example.org"
463
-
464
- [opendaylight]
465
- GERRIT_HTTP_USER = "bot-user"
466
- GERRIT_HTTP_PASSWORD = "${ENV:ODL_GERRIT_TOKEN}"
467
- ```
468
-
469
- The tool loads configuration from `~/.config/github2gerrit/configuration.txt`
470
- by default, or from the path specified in the `G2G_CONFIG_PATH` environment
471
- variable.
472
-
473
- **Note**: Unknown configuration keys will generate warnings to help catch typos
474
- and missing functionality.
475
-
476
- ## Behavior details
477
-
478
- - Branch resolution
479
- - Uses `GITHUB_BASE_REF` as the target branch for Gerrit, or defaults
480
- to `master` when unset, matching the existing workflow.
481
- - Topic naming
482
- - Uses `GH-<repo>-<pr-number>` where `<repo>` replaces slashes with
483
- hyphens.
484
- - GitHub Enterprise support
485
- - Direct URL mode accepts enterprise GitHub hosts when explicitly enabled
486
- (default: off; use github.com by default). Enable via --allow-ghe-urls or
487
- ALLOW_GHE_URLS="true". The tool determines the GitHub API base URL from
488
- GITHUB_API_URL or GITHUB_SERVER_URL/api/v3.
489
- - Change‑Id handling
490
- - Single commits: the process amends each cherry‑picked commit to include a
491
- `Change-Id`. The tool collects these values for querying.
492
- - Squashed: collects trailers from original commits, preserves
493
- `Signed-off-by`, and reuses the `Change-Id` when PRs reopen or synchronize.
494
- - Reviewers
495
- - If empty, defaults to the Gerrit SSH user email.
496
- - Comments
497
- - Adds a back‑reference comment in Gerrit with the GitHub PR and run
498
- URL. Adds a comment on the GitHub PR with the Gerrit change URL(s).
499
- - Closing PRs
500
- - On `pull_request_target`, the workflow may close the PR after submission to
501
- match the shell action’s behavior.
502
-
503
- ## Security notes
504
-
505
- - Do not hardcode secrets or keys. Provide the private key via the
506
- workflow secrets and known hosts via repository or org variables.
507
- - SSH handling is non-invasive: the tool creates temporary SSH files in
508
- the workspace without modifying user SSH configuration or keys.
509
- - SSH agent scanning prevention uses `IdentitiesOnly=yes` to avoid
510
- unintended key usage (e.g., signing keys requiring biometric auth).
511
- - Temporary SSH files are automatically cleaned up after execution.
512
- - All external calls should use retries and clear error reporting.
513
-
514
- ## Development
515
-
516
- This repository follows the guidelines in `CLAUDE.md`.
517
-
518
- - Language and CLI
519
- - Python 3.11. The CLI uses Typer.
520
- - Packaging
521
- - `pyproject.toml` with setuptools backend. Use `uv` to install and run.
522
- - Structure
523
- - `src/github2gerrit/cli.py` (CLI entrypoint)
524
- - `src/github2gerrit/core.py` (orchestration)
525
- - `src/github2gerrit/gitutils.py` (subprocess and git helpers)
526
- - Linting and type checking
527
- - Ruff and MyPy use settings in `pyproject.toml`.
528
- - Run from pre‑commit hooks and CI.
529
- - Tests
530
- - Pytest with coverage targets around 80%.
531
- - Add unit and integration tests for each feature.
532
-
533
- ### Local setup
534
-
535
- - Install `uv` and run:
536
- - `uv pip install --system .`
537
- - `uv run github2gerrit --help`
538
- - Run tests:
539
- - `uv run pytest -q`
540
- - Lint and type check:
541
- - `uv run ruff check .`
542
- - `uv run black --check .`
543
- - `uv run mypy src`
544
-
545
- ### Notes on parity
546
-
547
- - Inputs, outputs, and environment usage match the shell action.
548
- - The action assumes the same GitHub variables and secrets are present.
549
- - Where the shell action uses tools such as `jq` and `gh`, the Python
550
- version uses library calls and subprocess as appropriate, with retries
551
- and clear logging.
552
-
553
- ## License
554
-
555
- Apache License 2.0. See `LICENSE` for details.
@@ -1,15 +0,0 @@
1
- github2gerrit/__init__.py,sha256=N1Vj1HJ28LKCJLAynQdm5jFGQQAz9YSMzZhEfvbBgow,886
2
- github2gerrit/cli.py,sha256=30hvpwZCs-xeWfP6TJmcluebmPVU88AUUNprd0Szt-8,34043
3
- github2gerrit/config.py,sha256=4RmAyRFs1CxeGlAjbCaVW63EqEnBt5Vag0jTTMzfKyU,16948
4
- github2gerrit/core.py,sha256=HKgSmh792sbdTV_vuNLos-eaYgj3W0F0H72N7KBV6IA,75175
5
- github2gerrit/duplicate_detection.py,sha256=J6a8t3ih-ebr6FEhWsaKnXYPQCzwcnFEWhdstmtjnMo,19475
6
- github2gerrit/github_api.py,sha256=G_VRvIzpugDeNRyw1y-KGQQ_wvDRl-L6UCqP8BRh-gU,10697
7
- github2gerrit/gitutils.py,sha256=8Q94BCLC924zIG2kcCSzxkajTpUamQ3Ul07OqzEv9ic,18664
8
- github2gerrit/models.py,sha256=DAm0pEWvAexOInnxTVrvTnKWhLMd86TfSqT78UohOCo,1791
9
- github2gerrit/ssh_discovery.py,sha256=xildpri60eQZtnXJuRxcEEb-q71h6D8QUiQvp2P9LlU,13300
10
- github2gerrit-0.1.5.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
11
- github2gerrit-0.1.5.dist-info/METADATA,sha256=5rLt8uNLd0FLcNGqNncQbM7cYm3Ns_cDECz385lqwpk,21545
12
- github2gerrit-0.1.5.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
13
- github2gerrit-0.1.5.dist-info/entry_points.txt,sha256=MxN2_liIKo3-xJwtAulAeS5GcOS6JS96nvwOQIkP3W8,56
14
- github2gerrit-0.1.5.dist-info/top_level.txt,sha256=bWTYXjvuu4sSU90KLT1JlnjD7xV_iXZ-vKoulpjLTy8,14
15
- github2gerrit-0.1.5.dist-info/RECORD,,