github2gerrit 0.1.5__tar.gz → 0.1.6__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 (70) hide show
  1. {github2gerrit-0.1.5 → github2gerrit-0.1.6}/.editorconfig +3 -3
  2. {github2gerrit-0.1.5 → github2gerrit-0.1.6}/.pre-commit-config.yaml +2 -0
  3. {github2gerrit-0.1.5 → github2gerrit-0.1.6}/.yamllint +2 -0
  4. {github2gerrit-0.1.5/src/github2gerrit.egg-info → github2gerrit-0.1.6}/PKG-INFO +22 -25
  5. {github2gerrit-0.1.5 → github2gerrit-0.1.6}/README.md +21 -24
  6. {github2gerrit-0.1.5 → github2gerrit-0.1.6}/action.yaml +19 -19
  7. {github2gerrit-0.1.5 → github2gerrit-0.1.6}/pyproject.toml +4 -5
  8. {github2gerrit-0.1.5 → github2gerrit-0.1.6}/src/github2gerrit/cli.py +86 -117
  9. {github2gerrit-0.1.5 → github2gerrit-0.1.6}/src/github2gerrit/config.py +32 -24
  10. {github2gerrit-0.1.5 → github2gerrit-0.1.6}/src/github2gerrit/core.py +425 -417
  11. github2gerrit-0.1.6/src/github2gerrit/duplicate_detection.py +724 -0
  12. github2gerrit-0.1.6/src/github2gerrit/gerrit_urls.py +256 -0
  13. {github2gerrit-0.1.5 → github2gerrit-0.1.6}/src/github2gerrit/github_api.py +6 -17
  14. {github2gerrit-0.1.5 → github2gerrit-0.1.6}/src/github2gerrit/gitutils.py +30 -13
  15. {github2gerrit-0.1.5 → github2gerrit-0.1.6}/src/github2gerrit/models.py +1 -0
  16. github2gerrit-0.1.6/src/github2gerrit/similarity.py +458 -0
  17. {github2gerrit-0.1.5 → github2gerrit-0.1.6}/src/github2gerrit/ssh_discovery.py +20 -67
  18. {github2gerrit-0.1.5 → github2gerrit-0.1.6/src/github2gerrit.egg-info}/PKG-INFO +22 -25
  19. {github2gerrit-0.1.5 → github2gerrit-0.1.6}/src/github2gerrit.egg-info/SOURCES.txt +4 -0
  20. {github2gerrit-0.1.5 → github2gerrit-0.1.6}/tests/conftest.py +3 -10
  21. {github2gerrit-0.1.5 → github2gerrit-0.1.6}/tests/fixtures/make_repo.py +15 -12
  22. {github2gerrit-0.1.5 → github2gerrit-0.1.6}/tests/test_cli.py +6 -17
  23. {github2gerrit-0.1.5 → github2gerrit-0.1.6}/tests/test_cli_helpers.py +4 -12
  24. {github2gerrit-0.1.5 → github2gerrit-0.1.6}/tests/test_cli_outputs_file.py +5 -16
  25. {github2gerrit-0.1.5 → github2gerrit-0.1.6}/tests/test_cli_url_and_dryrun.py +3 -9
  26. {github2gerrit-0.1.5 → github2gerrit-0.1.6}/tests/test_config_and_reviewers.py +1 -3
  27. {github2gerrit-0.1.5 → github2gerrit-0.1.6}/tests/test_config_helpers.py +19 -68
  28. {github2gerrit-0.1.5 → github2gerrit-0.1.6}/tests/test_core_close_pr_policy.py +7 -21
  29. {github2gerrit-0.1.5 → github2gerrit-0.1.6}/tests/test_core_config_and_errors.py +16 -48
  30. {github2gerrit-0.1.5 → github2gerrit-0.1.6}/tests/test_core_gerrit_backref_comment.py +30 -33
  31. {github2gerrit-0.1.5 → github2gerrit-0.1.6}/tests/test_core_gerrit_rest_results.py +15 -47
  32. {github2gerrit-0.1.5 → github2gerrit-0.1.6}/tests/test_core_integration_fixture_repo.py +2 -6
  33. {github2gerrit-0.1.5 → github2gerrit-0.1.6}/tests/test_core_prepare_commits.py +17 -53
  34. {github2gerrit-0.1.5 → github2gerrit-0.1.6}/tests/test_core_ssh_setup.py +20 -60
  35. {github2gerrit-0.1.5 → github2gerrit-0.1.6}/tests/test_duplicate_detection.py +75 -118
  36. github2gerrit-0.1.6/tests/test_gerrit_change_id_footer.py +154 -0
  37. github2gerrit-0.1.6/tests/test_gerrit_urls.py +336 -0
  38. {github2gerrit-0.1.5 → github2gerrit-0.1.6}/tests/test_ghe_and_gitreview_args.py +4 -14
  39. {github2gerrit-0.1.5 → github2gerrit-0.1.6}/tests/test_github_api_helpers.py +1 -4
  40. {github2gerrit-0.1.5 → github2gerrit-0.1.6}/tests/test_gitutils_helpers.py +9 -30
  41. {github2gerrit-0.1.5 → github2gerrit-0.1.6}/tests/test_ssh_discovery.py +29 -48
  42. {github2gerrit-0.1.5 → github2gerrit-0.1.6}/tests/test_url_parser.py +1 -3
  43. {github2gerrit-0.1.5 → github2gerrit-0.1.6}/uv.lock +25 -0
  44. github2gerrit-0.1.5/src/github2gerrit/duplicate_detection.py +0 -542
  45. {github2gerrit-0.1.5 → github2gerrit-0.1.6}/.github/actionlint.yaml +0 -0
  46. {github2gerrit-0.1.5 → github2gerrit-0.1.6}/.github/dependabot.yml +0 -0
  47. {github2gerrit-0.1.5 → github2gerrit-0.1.6}/.github/release-drafter.yml +0 -0
  48. {github2gerrit-0.1.5 → github2gerrit-0.1.6}/.github/workflows/build-test-release.yaml +0 -0
  49. {github2gerrit-0.1.5 → github2gerrit-0.1.6}/.github/workflows/build-test.yaml +0 -0
  50. {github2gerrit-0.1.5 → github2gerrit-0.1.6}/.github/workflows/dependencies.yaml +0 -0
  51. {github2gerrit-0.1.5 → github2gerrit-0.1.6}/.github/workflows/github2gerrit.yaml +0 -0
  52. {github2gerrit-0.1.5 → github2gerrit-0.1.6}/.github/workflows/release-drafter.yaml +0 -0
  53. {github2gerrit-0.1.5 → github2gerrit-0.1.6}/.github/workflows/semantic-pull-request.yaml +0 -0
  54. {github2gerrit-0.1.5 → github2gerrit-0.1.6}/.github/workflows/sha-pinned-actions.yaml +0 -0
  55. {github2gerrit-0.1.5 → github2gerrit-0.1.6}/.gitignore +0 -0
  56. {github2gerrit-0.1.5 → github2gerrit-0.1.6}/.gitlint +0 -0
  57. {github2gerrit-0.1.5 → github2gerrit-0.1.6}/.readthedocs.yml +0 -0
  58. {github2gerrit-0.1.5 → github2gerrit-0.1.6}/LICENSE +0 -0
  59. {github2gerrit-0.1.5 → github2gerrit-0.1.6}/LICENSES/Apache-2.0.txt +0 -0
  60. {github2gerrit-0.1.5 → github2gerrit-0.1.6}/REUSE.toml +0 -0
  61. {github2gerrit-0.1.5 → github2gerrit-0.1.6}/setup.cfg +0 -0
  62. {github2gerrit-0.1.5 → github2gerrit-0.1.6}/sitecustomize.py +0 -0
  63. {github2gerrit-0.1.5 → github2gerrit-0.1.6}/src/github2gerrit/__init__.py +0 -0
  64. {github2gerrit-0.1.5 → github2gerrit-0.1.6}/src/github2gerrit.egg-info/dependency_links.txt +0 -0
  65. {github2gerrit-0.1.5 → github2gerrit-0.1.6}/src/github2gerrit.egg-info/entry_points.txt +0 -0
  66. {github2gerrit-0.1.5 → github2gerrit-0.1.6}/src/github2gerrit.egg-info/requires.txt +0 -0
  67. {github2gerrit-0.1.5 → github2gerrit-0.1.6}/src/github2gerrit.egg-info/top_level.txt +0 -0
  68. {github2gerrit-0.1.5 → github2gerrit-0.1.6}/tests/fixtures/__init__.py +0 -0
  69. {github2gerrit-0.1.5 → github2gerrit-0.1.6}/tests/test_core_gerrit_push_errors.py +0 -0
  70. {github2gerrit-0.1.5 → github2gerrit-0.1.6}/tests/test_github_api_retry_and_helpers.py +0 -0
