github2gerrit 1.4.4__tar.gz → 2.1.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.
Files changed (141) hide show
  1. {github2gerrit-1.4.4 → github2gerrit-2.1.0}/.pre-commit-config.yaml +8 -7
  2. {github2gerrit-1.4.4 → github2gerrit-2.1.0}/PKG-INFO +10 -4
  3. {github2gerrit-1.4.4 → github2gerrit-2.1.0}/README.md +8 -2
  4. {github2gerrit-1.4.4 → github2gerrit-2.1.0}/action.yaml +32 -19
  5. {github2gerrit-1.4.4 → github2gerrit-2.1.0}/docs/cli.md +2 -1
  6. {github2gerrit-1.4.4 → github2gerrit-2.1.0}/docs/features.md +198 -0
  7. {github2gerrit-1.4.4 → github2gerrit-2.1.0}/pyproject.toml +5 -0
  8. {github2gerrit-1.4.4 → github2gerrit-2.1.0}/src/github2gerrit/cli.py +366 -46
  9. {github2gerrit-1.4.4 → github2gerrit-2.1.0}/src/github2gerrit/config.py +41 -5
  10. {github2gerrit-1.4.4 → github2gerrit-2.1.0}/src/github2gerrit/core.py +264 -67
  11. {github2gerrit-1.4.4 → github2gerrit-2.1.0}/src/github2gerrit/duplicate_detection.py +13 -2
  12. {github2gerrit-1.4.4 → github2gerrit-2.1.0}/src/github2gerrit/github_api.py +109 -0
  13. {github2gerrit-1.4.4 → github2gerrit-2.1.0}/src/github2gerrit/gitreview.py +18 -2
  14. {github2gerrit-1.4.4 → github2gerrit-2.1.0}/src/github2gerrit/models.py +77 -5
  15. github2gerrit-2.1.0/src/github2gerrit/pr_approval.py +300 -0
  16. {github2gerrit-1.4.4 → github2gerrit-2.1.0}/src/github2gerrit/pr_commands.py +79 -15
  17. github2gerrit-2.1.0/src/github2gerrit/pr_directives.py +115 -0
  18. github2gerrit-2.1.0/src/github2gerrit/trust.py +122 -0
  19. {github2gerrit-1.4.4 → github2gerrit-2.1.0}/tests/conftest.py +29 -0
  20. {github2gerrit-1.4.4 → github2gerrit-2.1.0}/tests/test_action_environment_mapping.py +6 -0
  21. {github2gerrit-1.4.4 → github2gerrit-2.1.0}/tests/test_action_step_validation.py +131 -17
  22. {github2gerrit-1.4.4 → github2gerrit-2.1.0}/tests/test_cli_netrc_options.py +25 -10
  23. {github2gerrit-1.4.4 → github2gerrit-2.1.0}/tests/test_cli_outputs_file.py +12 -3
  24. {github2gerrit-1.4.4 → github2gerrit-2.1.0}/tests/test_cli_url_and_dryrun.py +1 -1
  25. {github2gerrit-1.4.4 → github2gerrit-2.1.0}/tests/test_composite_action_coverage.py +24 -16
  26. {github2gerrit-1.4.4 → github2gerrit-2.1.0}/tests/test_core_ssh_setup.py +6 -2
  27. github2gerrit-2.1.0/tests/test_fork_approval_gate.py +679 -0
  28. github2gerrit-2.1.0/tests/test_fork_pr_hardening.py +580 -0
  29. {github2gerrit-1.4.4 → github2gerrit-2.1.0}/tests/test_issue_157_regressions.py +19 -15
  30. github2gerrit-2.1.0/tests/test_pr_command_authorisation.py +357 -0
  31. {github2gerrit-1.4.4 → github2gerrit-2.1.0}/tests/test_pr_commands.py +13 -6
  32. {github2gerrit-1.4.4 → github2gerrit-2.1.0}/uv.lock +129 -111
  33. {github2gerrit-1.4.4 → github2gerrit-2.1.0}/.aislop/config.yml +0 -0
  34. {github2gerrit-1.4.4 → github2gerrit-2.1.0}/.editorconfig +0 -0
  35. {github2gerrit-1.4.4 → github2gerrit-2.1.0}/.gitignore +0 -0
  36. {github2gerrit-1.4.4 → github2gerrit-2.1.0}/.gitlint +0 -0
  37. {github2gerrit-1.4.4 → github2gerrit-2.1.0}/.markdownlint.yaml +0 -0
  38. {github2gerrit-1.4.4 → github2gerrit-2.1.0}/.yamllint +0 -0
  39. {github2gerrit-1.4.4 → github2gerrit-2.1.0}/LICENSE +0 -0
  40. {github2gerrit-1.4.4 → github2gerrit-2.1.0}/LICENSES/Apache-2.0.txt +0 -0
  41. {github2gerrit-1.4.4 → github2gerrit-2.1.0}/REUSE.toml +0 -0
  42. {github2gerrit-1.4.4 → github2gerrit-2.1.0}/SECURITY.md +0 -0
  43. {github2gerrit-1.4.4 → github2gerrit-2.1.0}/docs/COMMIT_RULES.md +0 -0
  44. {github2gerrit-1.4.4 → github2gerrit-2.1.0}/docs/development.md +0 -0
  45. {github2gerrit-1.4.4 → github2gerrit-2.1.0}/docs/github2gerrit_token_permissions_classic.png +0 -0
  46. {github2gerrit-1.4.4 → github2gerrit-2.1.0}/sitecustomize.py +0 -0
  47. {github2gerrit-1.4.4 → github2gerrit-2.1.0}/src/github2gerrit/__init__.py +0 -0
  48. {github2gerrit-1.4.4 → github2gerrit-2.1.0}/src/github2gerrit/commit_normalization.py +0 -0
  49. {github2gerrit-1.4.4 → github2gerrit-2.1.0}/src/github2gerrit/commit_rules.py +0 -0
  50. {github2gerrit-1.4.4 → github2gerrit-2.1.0}/src/github2gerrit/constants.py +0 -0
  51. {github2gerrit-1.4.4 → github2gerrit-2.1.0}/src/github2gerrit/error_codes.py +0 -0
  52. {github2gerrit-1.4.4 → github2gerrit-2.1.0}/src/github2gerrit/external_api.py +0 -0
  53. {github2gerrit-1.4.4 → github2gerrit-2.1.0}/src/github2gerrit/gerrit_pr_closer.py +0 -0
  54. {github2gerrit-1.4.4 → github2gerrit-2.1.0}/src/github2gerrit/gerrit_query.py +0 -0
  55. {github2gerrit-1.4.4 → github2gerrit-2.1.0}/src/github2gerrit/gerrit_rest.py +0 -0
  56. {github2gerrit-1.4.4 → github2gerrit-2.1.0}/src/github2gerrit/gerrit_ssh.py +0 -0
  57. {github2gerrit-1.4.4 → github2gerrit-2.1.0}/src/github2gerrit/gerrit_urls.py +0 -0
  58. {github2gerrit-1.4.4 → github2gerrit-2.1.0}/src/github2gerrit/gitutils.py +0 -0
  59. {github2gerrit-1.4.4 → github2gerrit-2.1.0}/src/github2gerrit/mapping_comment.py +0 -0
  60. {github2gerrit-1.4.4 → github2gerrit-2.1.0}/src/github2gerrit/netrc.py +0 -0
  61. {github2gerrit-1.4.4 → github2gerrit-2.1.0}/src/github2gerrit/orchestrator/__init__.py +0 -0
  62. {github2gerrit-1.4.4 → github2gerrit-2.1.0}/src/github2gerrit/orchestrator/reconciliation.py +0 -0
  63. {github2gerrit-1.4.4 → github2gerrit-2.1.0}/src/github2gerrit/pr_content_filter.py +0 -0
  64. {github2gerrit-1.4.4 → github2gerrit-2.1.0}/src/github2gerrit/reconcile_matcher.py +0 -0
  65. {github2gerrit-1.4.4 → github2gerrit-2.1.0}/src/github2gerrit/rich_display.py +0 -0
  66. {github2gerrit-1.4.4 → github2gerrit-2.1.0}/src/github2gerrit/rich_logging.py +0 -0
  67. {github2gerrit-1.4.4 → github2gerrit-2.1.0}/src/github2gerrit/similarity.py +0 -0
  68. {github2gerrit-1.4.4 → github2gerrit-2.1.0}/src/github2gerrit/ssh_agent_setup.py +0 -0
  69. {github2gerrit-1.4.4 → github2gerrit-2.1.0}/src/github2gerrit/ssh_common.py +0 -0
  70. {github2gerrit-1.4.4 → github2gerrit-2.1.0}/src/github2gerrit/ssh_config_parser.py +0 -0
  71. {github2gerrit-1.4.4 → github2gerrit-2.1.0}/src/github2gerrit/ssh_discovery.py +0 -0
  72. {github2gerrit-1.4.4 → github2gerrit-2.1.0}/src/github2gerrit/trailers.py +0 -0
  73. {github2gerrit-1.4.4 → github2gerrit-2.1.0}/src/github2gerrit/utils.py +0 -0
  74. {github2gerrit-1.4.4 → github2gerrit-2.1.0}/tests/fixtures/__init__.py +0 -0
  75. {github2gerrit-1.4.4 → github2gerrit-2.1.0}/tests/fixtures/make_repo.py +0 -0
  76. {github2gerrit-1.4.4 → github2gerrit-2.1.0}/tests/fixtures/ssh_config_samples.py +0 -0
  77. {github2gerrit-1.4.4 → github2gerrit-2.1.0}/tests/test_action_outputs.py +0 -0
  78. {github2gerrit-1.4.4 → github2gerrit-2.1.0}/tests/test_action_pr_number_handling.py +0 -0
  79. {github2gerrit-1.4.4 → github2gerrit-2.1.0}/tests/test_automation_only.py +0 -0
  80. {github2gerrit-1.4.4 → github2gerrit-2.1.0}/tests/test_change_id_deduplication.py +0 -0
  81. {github2gerrit-1.4.4 → github2gerrit-2.1.0}/tests/test_clean_squash_title.py +0 -0
  82. {github2gerrit-1.4.4 → github2gerrit-2.1.0}/tests/test_cli.py +0 -0
  83. {github2gerrit-1.4.4 → github2gerrit-2.1.0}/tests/test_cli_helpers.py +0 -0
  84. {github2gerrit-1.4.4 → github2gerrit-2.1.0}/tests/test_commit_normalization.py +0 -0
  85. {github2gerrit-1.4.4 → github2gerrit-2.1.0}/tests/test_commit_rules.py +0 -0
  86. {github2gerrit-1.4.4 → github2gerrit-2.1.0}/tests/test_config_and_reviewers.py +0 -0
  87. {github2gerrit-1.4.4 → github2gerrit-2.1.0}/tests/test_config_helpers.py +0 -0
  88. {github2gerrit-1.4.4 → github2gerrit-2.1.0}/tests/test_core_close_pr_policy.py +0 -0
  89. {github2gerrit-1.4.4 → github2gerrit-2.1.0}/tests/test_core_config_and_errors.py +0 -0
  90. {github2gerrit-1.4.4 → github2gerrit-2.1.0}/tests/test_core_gerrit_backref_comment.py +0 -0
  91. {github2gerrit-1.4.4 → github2gerrit-2.1.0}/tests/test_core_gerrit_push_errors.py +0 -0
  92. {github2gerrit-1.4.4 → github2gerrit-2.1.0}/tests/test_core_gerrit_rest_results.py +0 -0
  93. {github2gerrit-1.4.4 → github2gerrit-2.1.0}/tests/test_core_integration_fixture_repo.py +0 -0
  94. {github2gerrit-1.4.4 → github2gerrit-2.1.0}/tests/test_core_prepare_commits.py +0 -0
  95. {github2gerrit-1.4.4 → github2gerrit-2.1.0}/tests/test_core_shallow_clone.py +0 -0
  96. {github2gerrit-1.4.4 → github2gerrit-2.1.0}/tests/test_core_ssrf_protection.py +0 -0
  97. {github2gerrit-1.4.4 → github2gerrit-2.1.0}/tests/test_dependency_supersession.py +0 -0
  98. {github2gerrit-1.4.4 → github2gerrit-2.1.0}/tests/test_dns_validation_and_no_gerrit.py +0 -0
  99. {github2gerrit-1.4.4 → github2gerrit-2.1.0}/tests/test_duplicate_detection.py +0 -0
  100. {github2gerrit-1.4.4 → github2gerrit-2.1.0}/tests/test_email_case_normalization.py +0 -0
  101. {github2gerrit-1.4.4 → github2gerrit-2.1.0}/tests/test_error_codes.py +0 -0
  102. {github2gerrit-1.4.4 → github2gerrit-2.1.0}/tests/test_external_api_framework.py +0 -0
  103. {github2gerrit-1.4.4 → github2gerrit-2.1.0}/tests/test_final_state_reconciliation.py +0 -0
  104. {github2gerrit-1.4.4 → github2gerrit-2.1.0}/tests/test_force_flag_cli.py +0 -0
  105. {github2gerrit-1.4.4 → github2gerrit-2.1.0}/tests/test_gerrit_change_id_footer.py +0 -0
  106. {github2gerrit-1.4.4 → github2gerrit-2.1.0}/tests/test_gerrit_change_status_checks.py +0 -0
  107. {github2gerrit-1.4.4 → github2gerrit-2.1.0}/tests/test_gerrit_pr_closer.py +0 -0
  108. {github2gerrit-1.4.4 → github2gerrit-2.1.0}/tests/test_gerrit_rest_client.py +0 -0
  109. {github2gerrit-1.4.4 → github2gerrit-2.1.0}/tests/test_gerrit_ssh_abandon.py +0 -0
  110. {github2gerrit-1.4.4 → github2gerrit-2.1.0}/tests/test_gerrit_urls.py +0 -0
  111. {github2gerrit-1.4.4 → github2gerrit-2.1.0}/tests/test_gerrit_urls_more.py +0 -0
  112. {github2gerrit-1.4.4 → github2gerrit-2.1.0}/tests/test_ghe_and_gitreview_args.py +0 -0
  113. {github2gerrit-1.4.4 → github2gerrit-2.1.0}/tests/test_github_api_error_handling.py +0 -0
  114. {github2gerrit-1.4.4 → github2gerrit-2.1.0}/tests/test_github_api_helpers.py +0 -0
  115. {github2gerrit-1.4.4 → github2gerrit-2.1.0}/tests/test_github_api_retry_and_helpers.py +0 -0
  116. {github2gerrit-1.4.4 → github2gerrit-2.1.0}/tests/test_gitreview.py +0 -0
  117. {github2gerrit-1.4.4 → github2gerrit-2.1.0}/tests/test_gitutils_helpers.py +0 -0
  118. {github2gerrit-1.4.4 → github2gerrit-2.1.0}/tests/test_mapping_comment_additional.py +0 -0
  119. {github2gerrit-1.4.4 → github2gerrit-2.1.0}/tests/test_mapping_comment_digest_and_backref.py +0 -0
  120. {github2gerrit-1.4.4 → github2gerrit-2.1.0}/tests/test_metadata_and_reconciliation.py +0 -0
  121. {github2gerrit-1.4.4 → github2gerrit-2.1.0}/tests/test_metadata_trailer_separation_bug.py +0 -0
  122. {github2gerrit-1.4.4 → github2gerrit-2.1.0}/tests/test_misc_small_coverage.py +0 -0
  123. {github2gerrit-1.4.4 → github2gerrit-2.1.0}/tests/test_netrc.py +0 -0
  124. {github2gerrit-1.4.4 → github2gerrit-2.1.0}/tests/test_orphan_rest_side_effects.py +0 -0
  125. {github2gerrit-1.4.4 → github2gerrit-2.1.0}/tests/test_pr_content_filter.py +0 -0
  126. {github2gerrit-1.4.4 → github2gerrit-2.1.0}/tests/test_pr_content_filter_integration.py +0 -0
  127. {github2gerrit-1.4.4 → github2gerrit-2.1.0}/tests/test_pr_update_detection.py +0 -0
  128. {github2gerrit-1.4.4 → github2gerrit-2.1.0}/tests/test_reconciliation_extracted_module.py +0 -0
  129. {github2gerrit-1.4.4 → github2gerrit-2.1.0}/tests/test_reconciliation_plan_and_orphans.py +0 -0
  130. {github2gerrit-1.4.4 → github2gerrit-2.1.0}/tests/test_reconciliation_scenarios.py +0 -0
  131. {github2gerrit-1.4.4 → github2gerrit-2.1.0}/tests/test_ssh_agent.py +0 -0
  132. {github2gerrit-1.4.4 → github2gerrit-2.1.0}/tests/test_ssh_agent_ownership.py +0 -0
  133. {github2gerrit-1.4.4 → github2gerrit-2.1.0}/tests/test_ssh_artifact_prevention.py +0 -0
  134. {github2gerrit-1.4.4 → github2gerrit-2.1.0}/tests/test_ssh_common.py +0 -0
  135. {github2gerrit-1.4.4 → github2gerrit-2.1.0}/tests/test_ssh_discovery.py +0 -0
  136. {github2gerrit-1.4.4 → github2gerrit-2.1.0}/tests/test_ssh_discovery_dry_run.py +0 -0
  137. {github2gerrit-1.4.4 → github2gerrit-2.1.0}/tests/test_trailers_additional.py +0 -0
  138. {github2gerrit-1.4.4 → github2gerrit-2.1.0}/tests/test_url_parser.py +0 -0
  139. {github2gerrit-1.4.4 → github2gerrit-2.1.0}/tests/test_utils.py +0 -0
  140. {github2gerrit-1.4.4 → github2gerrit-2.1.0}/tests/unit/test_config_integration.py +0 -0
  141. {github2gerrit-1.4.4 → github2gerrit-2.1.0}/tests/unit/test_ssh_config_parser.py +0 -0
