github2gerrit 0.1.9__py3-none-any.whl → 0.1.10__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.
github2gerrit/cli.py CHANGED
@@ -265,12 +265,13 @@ def main(
265
265
  envvar="CI_TESTING",
266
266
  help="Enable CI testing mode (overrides .gitreview, handles unrelated repos).",
267
267
  ),
268
- duplicates: str = typer.Option(
268
+ duplicate_types: str = typer.Option(
269
269
  "open",
270
- "--duplicates",
271
- envvar="DUPLICATES",
270
+ "--duplicate-types",
271
+ envvar="DUPLICATE_TYPES",
272
272
  help=(
273
- 'Gerrit statuses for duplicate detection (comma-separated). E.g. "open,merged,abandoned". Default: "open".'
273
+ "Gerrit change states to evaluate when determining if a change should be considered a duplicate "
274
+ '(comma-separated). E.g. "open,merged,abandoned". Default: "open".'
274
275
  ),
275
276
  ),
276
277
  normalise_commit: bool = typer.Option(
@@ -354,8 +355,8 @@ def main(
354
355
  os.environ["ISSUE_ID"] = issue_id
355
356
  os.environ["ALLOW_DUPLICATES"] = "true" if allow_duplicates else "false"
356
357
  os.environ["CI_TESTING"] = "true" if ci_testing else "false"
357
- if duplicates:
358
- os.environ["DUPLICATES"] = duplicates
358
+ if duplicate_types:
359
+ os.environ["DUPLICATE_TYPES"] = duplicate_types
359
360
  # URL mode handling
360
361
  if target_url:
361
362
  org, repo, pr = _parse_github_target(target_url)
@@ -432,7 +433,7 @@ def _build_inputs_from_env() -> Inputs:
432
433
  issue_id=env_str("ISSUE_ID", ""),
433
434
  allow_duplicates=env_bool("ALLOW_DUPLICATES", False),
434
435
  ci_testing=env_bool("CI_TESTING", False),
435
- duplicates_filter=env_str("DUPLICATES", "open"),
436
+ duplicates_filter=env_str("DUPLICATE_TYPES", "open"),
436
437
  )
437
438
 
438
439
 
@@ -476,7 +477,7 @@ def _process_bulk(data: Inputs, gh: GitHubContext) -> bool:
476
477
 
477
478
  try:
478
479
  if data.duplicates_filter:
479
- os.environ["DUPLICATES"] = data.duplicates_filter
480
+ os.environ["DUPLICATE_TYPES"] = data.duplicates_filter
480
481
  check_for_duplicates(per_ctx, allow_duplicates=data.allow_duplicates)
481
482
  except DuplicateChangeError as exc:
482
483
  log_exception_conditionally(log, "Skipping PR #%d", pr_number)
@@ -1022,7 +1023,7 @@ def _process() -> None:
1022
1023
  if gh.pr_number and not env_bool("SYNC_ALL_OPEN_PRS", False):
1023
1024
  try:
1024
1025
  if data.duplicates_filter:
1025
- os.environ["DUPLICATES"] = data.duplicates_filter
1026
+ os.environ["DUPLICATE_TYPES"] = data.duplicates_filter
1026
1027
  check_for_duplicates(gh, allow_duplicates=data.allow_duplicates)
1027
1028
  except DuplicateChangeError as exc:
1028
1029
  log_exception_conditionally(
github2gerrit/config.py CHANGED
@@ -77,6 +77,7 @@ KNOWN_KEYS: set[str] = {
77
77
  "ALLOW_GHE_URLS",
78
78
  "DRY_RUN",
79
79
  "ALLOW_DUPLICATES",
80
+ "DUPLICATE_TYPES",
80
81
  "ISSUE_ID",
81
82
  "G2G_VERBOSE",
82
83
  "G2G_SKIP_GERRIT_COMMENTS",
github2gerrit/core.py CHANGED
@@ -1417,6 +1417,7 @@ class Orchestrator:
1417
1417
  signed_lines = [ln for ln in lines_cur if ln.startswith("Signed-off-by:")]
1418
1418
  change_id_lines = [ln for ln in lines_cur if ln.startswith("Change-Id:")]
1419
1419
  github_hash_lines = [ln for ln in lines_cur if ln.startswith("GitHub-Hash:")]
1420
+ github_pr_lines = [ln for ln in lines_cur if ln.startswith("GitHub-PR:")]
1420
1421
 
1421
1422
  msg_parts = [title, "", body] if title or body else [current_body]
1422
1423
  commit_message = "\n".join(msg_parts).strip()
@@ -1446,8 +1447,19 @@ class Orchestrator:
1446
1447
  seen_so.add(ln)
1447
1448
  if change_id_lines:
1448
1449
  trailers_out.append(change_id_lines[-1])
1450
+
1451
+ # GitHub-PR trailer (must appear after Change-Id)
1452
+ if github_pr_lines:
1453
+ pr_line = github_pr_lines[-1]
1454
+ else:
1455
+ pr_line = f"GitHub-PR: {gh.server_url}/{gh.repository}/pull/{gh.pr_number}" if gh.pr_number else ""
1456
+
1449
1457
  if trailers_out:
1450
1458
  commit_message += "\n\n" + "\n".join(trailers_out)
1459
+ if pr_line:
1460
+ commit_message += "\n" + pr_line
1461
+ elif pr_line:
1462
+ commit_message += "\n\n" + pr_line
1451
1463
 
1452
1464
  author = run_cmd(
1453
1465
  ["git", "show", "-s", "--pretty=format:%an <%ae>", "HEAD"],
@@ -373,7 +373,7 @@ class DuplicateDetector:
373
373
  q_parts = []
374
374
  if gerrit_project:
375
375
  q_parts.append(f"project:{gerrit_project}")
376
- # Build status clause from DUPLICATES filter (default: open)
376
+ # Build status clause from DUPLICATE_TYPES filter (default: open)
377
377
  dup_filter = (self.duplicates_filter or "open").strip().lower()
378
378
  selected = [s.strip() for s in dup_filter.split(",") if s.strip()]
379
379
  valid = {
@@ -644,7 +644,7 @@ def check_for_duplicates(
644
644
  detector = DuplicateDetector(
645
645
  repo,
646
646
  lookback_days=lookback_days,
647
- duplicates_filter=os.getenv("DUPLICATES", "open"),
647
+ duplicates_filter=os.getenv("DUPLICATE_TYPES", "open"),
648
648
  )
649
649
  detector.check_for_duplicates(target_pr, allow_duplicates=allow_duplicates, gh=gh)
650
650
 
@@ -163,6 +163,7 @@ def remove_commit_trailers(message: str) -> str:
163
163
  - Signed-off-by: Name <email>
164
164
  - Issue-ID: ABC-123
165
165
  - GitHub-Hash: deadbeefcafebabe
166
+ - GitHub-PR: https://github.com/org/repo/pull/123
166
167
  - Co-authored-by: ...
167
168
 
168
169
  Args:
@@ -173,7 +174,7 @@ def remove_commit_trailers(message: str) -> str:
173
174
  """
174
175
  lines = (message or "").splitlines()
175
176
  out: list[str] = []
176
- trailer_re = re.compile(r"(?i)^(change-id|signed-off-by|issue-id|github-hash|co-authored-by):")
177
+ trailer_re = re.compile(r"(?i)^(change-id|signed-off-by|issue-id|github-hash|github-pr|co-authored-by):")
177
178
  for ln in lines:
178
179
  if trailer_re.match(ln.strip()):
179
180
  continue
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: github2gerrit
3
- Version: 0.1.9
3
+ Version: 0.1.10
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
@@ -140,6 +140,27 @@ with:
140
140
  When allowed, duplicates generate warnings but processing continues.
141
141
  The tool exits with code 3 when it detects duplicates and they are not allowed.
142
142
 
143
+ ### Configuring duplicate detection scope
144
+
145
+ By default, the duplicate detector considers changes with status `open` when searching for potential duplicates.
146
+ You can customize which Gerrit change states to check using `--duplicate-types` or setting `DUPLICATE_TYPES`:
147
+
148
+ ```bash
149
+ # CLI usage - check against open and merged changes
150
+ github2gerrit --duplicate-types=open,merged https://github.com/org/repo
151
+
152
+ # Environment variable
153
+ DUPLICATE_TYPES=open,merged,abandoned github2gerrit https://github.com/org/repo
154
+
155
+ # GitHub Actions
156
+ uses: onap/github2gerrit@main
157
+ with:
158
+ DUPLICATE_TYPES: 'open,merged'
159
+ ```
160
+
161
+ Valid change states include `open`, `merged`, and `abandoned`. This setting determines which existing changes
162
+ to check when evaluating whether a new change would be a duplicate.
163
+
143
164
  ## Commit Message Normalization
144
165
 
145
166
  The tool includes intelligent commit message normalization that automatically
@@ -368,6 +389,7 @@ Key options include:
368
389
  - `--use-pr-as-commit`: Use PR title/body as commit message (`USE_PR_AS_COMMIT`)
369
390
  - `--issue-id`: Add an Issue-ID trailer (e.g., "Issue-ID: ABC-123") to the commit message (`ISSUE_ID`)
370
391
  - `--preserve-github-prs`: Don't close GitHub PRs after submission (`PRESERVE_GITHUB_PRS`)
392
+ - `--duplicate-types`: Configure which Gerrit change states to check for duplicates (`DUPLICATE_TYPES`)
371
393
 
372
394
  For a complete list of all available options, see the [Inputs](#inputs) section.
373
395
 
@@ -593,7 +615,7 @@ alignment between action inputs, environment variables, and CLI flags:
593
615
  | `CI_TESTING` | `CI_TESTING` | `--ci-testing` | No | `"false"` | Enable CI testing mode (overrides .gitreview) |
594
616
  | `ISSUE_ID` | `ISSUE_ID` | `--issue-id` | No | `""` | Issue ID to include (e.g., ABC-123) |
595
617
  | `G2G_USE_SSH_AGENT` | `G2G_USE_SSH_AGENT` | N/A | No | `"true"` | Use SSH agent for authentication |
596
- | `DUPLICATES` | `DUPLICATES` | `--duplicates` | No | `"open"` | Comma-separated Gerrit statuses for duplicate detection |
618
+ | `DUPLICATE_TYPES` | `DUPLICATE_TYPES` | `--duplicate-types` | No | `"open"` | Comma-separated Gerrit change states to check for duplicate detection |
597
619
  | `GERRIT_SERVER` | `GERRIT_SERVER` | `--gerrit-server` | No² | `""` | Gerrit server hostname (auto-derived if enabled) |
598
620
  | `GERRIT_SERVER_PORT` | `GERRIT_SERVER_PORT` | `--gerrit-server-port` | No | `"29418"` | Gerrit SSH port |
599
621
  | `GERRIT_PROJECT` | `GERRIT_PROJECT` | `--gerrit-project` | No² | `""` | Gerrit project name |
@@ -1,9 +1,9 @@
1
1
  github2gerrit/__init__.py,sha256=N1Vj1HJ28LKCJLAynQdm5jFGQQAz9YSMzZhEfvbBgow,886
2
- github2gerrit/cli.py,sha256=ClwCOtMl9eecobeN6Bb1GFQ_E-kbILdxKFE89Vtvai4,45865
2
+ github2gerrit/cli.py,sha256=WlEOfomSxXOvSbN58ti2J-R4PA9_ZV6ZbyHQDC_JUQs,45980
3
3
  github2gerrit/commit_normalization.py,sha256=u4AZigz3qOpz5XYpUOq3WUqsY-o08YrkgaT160eyIIs,16594
4
- github2gerrit/config.py,sha256=uRVVcofzojTayA8AyM_3rgSFsV0fWGjixWmK48aZsRA,21471
5
- github2gerrit/core.py,sha256=Mjo_TNocFE5HDmRTxh54LEHAEw5y1u6lc1qItEZ76GA,105180
6
- github2gerrit/duplicate_detection.py,sha256=5j6EDz2P3GnnT2JkR1tGbzWCjA6TV0l5VjsEMs-tfCM,26544
4
+ github2gerrit/config.py,sha256=Jxo2q9qZZwEWc_kLYnO_hJ9ToSthYlyYxQnmN_yJRcY,21494
5
+ github2gerrit/core.py,sha256=4BDh4jm7gjDcVEIrY_3xkrMomDypdp8KYKRdkjugEGs,105660
6
+ github2gerrit/duplicate_detection.py,sha256=_CHVCaxqLoDBuk3wq2SIsekPtqRzmOwCZTQfe2ZbVgI,26554
7
7
  github2gerrit/external_api.py,sha256=EVHh__v6lRq_ojpBI_nkGZ31AQSZ9NG8tDqVUid23XY,17638
8
8
  github2gerrit/gerrit_rest.py,sha256=NmC95hb2hLpnko8Uu3OwPEKktNv-k3qrmuA7A2q-H0Y,10562
9
9
  github2gerrit/gerrit_urls.py,sha256=pw4rjIQeQ-i-vbPqsOZjZpdz7FO03pnMUMWc8L9Mcic,12893
@@ -11,14 +11,14 @@ github2gerrit/github_api.py,sha256=6S9DRt-Dza78cgxQwZ3_ujI0yPPozDGBIKnYgHan760,8
11
11
  github2gerrit/gitutils.py,sha256=3ob1K7dlKeWYYYOPXIIJ56p2N49lm1yj8XHHg2zSlhw,25929
12
12
  github2gerrit/models.py,sha256=sRS4rPMF_wjV19HMFTzhHXFMfsLFzm9TFb1JydJsSyQ,1875
13
13
  github2gerrit/pr_content_filter.py,sha256=w4MqSZ4uLX-3Da1DL_A56zVQa7xJ4h5jHMNteOOG2AE,16896
14
- github2gerrit/similarity.py,sha256=xPqdypI-Fmpeb74K4lcqZBxj17i8avS_x73dXckeicA,15268
14
+ github2gerrit/similarity.py,sha256=Gf8xDQzDDsgauhYNGueUFaQRnzt7PJ27AaLVo-Bpa7M,15332
15
15
  github2gerrit/ssh_agent_setup.py,sha256=fvKuMdF9Hv5ioaSu_alzLcjeoQLGGFRLS2wb46KdNzE,11889
16
16
  github2gerrit/ssh_common.py,sha256=f0QQmnj6yIW74N3ZjGkYmJryEstjEOmq41EIXOZdGTM,8102
17
17
  github2gerrit/ssh_discovery.py,sha256=zH0tX9VN1pn8DLM1J9QQquoKBhA9gk5drXHvMSHNNLg,13021
18
18
  github2gerrit/utils.py,sha256=ADE5YZe1h3PB3cgfxbsCuYU-Xs-1CMHrDHxfIdariFE,3369
19
- github2gerrit-0.1.9.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
20
- github2gerrit-0.1.9.dist-info/METADATA,sha256=QlTEhsWuTU9Yxim1Z__-aMr6GcGWmBzpcczbqzEyBNU,31006
21
- github2gerrit-0.1.9.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
22
- github2gerrit-0.1.9.dist-info/entry_points.txt,sha256=MxN2_liIKo3-xJwtAulAeS5GcOS6JS96nvwOQIkP3W8,56
23
- github2gerrit-0.1.9.dist-info/top_level.txt,sha256=bWTYXjvuu4sSU90KLT1JlnjD7xV_iXZ-vKoulpjLTy8,14
24
- github2gerrit-0.1.9.dist-info/RECORD,,
19
+ github2gerrit-0.1.10.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
20
+ github2gerrit-0.1.10.dist-info/METADATA,sha256=D3HNkThf9wbgtqo-K0SxaaT0DLaLW20fA2CMFFi6vn4,31914
21
+ github2gerrit-0.1.10.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
22
+ github2gerrit-0.1.10.dist-info/entry_points.txt,sha256=MxN2_liIKo3-xJwtAulAeS5GcOS6JS96nvwOQIkP3W8,56
23
+ github2gerrit-0.1.10.dist-info/top_level.txt,sha256=bWTYXjvuu4sSU90KLT1JlnjD7xV_iXZ-vKoulpjLTy8,14
24
+ github2gerrit-0.1.10.dist-info/RECORD,,