@@ -14,10 +14,10 @@ indent_size = 4
14
14
  indent_size = 2
15
15
 
16
16
  [*.markdown]
17
- max_line_length = 80
17
+ max_line_length = 120
18
18
 
19
19
  [*.py]
20
- max_line_legth = 120
20
+ max_line_length = 120
21
21
 
22
22
  [*.sh]
23
- max_line_length = 80
23
+ max_line_length = 120
@@ -79,6 +79,7 @@ repos:
79
79
  hooks:
80
80
  - id: write-good
81
81
  files: "\\.(rst|md|markdown|mdown|mkdn)$"
82
+ exclude: "GERRIT_URL_CENTRALIZATION.md"
82
83
 
83
84
  - repo: https://github.com/shellcheck-py/shellcheck-py
84
85
  rev: 745eface02aef23e168a8afb6b5737818efbea95 # frozen: v0.11.0.1
@@ -90,6 +91,7 @@ repos:
90
91
  hooks:
91
92
  - id: markdownlint
92
93
  args: ["--fix"]
94
+ exclude: "GERRIT_URL_CENTRALIZATION.md"
93
95
 
94
96
  - repo: https://github.com/fsfe/reuse-tool
95
97
  rev: 60dfc6b2ad9e1f3eabfbcf3a0dc202ee89dc5a00 # frozen: v5.0.2