@@ -3,6 +3,7 @@
3
3
  # SPDX-FileCopyrightText: 2025 The Linux Foundation
4
4
 
5
5
  ci:
6
+ autofix_prs: false
6
7
  # pre-commit.ci sandbox prevents network calls; aislop runs engines
7
8
  # that can call the network at scan time, so it cannot run there
8
9
  # either. gha-workflow-linter validates action calls over the
@@ -63,7 +64,7 @@ repos:
63
64
  types: [yaml]
64
65
 
65
66
  - repo: https://github.com/astral-sh/ruff-pre-commit
66
- rev: 2700fd5671c633760d912769c041bfcde2b9a01b # frozen: v0.15.22
67
+ rev: aab412d509121cb5f7533134b7e67f9fab59c682 # frozen: v0.16.4
67
68
  hooks:
68
69
  - id: ruff
69
70
  files: ^(src|scripts|tests)/.+\.py$
@@ -72,7 +73,7 @@ repos:
72
73
  files: ^(src|scripts|tests)/.+\.py$
73
74
 
74
75
  - repo: https://github.com/pre-commit/mirrors-mypy
75
- rev: 41e691678310dfd3833f7ab4e180ddb014310356 # frozen: v2.3.0
76
+ rev: 7ff8d35ae36a7d2b968f2f90b4c723e292e594ee # frozen: v2.3.1
76
77
  hooks:
77
78
  - id: mypy
78
79
  files: ^src/.+\.py$
@@ -88,7 +89,7 @@ repos:
88
89
  args: ["--no-adverb"]
89
90
 
90
91
  - repo: https://github.com/shellcheck-py/shellcheck-py
91
- rev: 745eface02aef23e168a8afb6b5737818efbea95 # frozen: v0.11.0.1
92
+ rev: a6564f5d57444e123433a5c9af733e3975c77229 # frozen: v0.11.0.1-1
92
93
  hooks:
93
94
  - id: shellcheck
94
95
 
@@ -119,13 +120,13 @@ repos:
119
120
 
120
121
  # Requires a mirror, primary repo lacks .pre-commit-hooks.yaml
121
122
  - repo: https://github.com/DetachHead/basedpyright-prek-mirror
122
- rev: d55eabd2531b4f4a4c49c30fba627ce3a636ab79 # frozen: 1.39.9
123
+ rev: 3c94d276aa3005fa1f5a977946c9dc106135c083 # frozen: 1.39.10
123
124
  hooks:
124
125
  - id: basedpyright
125
126
  files: ^src/.+\.py$
126
127
 
127
128
  - repo: https://github.com/lfreleng-actions/gha-workflow-linter
128
- rev: cec679e88cd818179079f52925ba80b9e6cb705c # frozen: v1.2.3
129
+ rev: 42aa4db931ab4c9da0930ae5ca2259ab08da79cb # frozen: v1.5.2
129
130
  hooks:
130
131
  - id: gha-workflow-linter
131
132
 
@@ -141,12 +142,12 @@ repos:
141
142
  name: aislop
142
143
  entry: aislop ci --human
143
144
  language: node
144
- additional_dependencies: ["aislop@0.13.1"]
145
+ additional_dependencies: ["aislop@0.14.1"]
145
146
  pass_filenames: false
146
147
  always_run: true
147
148
 
148
149
  - repo: https://github.com/python-jsonschema/check-jsonschema
149
- rev: 1a4bb160cab6417b3045e1b37b6b72449243e658 # frozen: 0.37.4
150
+ rev: c4654a7e007c9619a5eb63c39a456572a0fa1851 # frozen: 0.38.0
150
151
  hooks:
151
152
  - id: check-github-actions
152
153
  - id: check-github-workflows
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.4
1
+ Metadata-Version: 2.5
2
2
  Name: github2gerrit
3
- Version: 1.4.4
3
+ Version: 2.1.0
4
4
  Summary: Submit a GitHub pull request to a Gerrit repository.
5
5
  Project-URL: Homepage, https://github.com/lfreleng-actions/github2gerrit-action
6
6
  Project-URL: Repository, https://github.com/lfreleng-actions/github2gerrit-action
@@ -139,6 +139,9 @@ name: github2gerrit
139
139
  on:
140
140
  pull_request_target:
141
141
  types: [opened, reopened, edited, synchronize, closed]
142
+ # Re-runs when a maintainer approves a fork pull request
143
+ pull_request_review:
144
+ types: [submitted, dismissed]
142
145
  push:
143
146
  branches: [main, master]
144
147
  workflow_dispatch:
@@ -186,6 +189,9 @@ name: github2gerrit
186
189
  on:
187
190
  pull_request_target:
188
191
  types: [opened, reopened, edited, synchronize, closed]
192
+ # Re-runs when a maintainer approves a fork pull request
193
+ pull_request_review:
194
+ types: [submitted, dismissed]
189
195
  workflow_dispatch:
190
196
 
191
197
  permissions:
@@ -235,7 +241,7 @@ uvx github2gerrit https://github.com/onap/portal-ng-bff/pull/33
235
241
  | `GERRIT_HTTP_PASSWORD` | No | `""` | Gerrit HTTP password/token for REST queries |
236
242
  | `ORGANIZATION` | No | repository owner | GitHub organization/owner used for credential derivation |
237
243
  | `PR_NUMBER` | No | `"0"` | PR number to process; `0` processes all open PRs (dispatch) |
238
- | `FETCH_DEPTH` | No | `"10"` | Fetch depth for checkout |
244
+ | `FETCH_DEPTH` | No | `"10"` | Git history depth: PR fetch, push checkout, reconciliation |
239
245
  | `SUBMIT_SINGLE_COMMITS` | No | `"false"` | Submit one commit at a time to Gerrit |
240
246
  | `USE_PR_AS_COMMIT` | No | `"false"` | Use PR title and body as the commit message |
241
247
  | `PRESERVE_GITHUB_PRS` | No | `"true"` | Do not close GitHub PRs after pushing to Gerrit |
@@ -312,7 +318,7 @@ Input defaults match the composite action defaults.
312
318
  | `G2G_USE_SSH_AGENT` | boolean | `true` | Use SSH agent instead of file-based keys |
313
319
  | `ORGANIZATION` | string | repository owner | GitHub organization/owner |
314
320
  | `PR_NUMBER` | string | `"0"` | PR to process on dispatch; `0` processes all |
315
- | `FETCH_DEPTH` | string | `"10"` | Fetch depth for checkout |
321
+ | `FETCH_DEPTH` | string | `"10"` | Git depth: PR, push, reconciliation |
316
322
  | `SUBMIT_SINGLE_COMMITS` | boolean | `false` | Submit one commit at a time |
317
323
  | `USE_PR_AS_COMMIT` | boolean | `false` | Use PR title and body as the commit message |
318
324
  | `PRESERVE_GITHUB_PRS` | boolean | `true` | Do not close GitHub PRs after pushing |
@@ -93,6 +93,9 @@ name: github2gerrit
93
93
  on:
94
94
  pull_request_target:
95
95
  types: [opened, reopened, edited, synchronize, closed]
96
+ # Re-runs when a maintainer approves a fork pull request
97
+ pull_request_review:
98
+ types: [submitted, dismissed]
96
99
  push:
97
100
  branches: [main, master]
98
101
  workflow_dispatch:
@@ -140,6 +143,9 @@ name: github2gerrit
140
143
  on:
141
144
  pull_request_target:
142
145
  types: [opened, reopened, edited, synchronize, closed]
146
+ # Re-runs when a maintainer approves a fork pull request
147
+ pull_request_review:
148
+ types: [submitted, dismissed]
143
149
  workflow_dispatch:
144
150
 
145
151
  permissions:
@@ -189,7 +195,7 @@ uvx github2gerrit https://github.com/onap/portal-ng-bff/pull/33
189
195
  | `GERRIT_HTTP_PASSWORD` | No | `""` | Gerrit HTTP password/token for REST queries |
190
196
  | `ORGANIZATION` | No | repository owner | GitHub organization/owner used for credential derivation |
191
197
  | `PR_NUMBER` | No | `"0"` | PR number to process; `0` processes all open PRs (dispatch) |
192
- | `FETCH_DEPTH` | No | `"10"` | Fetch depth for checkout |
198
+ | `FETCH_DEPTH` | No | `"10"` | Git history depth: PR fetch, push checkout, reconciliation |
193
199
  | `SUBMIT_SINGLE_COMMITS` | No | `"false"` | Submit one commit at a time to Gerrit |
194
200
  | `USE_PR_AS_COMMIT` | No | `"false"` | Use PR title and body as the commit message |
195
201
  | `PRESERVE_GITHUB_PRS` | No | `"true"` | Do not close GitHub PRs after pushing to Gerrit |
@@ -266,7 +272,7 @@ Input defaults match the composite action defaults.
266
272
  | `G2G_USE_SSH_AGENT` | boolean | `true` | Use SSH agent instead of file-based keys |
267
273
  | `ORGANIZATION` | string | repository owner | GitHub organization/owner |
268
274
  | `PR_NUMBER` | string | `"0"` | PR to process on dispatch; `0` processes all |
269
- | `FETCH_DEPTH` | string | `"10"` | Fetch depth for checkout |
275
+ | `FETCH_DEPTH` | string | `"10"` | Git depth: PR, push, reconciliation |
270
276
  | `SUBMIT_SINGLE_COMMITS` | boolean | `false` | Submit one commit at a time |
271
277
  | `USE_PR_AS_COMMIT` | boolean | `false` | Use PR title and body as the commit message |
272
278
  | `PRESERVE_GITHUB_PRS` | boolean | `true` | Do not close GitHub PRs after pushing |
@@ -19,18 +19,13 @@ inputs:
19
19
  required: false
20
20
  default: "false"
21
21
  FETCH_DEPTH:
22
- description: "Fetch depth for checkout"
23
- required: false
24
- default: "10"
25
- SKIP_CHECKOUT:
26
22
  description: >-
27
- Skip the internal repository checkout. Set when the caller has
28
- already checked out the target repository at the desired ref
29
- (e.g. the bundled reusable workflow, which also checks out this
30
- action into the workspace and must not have it deleted by a
31
- nested checkout)
23
+ Depth of git history fetched. Applied to the tool's own fetch of
24
+ refs/pull/<N>/head, to the push-event checkout, and as the git log
25
+ window used to find merged commits during PR reconciliation, so
26
+ raising it widens how far back a merged change is matched
32
27
  required: false
33
- default: "false"
28
+ default: "10"
34
29
  PR_NUMBER:
35
30
  description: "Pull request number to process, use 0 to process all open"
36
31
  required: false