@@ -11,3 +11,5 @@ rules:
11
11
  # prettier forces 1 space comment separator
12
12
  min-spaces-from-content: 1
13
13
  level: error
14
+ line-length:
15
+ max: 120
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: github2gerrit
3
- Version: 0.1.5
3
+ Version: 0.1.6
4
4
  Summary: Submit a GitHub pull request to a Gerrit repository.
5
5
  Author-email: Matthew Watkins <mwatkins@linuxfoundation.org>
6
6
  License-Expression: Apache-2.0
@@ -105,16 +105,25 @@ stabilize coverage reporting for parallel/xdist runs.
105
105
 
106
106
  ## Duplicate detection
107
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.
108
+ Duplicate detection uses a scoring-based approach. Instead of relying on a hash
109
+ added by this action, the detector compares the first line of the commit message
110
+ (subject/PR title), analyzes the body text and the set of files changed, and
111
+ computes a similarity score. When the score meets or exceeds a configurable
112
+ threshold (default 0.8), the tool treats the change as a duplicate and blocks
113
+ submission. This approach aims to remain robust even when similar changes
114
+ appeared outside this pipeline.
112
115
 
113
116
  ### Examples of detected duplicates
114
117
 
115
- - Identical Dependabot PRs: "Bump package from 1.0 to 1.1"
116
- - Sequential dependency updates: "Bump package 1.01.1", "Bump package 1.11.2"
117
- - Similar bug fixes with slightly different wording
118
+ - Dependency bumps for the same package across close versions
119
+ (e.g., "Bump foo from 1.0 to 1.1" vs "Bump foo from 1.1 to 1.2")
120
+ with overlapping files high score
121
+ - Pre-commit autoupdates that change .pre-commit-config.yaml and hook versions —
122
+ high score
123
+ - GitHub Actions version bumps that update .github/workflows/* uses lines —
124
+ medium to high score
125
+ - Similar bug fixes with the same subject and significant file overlap —
126
+ strong match
118
127
 
119
128
  ### Allowing duplicates
120
129
 
@@ -290,19 +299,7 @@ jobs:
290
299
  submit-to-gerrit:
291
300
  runs-on: ubuntu-latest
292
301
  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
302
+
306
303
 
307
304
  - name: Submit PR to Gerrit (with explicit overrides)
308
305
  id: g2g
@@ -336,10 +333,10 @@ jobs:
336
333
 
337
334
  Notes:
338
335
 
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.
336
+ - The action configures SSH internally using the provided inputs (key,
337
+ known_hosts) and does not use the runner’s SSH agent or ~/.ssh/config.
338
+ - Do not add external steps to install SSH keys or edit SSH config; they’re
339
+ unnecessary and may conflict with the action.
343
340
 
344
341
  ## GitHub Enterprise support
345
342
 
@@ -65,16 +65,25 @@ stabilize coverage reporting for parallel/xdist runs.
65
65
 
66
66
  ## Duplicate detection
67
67
 
68
- By default, the tool checks for duplicate changes to prevent spam
69
- submissions from automated tools like Dependabot. It compares PR titles,
70
- content, and files changed against recent PRs (last 7 days) and will
71
- exit with an error when it finds duplicates.
68
+ Duplicate detection uses a scoring-based approach. Instead of relying on a hash
69
+ added by this action, the detector compares the first line of the commit message
70
+ (subject/PR title), analyzes the body text and the set of files changed, and
71
+ computes a similarity score. When the score meets or exceeds a configurable
72
+ threshold (default 0.8), the tool treats the change as a duplicate and blocks
73
+ submission. This approach aims to remain robust even when similar changes
74
+ appeared outside this pipeline.
72
75
 
73
76
  ### Examples of detected duplicates
74
77
 
75
- - Identical Dependabot PRs: "Bump package from 1.0 to 1.1"
76
- - Sequential dependency updates: "Bump package 1.01.1", "Bump package 1.11.2"
77
- - Similar bug fixes with slightly different wording
78
+ - Dependency bumps for the same package across close versions
79
+ (e.g., "Bump foo from 1.0 to 1.1" vs "Bump foo from 1.1 to 1.2")
80
+ with overlapping files high score
81
+ - Pre-commit autoupdates that change .pre-commit-config.yaml and hook versions —
82
+ high score
83
+ - GitHub Actions version bumps that update .github/workflows/* uses lines —
84
+ medium to high score
85
+ - Similar bug fixes with the same subject and significant file overlap —
86
+ strong match
78
87
 
79
88
  ### Allowing duplicates
80
89
 
@@ -250,19 +259,7 @@ jobs:
250
259
  submit-to-gerrit:
251
260
  runs-on: ubuntu-latest
252
261
  steps:
253
- - name: Install SSH key and custom SSH config
254
- <!-- markdownlint-disable-next-line MD013 -->
255
- uses: shimataro/ssh-key-action@d4fffb50872869abe2d9a9098a6d9c5aa7d16be4 # v2.7.0
256
- with:
257
- key: ${{ secrets.GERRIT_SSH_PRIVKEY_G2G }}
258
- name: "id_rsa"
259
- known_hosts: ${{ vars.GERRIT_KNOWN_HOSTS }}
260
- config: |
261
- Host ${{ vars.GERRIT_SERVER }}
262
- User ${{ vars.GERRIT_SSH_USER_G2G }}
263
- Port ${{ vars.GERRIT_SERVER_PORT }}
264
- PubkeyAcceptedKeyTypes +ssh-rsa
265
- IdentityFile ~/.ssh/id_rsa
262
+
266
263
 
267
264
  - name: Submit PR to Gerrit (with explicit overrides)
268
265
  id: g2g
@@ -296,10 +293,10 @@ jobs:
296
293
 
297
294
  Notes:
298
295
 
299
- - If both this step and the action define SSH configuration, the last
300
- configuration applied in the runner wins.
301
- - For most users, you can rely on the action’s built-in SSH setup. Use this
302
- advanced configuration when you need custom SSH behavior or hosts.
296
+ - The action configures SSH internally using the provided inputs (key,
297
+ known_hosts) and does not use the runner’s SSH agent or ~/.ssh/config.
298
+ - Do not add external steps to install SSH keys or edit SSH config; they’re
299
+ unnecessary and may conflict with the action.
303
300
 
304
301
  ## GitHub Enterprise support
305
302
 
@@ -33,16 +33,20 @@ inputs:
33
33
  GERRIT_SSH_USER_G2G:
34
34
  description: >
35
35
  Gerrit SSH username (e.g. automation bot account). In GitHub Actions,
36
- automatically derived as [ORGANIZATION].gh2gerrit when not provided.
37
- For local CLI usage, set G2G_ENABLE_DERIVATION=true to enable derivation.
36
+ automatically derived as [ORGANIZATION].gh2gerrit when not provided if
37
+ G2G_ENABLE_DERIVATION=true (default: false). For local CLI usage,
38
+ derivation is enabled by default; set
39
+ G2G_ENABLE_DERIVATION=false to disable.
38
40
  required: false
39
41
  default: ""
40
42
  GERRIT_SSH_USER_G2G_EMAIL:
41
43
  description: >
42
44
  Email address associated to the Gerrit SSH user. In GitHub Actions,
43
45
  automatically derived as
44
- releng+[ORGANIZATION]-gh2gerrit@linuxfoundation.org when not provided.
45
- For local CLI usage, set G2G_ENABLE_DERIVATION=true to enable derivation.
46
+ releng+[ORGANIZATION]-gh2gerrit@linuxfoundation.org when not provided if
47
+ G2G_ENABLE_DERIVATION=true (default: false). For local CLI usage,
48
+ derivation is enabled by default; set
49
+ G2G_ENABLE_DERIVATION=false to disable.
46
50
  required: false
47
51
  default: ""
48
52
 
@@ -76,13 +80,21 @@ inputs:
76
80
  required: false
77
81
  default: ""
78
82
 
83
+ DUPLICATES:
84
+ description: >
85
+ Comma-separated Gerrit statuses to consider for duplicate
86
+ detection (e.g., open,merged,abandoned)
87
+ required: false
88
+ default: "open"
89
+
79
90
  # Optional Gerrit overrides (used when .gitreview is missing)
80
91
  GERRIT_SERVER:
81
92
  description: >
82
93
  Gerrit server hostname (optional; use .gitreview if present). In GitHub
83
94
  Actions, automatically derived as gerrit.[ORGANIZATION].org when not
84
- provided. For local CLI usage, set G2G_ENABLE_DERIVATION=true to enable
85
- derivation.
95
+ provided if G2G_ENABLE_DERIVATION=true (default: false). For local CLI
96
+ usage, derivation is enabled by default; set G2G_ENABLE_DERIVATION=false
97
+ to disable.
86
98
  required: false
87
99
  default: ""
88
100
  GERRIT_SERVER_PORT:
@@ -204,19 +216,6 @@ runs:
204
216
  fi
205
217
  fi
206
218
 
207
- - name: Install SSH key for Gerrit
208
- # yamllint disable-line rule:line-length
209
- uses: shimataro/ssh-key-action@d4fffb50872869abe2d9a9098a6d9c5aa7d16be4 # v2.7.0
210
- with:
211
- key: ${{ inputs.GERRIT_SSH_PRIVKEY_G2G }}
212
- name: "id_rsa"
213
- known_hosts: ${{ inputs.GERRIT_KNOWN_HOSTS }}
214
- config: |
215
- Host ${{ inputs.GERRIT_SERVER || env.GERRIT_SERVER }}
216
- User ${{ inputs.GERRIT_SSH_USER_G2G }}
217
- Port ${{ inputs.GERRIT_SERVER_PORT }}
218
- PubkeyAcceptedKeyTypes +ssh-rsa
219
- IdentityFile ~/.ssh/id_rsa
220
219
 
221
220
  - name: Run github2gerrit Python CLI
222
221
  id: run-cli
@@ -240,6 +239,7 @@ runs:
240
239
  DRY_RUN: ${{ inputs.DRY_RUN }}
241
240
  ALLOW_DUPLICATES: ${{ inputs.ALLOW_DUPLICATES }}
242
241
  ISSUE_ID: ${{ inputs.ISSUE_ID }}
242
+ DUPLICATES: ${{ inputs.DUPLICATES }}
243
243
 
244
244
  # Optional Gerrit overrides (when .gitreview is missing)
245
245
  GERRIT_SERVER: ${{ inputs.GERRIT_SERVER }}
@@ -76,7 +76,7 @@ dev = [
76
76
  ]
77
77
 
78
78
  [tool.ruff]
79
- line-length = 80
79
+ line-length = 120
80
80
  target-version = "py311"
81
81
 
82
82
  [tool.ruff.lint]
@@ -92,8 +92,9 @@ ignore = [
92
92
  ]
93
93
 
94
94
  [tool.ruff.lint.per-file-ignores]
95
- "tests/*.py" = ["S101", "S105", "PLW0603", "E501", "TRY003"]
96
- "sitecustomize.py" = ["S110", "SIM103", "SIM105", "PLW2901", "E501"]
95
+ "tests/*.py" = ["S101", "S105", "PLW0603", "TRY003"]
96
+ "sitecustomize.py" = ["S110", "SIM103", "SIM105", "PLW2901"]
97
+ "src/github2gerrit/duplicate_detection.py" = ["S310"]
97
98
 
98
99
  [tool.ruff.lint.isort]
99
100
  known-first-party = ["github2gerrit"]
@@ -124,8 +125,6 @@ exclude = [
124
125
  "tests/fixtures/",
125
126
  ]
126
127
 
127
-
128
-
129
128
  [[tool.mypy.overrides]]
130
129
  module = ["pygerrit2", "pygerrit2.*"]
131
130
  ignore_missing_imports = true