@@ -213,19 +208,32 @@ runs:
213
208
  echo "disabled=false" >> "$GITHUB_OUTPUT"
214
209
  fi
215
210
 
216
- - name: "Checkout repository"
217
- # yamllint disable-line rule:line-length
218
- if: steps.disabled-check.outputs.disabled != 'true' && inputs.SKIP_CHECKOUT != 'true'
211
+ - name: "Checkout repository (push events)"
212
+ # Push runs reconcile merged Gerrit changes back to their GitHub
213
+ # PRs, which reads commit trailers with a local `git show` in the
214
+ # working directory. Pull request runs need no checkout: the tool
215
+ # fetches refs/pull/<N>/head into its own temporary directory, and
216
+ # checking a fork head out here would both fail under
217
+ # pull_request_target and expose a fork-controlled .gitreview.
218
+ if: >-
219
+ steps.disabled-check.outputs.disabled != 'true'
220
+ && github.event_name == 'push'
219
221
  # yamllint disable-line rule:line-length
220
222
  uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
221
223
  with:
222
224
  fetch-depth: ${{ inputs.FETCH_DEPTH }}
223
- # Ensure we are on the PR's head SHA when triggered by PR events
224
- ref: ${{ github.event.pull_request.head.sha || github.sha }}
225
- # The action authenticates to Gerrit over SSH and to GitHub via an
226
- # explicit GITHUB_TOKEN env var, so the checkout token does not need
227
- # to be persisted into the local git config.
225
+ # The action authenticates to Gerrit over SSH and to GitHub via
226
+ # an explicit GITHUB_TOKEN env var, so the checkout token does
227
+ # not need to be persisted into the local git config.
228
228
  persist-credentials: false
229
+ # Callers may place files in the workspace that this action
230
+ # depends on. The bundled reusable workflow checks the action
231
+ # itself out to .g2g-action and then runs it from there, so a
232
+ # cleaning checkout would delete the action mid-run. That
233
+ # workflow also seeds the workspace root with the target
234
+ # repository first, because actions/checkout wipes a directory
235
+ # that is not already a git repository whatever `clean` says.
236
+ clean: false
229
237
 
230
238
  - name: "Setup Python"
231
239
  if: steps.disabled-check.outputs.disabled != 'true'
@@ -237,7 +245,7 @@ runs:
237
245
  - name: "Setup uv"
238
246
  if: steps.disabled-check.outputs.disabled != 'true'
239
247
  # yamllint disable-line rule:line-length
240
- uses: astral-sh/setup-uv@11f9893b081a58869d3b5fccaea48c9e9e46f990 # v8.3.2
248
+ uses: astral-sh/setup-uv@20cfd1bf945f4377ade1205e4dbc17946fc9a30d # v10.0.1
241
249
  with:
242
250
  enable-cache: false
243
251
 
@@ -396,6 +404,11 @@ runs:
396
404
  GITHUB_SHA: ${{ github.sha }}
397
405
  GITHUB_BASE_REF: ${{ github.base_ref }}
398
406
  GITHUB_HEAD_REF: ${{ github.head_ref }}
407
+ # Full owner/repo of the PR head. Differs from GITHUB_REPOSITORY
408
+ # for fork pull requests, whose tree must not influence Gerrit
409
+ # target resolution.
410
+ # yamllint disable-line rule:line-length
411
+ PR_HEAD_REPO: ${{ github.event.pull_request.head.repo.full_name }}
399
412
  GITHUB_ACTOR: ${{ github.actor }}
400
413
  SYNC_ALL_OPEN_PRS: ${{ steps.extract.outputs.sync_all }}
401
414
  PR_NUMBER: ${{ steps.extract.outputs.pr_number }}
@@ -84,7 +84,7 @@ set by GitHub Actions) and undergo proper boolean parsing.
84
84
  | `--preserve-github-prs/--no-preserve-github-prs` | `PRESERVE_GITHUB_PRS` | `true` | Do not close GitHub PRs after pushing to Gerrit |
85
85
  | `--close-merged-prs/--no-close-merged-prs` | `CLOSE_MERGED_PRS` | `true` | Close GitHub PRs when corresponding Gerrit changes merge |
86
86
  | `--force` | `FORCE` | `false` | Force PR closure regardless of Gerrit change status (abandoned, etc.) |
87
- | `--fetch-depth INTEGER` | `FETCH_DEPTH` | `10` | Fetch depth for checkout |
87
+ | `--fetch-depth INTEGER` | `FETCH_DEPTH` | `10` | Git history depth: PR fetch, push checkout, reconciliation window |
88
88
  | `--reviewers-email TEXT` | `REVIEWERS_EMAIL` | `""` | Email address(es) of reviewers (comma-separated) |
89
89
  | `--organization TEXT` | `ORGANIZATION` | unset | Organization (defaults to `GITHUB_REPOSITORY_OWNER` when unset) |
90
90
  | `--github-actor TEXT` | `GITHUB_ACTOR` | `""` | GitHub actor (username) who triggered the workflow |
@@ -165,6 +165,7 @@ Some settings have no CLI flag and use environment variables:
165
165
  | `G2G_LOG_LEVEL` | `WARNING` | Logging level; set `DEBUG` for verbose output |
166
166
  | `G2G_TOPIC_PREFIX` | `GH` | Prefix used when generating Gerrit topics |
167
167
  | `G2G_SKIP_GERRIT_COMMENTS` | `false` | Skip posting back-reference comments on Gerrit changes |
168
+ | `G2G_TRUSTED_ASSOCIATIONS` | `OWNER,MEMBER,COLLABORATOR` | Author associations trusted to issue `@github2gerrit` comment directives |
168
169
  | `G2G_ENABLE_DERIVATION` | `true` | Enable automatic derivation of Gerrit parameters from organization defaults |
169
170
  | `G2G_AUTO_SAVE_CONFIG` | context-dependent | Save derived parameters back to the configuration file |
170
171
  | `G2G_RESPECT_USER_SSH` | `false` (`true` in direct URL mode) | Use the local user's SSH configuration and keys instead of provided key material |
@@ -16,6 +16,7 @@ action in detail. For a quick start and the full inputs table, see the
16
16
  - [Closing Merged PRs](#closing-merged-prs)
17
17
  - [Automatic Cleanup](#automatic-cleanup)
18
18
  - [Restricting PRs to Automation Tools](#restricting-prs-to-automation-tools)
19
+ - [Fork Pull Requests](#fork-pull-requests)
19
20
  - [Duplicate Detection](#duplicate-detection)
20
21
  - [Commit Message Normalization](#commit-message-normalization)
21
22
  - [Change-ID Reconciliation](#change-id-reconciliation)
@@ -101,6 +102,57 @@ acts on it during the next workflow run.
101
102
  - When the same command appears in more than one comment, only the latest
102
103
  occurrence takes effect.
103
104
  - The tool logs unrecognized directives at debug level and ignores them.
105
+ - Only comments from trusted authors count. See below.
106
+
107
+ ### Who May Issue Commands
108
+
109
+ These repositories are public, so the tool checks who wrote a comment before
110
+ acting on it. Without that check, any GitHub user able to leave a comment
111
+ could direct the tool.
112
+
113
+ A comment counts only when GitHub reports its author's `author_association`
114
+ as one of:
115
+
116
+ | Association | Meaning |
117
+ | -------------- | ------------------------------------------ |
118
+ | `OWNER` | Owns the repository |
119
+ | `MEMBER` | Member of the owning organization |
120
+ | `COLLABORATOR` | Invited collaborator on the repository |
121
+
122
+ `CONTRIBUTOR` is **not** trusted. It means only that the author has had a
123
+ pull request merged at some point, which any outside contributor can achieve
124
+ and which carries no authority.
125
+
126
+ The tool ignores directives from anyone else and logs a warning naming the
127
+ author and their association, so a refused command is visible rather than
128
+ silently dropped.
129
+
130
+ #### For contributors adding commands
131
+
132
+ Adding a `CommandDefinition` to the registry gives the new command the same
133
+ authorisation as the existing one, so long as consumers reach it through
134
+ `github2gerrit.pr_directives`, which fetches comments, discards untrusted
135
+ authors and parses in a single step.
136
+
137
+ The parsing module performs no authorisation of its own. Calling
138
+ `parse_commands`, `find_command` or `has_command` with comments taken straight
139
+ from the GitHub API skips the check and recreates the original defect.
140
+
141
+ Override the trusted set with `G2G_TRUSTED_ASSOCIATIONS`, a comma-separated
142
+ list. Setting it to `OWNER` alone is the strictest useful value:
143
+
144
+ ```yaml
145
+ env:
146
+ G2G_TRUSTED_ASSOCIATIONS: "OWNER,MEMBER"
147
+ ```
148
+
149
+ An empty or blank value keeps the default rather than trusting nobody or
150
+ everyone.
151
+
152
+ Note that `MEMBER` means organization member, which is not the same as write
153
+ access to a given repository. On a Gerrit mirror that remains the only
154
+ available signal, because the GitHub collaborator list holds infrastructure
155
+ accounts rather than the project's reviewers.
104
156
 
105
157
  ### Available Commands
106
158
 
@@ -284,6 +336,152 @@ Set `AUTOMATION_ONLY: "false"` to accept PRs from all users:
284
336
  GERRIT_SSH_PRIVKEY_G2G: ${{ secrets.GERRIT_SSH_PRIVKEY_G2G }}
285
337
  ```
286
338
 
339
+ ## Fork Pull Requests
340
+
341
+ A pull request raised from a fork carries a tree that someone without write
342
+ access to the base repository wrote. The tool treats that tree as untrusted
343
+ input.
344
+
345
+ ### No runner checkout for pull requests
346
+
347
+ The action does not check the target repository out into the runner workspace
348
+ for pull request events. It fetches `refs/pull/<N>/head` into a private
349
+ temporary directory instead. That ref lives on the base repository and resolves
350
+ fork pull request heads, so the tool never contacts the fork directly.
351
+
352
+ This sidesteps the `pull_request_target` checkout restriction that
353
+ `actions/checkout` enforces, and keeps fork content out of the working
354
+ directory, where the tool might otherwise read it as configuration.
355
+
356
+ Push events still check the repository out. Those runs reconcile merged Gerrit
357
+ changes back to their GitHub pull requests, which reads commit trailers from
358
+ the working directory. A push carries no fork content, so the checkout is safe
359
+ there.
360
+
361
+ ### Gerrit target resolution
362
+
363
+ For fork pull requests the tool ignores any `.gitreview` in the pull request
364
+ tree and resolves against the **base repository** instead. A fork could
365
+ otherwise redirect the push to a different Gerrit project simply by editing
366
+ `.gitreview`.
367
+
368
+ The tool applies the same treatment when it cannot establish where the pull
369
+ request head lives. Specific-PR `workflow_dispatch` runs and direct URL
370
+ invocations carry no pull request payload, and GitHub reports a null head
371
+ repository for a deleted fork. The tool resolves provenance through the API
372
+ where it can, and treats whatever remains unresolved as untrusted, so a missing
373
+ signal never earns a fork unwarranted trust.
374
+
375
+ Resolution order for a fork pull request:
376
+
377
+ 1. `.gitreview` from the base repository at the pull request's base branch,
378
+ via the GitHub API or `raw.githubusercontent.com`
379
+ 2. Explicit `GERRIT_SERVER` / `GERRIT_SERVER_PORT` / `GERRIT_PROJECT` inputs
380
+ 3. Per-organization configuration file
381
+ 4. Derivation from the organization name (`gerrit.[org].org`)
382
+
383
+ The lookup stops at the base branch. It does not fall back to the repository
384
+ default branch, and it does not read `.gitreview` through the API without an
385
+ authoritative base ref, because either would answer for a branch the pull
386
+ request does not target — and `.gitreview` outranks the explicit inputs.
387
+
388
+ The base repository's copy carries the same authority and lies outside an
389
+ attacker's reach, so this costs no accuracy. Skipping straight to derivation
390
+ would instead guess the Gerrit project name, and that guess goes wrong for
391
+ repositories whose name contains a hyphen that does not mark a path separator.
392
+
393
+ For the same reason, the tool drops branch names that originate in the fork
394
+ (`GITHUB_HEAD_REF` and the pull request head ref) from base-repository
395
+ lookups. Duplicate detection, which resolves `.gitreview` independently and
396
+ earlier, applies the same rule.
397
+
398
+ Same-repository pull requests keep their previous behaviour and still read
399
+ `.gitreview` from the pull request tree.
400
+
401
+ ### Approval gating
402
+
403
+ A fork pull request does not transfer to Gerrit until a maintainer approves it.
404
+ The check runs before the tool fetches anything from the pull request and before
405
+ it unlocks the Gerrit SSH key, so a pull request awaiting review reaches
406
+ neither.
407
+
408
+ Same-repository pull requests skip the check entirely. Pushing a branch to the
409
+ base repository already requires write access, and automation such as
410
+ Dependabot, pre-commit.ci and Copilot works that way, so the gate never affects
411
+ them.
412
+
413
+ #### What counts as approval
414
+
415
+ An approving review, where every one of the following holds:
416
+
417
+ - the reviewer's `author_association` falls in the trusted set, the same one
418
+ used for [comment commands](#who-may-issue-commands);
419
+ - the review targets the pull request's **current head commit**;
420
+ - no trusted reviewer has since requested changes; and
421
+ - the reviewer is not the pull request author.
422
+
423
+ A pull request whose provenance the tool cannot establish takes the same path as
424
+ a fork. Approval is a question about authority, and an absent signal is not an
425
+ answer.
426
+
427
+ The gate applies to unattended runs. Running the CLI directly against a pull
428
+ request URL does not require an approval: the operator chose that pull request
429
+ and is using their own credentials, so they are already the authority the gate
430
+ looks for. It exists for the automated path, where the tool acts on a shared
431
+ identity with nobody watching.
432
+
433
+ Binding to the head commit matters. GitHub keeps approvals across pushes unless
434
+ branch protection dismisses them, so an approval that was not checked against a
435
+ commit would let a contributor gain approval for one revision and then push a
436
+ different one. The cost is that maintainers re-approve after each push, which is
437
+ the correct trade.
438
+
439
+ The author exclusion is belt and braces. GitHub already rejects approving your
440
+ own pull request, and that guarantee is a large part of why the tool uses
441
+ reviews rather than comment directives — on a Gerrit mirror the pull request
442
+ author often holds the same organization membership as the reviewers.
443
+
444
+ #### Enabling re-runs on approval
445
+
446
+ `pull_request_target` carries no event for a submitted review, so approving a
447
+ pull request does nothing unless the calling workflow listens for it:
448
+
449
+ ```yaml
450
+ on:
451
+ pull_request_target:
452
+ types: [opened, reopened, edited, synchronize, closed]
453
+ pull_request_review:
454
+ types: [submitted, dismissed]
455
+ ```
456
+
457
+ Without that trigger the tool only reconsiders a pull request on its next
458
+ push, or when a maintainer dispatches the workflow by hand.
459
+
460
+ #### When the gate blocks
461
+
462
+ The run finishes successfully rather than failing. A pull request waiting for a
463
+ human is not broken, and a red check would suggest otherwise.
464
+
465
+ The tool posts one comment explaining what is missing, and edits that same
466
+ comment on later runs rather than adding another. Where an approval exists but
467
+ covers an earlier commit, the comment says so, so a maintainer who did approve
468
+ is not told that nobody has.
469
+
470
+ Once approval arrives, the tool edits that comment again to record it, so a
471
+ transferred pull request does not keep displaying a stale block.
472
+
473
+ #### If the head moves mid-run
474
+
475
+ The gate reads the head commit from the API, while the workspace fetch reads
476
+ `refs/pull/<N>/head`, which the contributor can move meanwhile. The tool
477
+ compares the commit it fetched against the commit the maintainer approved and
478
+ refuses a mismatch, so a push timed against a running workflow cannot slip an
479
+ unreviewed commit into Gerrit.
480
+
481
+ That refusal fails the run, unlike the ordinary blocked case, because it falls
482
+ outside the normal course of events. The push that caused it triggers a fresh
483
+ run, which asks for approval of the new commit in the usual way.
484
+
287
485
  ## Duplicate Detection
288
486
 
289
487
  Duplicate detection uses a scoring-based approach. The detector compares the
@@ -139,6 +139,11 @@ ignore = [
139
139
  "sitecustomize.py" = ["S110", "SIM103", "SIM105", "PLW2901"]
140
140
  "src/github2gerrit/duplicate_detection.py" = ["S310"]
141
141
  "src/github2gerrit/gerrit_rest.py" = ["S310", "TRY301"]
142
+ # S310 audits urlopen for non-HTTP schemes such as file:. This module
143
+ # builds the URL from a literal https://raw.githubusercontent.com/ prefix
144
+ # and passes it through _validate_raw_url, which requires scheme https and
145
+ # host raw.githubusercontent.com before the fetch runs.
146
+ "src/github2gerrit/gitreview.py" = ["S310"]
142
147
 
143
148
  [tool.ruff.lint.isort]
144
149
  known-first-party = ["github2gerrit"]