github2gerrit 0.1.3__py3-none-any.whl → 0.1.4__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
@@ -31,6 +31,16 @@ from .models import GitHubContext
31
31
  from .models import Inputs
32
32
 
33
33
 
34
+ class ConfigurationError(Exception):
35
+ """Raised when configuration validation fails.
36
+
37
+ This custom exception is used instead of typer.BadParameter to provide
38
+ cleaner error messages to end users without exposing Python tracebacks.
39
+ When caught, it displays user-friendly messages prefixed with
40
+ "Configuration validation failed:" rather than raw exception details.
41
+ """
42
+
43
+
34
44
  def _parse_github_target(url: str) -> tuple[str | None, str | None, int | None]:
35
45
  """
36
46
  Parse a GitHub repository or pull request URL.
@@ -402,7 +412,7 @@ def _process_bulk(data: Inputs, gh: GitHubContext) -> None:
402
412
  if result_multi.change_urls:
403
413
  all_urls.extend(result_multi.change_urls)
404
414
  for url in result_multi.change_urls:
405
- typer.echo(f"Gerrit change URL: {url}")
415
+ log.info("Gerrit change URL: %s", url)
406
416
  log.info(
407
417
  "PR #%d created Gerrit change: %s",
408
418
  pr_number,
@@ -452,8 +462,10 @@ def _process_single(data: Inputs, gh: GitHubContext) -> None:
452
462
  log.debug("Local checkout preparation failed: %s", exc)
453
463
 
454
464
  orch = Orchestrator(workspace=workspace)
465
+ pipeline_success = False
455
466
  try:
456
467
  result = orch.execute(inputs=data, gh=gh)
468
+ pipeline_success = True
457
469
  except Exception as exc:
458
470
  log.debug("Execution failed; continuing to write outputs: %s", exc)
459
471
 
@@ -466,7 +478,7 @@ def _process_single(data: Inputs, gh: GitHubContext) -> None:
466
478
  )
467
479
  # Output Gerrit change URL(s) to console
468
480
  for url in result.change_urls:
469
- typer.echo(f"Gerrit change URL: {url}")
481
+ log.info("Gerrit change URL: %s", url)
470
482
  if result.change_numbers:
471
483
  os.environ["GERRIT_CHANGE_REQUEST_NUM"] = "\n".join(
472
484
  result.change_numbers
@@ -485,7 +497,10 @@ def _process_single(data: Inputs, gh: GitHubContext) -> None:
485
497
  }
486
498
  )
487
499
 
488
- log.info("Submission pipeline complete.")
500
+ if pipeline_success:
501
+ log.info("Submission pipeline completed SUCCESSFULLY ✅")
502
+ else:
503
+ log.error("Submission pipeline FAILED ❌")
489
504
  return
490
505
 
491
506
 
@@ -661,9 +676,9 @@ def _process() -> None:
661
676
  # Validate inputs
662
677
  try:
663
678
  _validate_inputs(data)
664
- except typer.BadParameter as exc:
665
- log.exception("Validation failed")
666
- typer.echo(str(exc), err=True)
679
+ except ConfigurationError as exc:
680
+ log.exception("Configuration validation failed")
681
+ typer.echo(f"Configuration validation failed: {exc}", err=True)
667
682
  raise typer.Exit(code=2) from exc
668
683
 
669
684
  gh = _read_github_context()
@@ -803,7 +818,7 @@ def _validate_inputs(data: Inputs) -> None:
803
818
  "USE_PR_AS_COMMIT and SUBMIT_SINGLE_COMMITS cannot be enabled at "
804
819
  "the same time"
805
820
  )
806
- raise typer.BadParameter(msg)
821
+ raise ConfigurationError(msg)
807
822
 
808
823
  # Presence checks for required fields used by existing action
809
824
  for field_name in (
@@ -814,16 +829,16 @@ def _validate_inputs(data: Inputs) -> None:
814
829
  ):
815
830
  if not getattr(data, field_name):
816
831
  log.error("Missing required input: %s", field_name)
817
- raise typer.BadParameter(f"Missing required input: {field_name}") # noqa: TRY003
832
+ raise ConfigurationError(f"Missing required input: {field_name}") # noqa: TRY003
818
833
 
819
834
  # Validate fetch depth is a positive integer
820
835
  if data.fetch_depth <= 0:
821
836
  log.error("Invalid FETCH_DEPTH: %s", data.fetch_depth)
822
- raise typer.BadParameter("FETCH_DEPTH must be a positive integer") # noqa: TRY003
837
+ raise ConfigurationError("FETCH_DEPTH must be a positive integer") # noqa: TRY003
823
838
 
824
839
  # Validate Issue ID is a single line string if provided
825
840
  if data.issue_id and ("\n" in data.issue_id or "\r" in data.issue_id):
826
- raise typer.BadParameter("Issue ID must be single line") # noqa: TRY003
841
+ raise ConfigurationError("Issue ID must be single line") # noqa: TRY003
827
842
 
828
843
 
829
844
  def _log_effective_config(data: Inputs, gh: GitHubContext) -> None:
github2gerrit/config.py CHANGED
@@ -58,8 +58,8 @@ log = logging.getLogger("github2gerrit.config")
58
58
 
59
59
  DEFAULT_CONFIG_PATH = "~/.config/github2gerrit/configuration.txt"
60
60
 
61
- # Recognized keys. Unknown keys are still passed through, but these are
62
- # the most relevant to current tooling and action inputs/options.
61
+ # Recognized keys. Unknown keys will be reported as warnings to help
62
+ # users catch typos and missing functionality.
63
63
  KNOWN_KEYS: set[str] = {
64
64
  # Action inputs
65
65
  "SUBMIT_SINGLE_COMMITS",
@@ -74,6 +74,13 @@ KNOWN_KEYS: set[str] = {
74
74
  "PR_NUMBER",
75
75
  "SYNC_ALL_OPEN_PRS",
76
76
  "PRESERVE_GITHUB_PRS",
77
+ "ALLOW_GHE_URLS",
78
+ "DRY_RUN",
79
+ "ALLOW_DUPLICATES",
80
+ "ISSUE_ID",
81
+ "G2G_VERBOSE",
82
+ "G2G_SKIP_GERRIT_COMMENTS",
83
+ "GITHUB_TOKEN",
77
84
  # Optional inputs (reusable workflow compatibility)
78
85
  "GERRIT_SERVER",
79
86
  "GERRIT_SERVER_PORT",
@@ -264,6 +271,17 @@ def load_org_config(
264
271
  )
265
272
 
266
273
  normalized = _normalize_keys(result)
274
+
275
+ # Report unknown configuration keys to help users catch typos
276
+ unknown_keys = set(normalized.keys()) - KNOWN_KEYS
277
+ if unknown_keys:
278
+ log.warning(
279
+ "Unknown configuration keys found in [%s]: %s. "
280
+ "These will be ignored. Check for typos or missing functionality.",
281
+ effective_org or "default",
282
+ ", ".join(sorted(unknown_keys)),
283
+ )
284
+
267
285
  return normalized
268
286
 
269
287
 
github2gerrit/core.py CHANGED
@@ -89,8 +89,11 @@ def _insert_issue_id_into_commit_message(message: str, issue_id: str) -> str:
89
89
  if "\n" in cleaned_issue_id or "\r" in cleaned_issue_id:
90
90
  raise ValueError("Issue ID must be single line") # noqa: TRY003
91
91
 
92
- # Use the cleaned issue ID for insertion
93
- issue_line = cleaned_issue_id
92
+ # Format as proper Issue-ID trailer
93
+ if cleaned_issue_id.startswith("Issue-ID:"):
94
+ issue_line = cleaned_issue_id
95
+ else:
96
+ issue_line = f"Issue-ID: {cleaned_issue_id}"
94
97
 
95
98
  lines = message.splitlines()
96
99
  if not lines:
@@ -1081,6 +1084,7 @@ class Orchestrator:
1081
1084
  repo.project_gerrit,
1082
1085
  branch,
1083
1086
  )
1087
+ log.debug("Starting git review push operation...")
1084
1088
  if single_commits:
1085
1089
  tmp_branch = os.getenv("G2G_TMP_BRANCH", "tmp_branch")
1086
1090
  run_cmd(["git", "checkout", tmp_branch], cwd=self.workspace)
@@ -1113,9 +1117,17 @@ class Orchestrator:
1113
1117
  if self._git_ssh_command
1114
1118
  else None
1115
1119
  )
1120
+ log.debug("Executing git review command: %s", " ".join(args))
1116
1121
  run_cmd(args, cwd=self.workspace, env=env)
1122
+ log.info("Successfully pushed changes to Gerrit")
1117
1123
  except CommandError as exc:
1118
- msg = f"Failed to push changes to Gerrit with git-review: {exc}"
1124
+ # Analyze the specific failure reason from git review output
1125
+ error_details = self._analyze_gerrit_push_failure(exc)
1126
+ log.exception("Gerrit push failed: %s", error_details)
1127
+ msg = (
1128
+ f"Failed to push changes to Gerrit with git-review: "
1129
+ f"{error_details}"
1130
+ )
1119
1131
  raise OrchestratorError(msg) from exc
1120
1132
  # Cleanup temporary branch used during preparation
1121
1133
  tmp_branch = (os.getenv("G2G_TMP_BRANCH", "") or "").strip()
@@ -1132,6 +1144,43 @@ class Orchestrator:
1132
1144
  cwd=self.workspace,
1133
1145
  )
1134
1146
 
1147
+ def _analyze_gerrit_push_failure(self, exc: CommandError) -> str:
1148
+ """Analyze git review failure and provide helpful error message."""
1149
+ stdout = exc.stdout or ""
1150
+ stderr = exc.stderr or ""
1151
+ combined_output = f"{stdout}\n{stderr}"
1152
+ combined_lower = combined_output.lower()
1153
+
1154
+ if "missing issue-id" in combined_lower:
1155
+ return "Missing Issue-ID in commit message."
1156
+ elif "commit not associated to any issue" in combined_lower:
1157
+ return "Commit not associated to any issue."
1158
+ elif (
1159
+ "remote rejected" in combined_lower
1160
+ and "refs/for/" in combined_lower
1161
+ ):
1162
+ # Extract specific rejection reason from output
1163
+ lines = combined_output.split("\n")
1164
+ for line in lines:
1165
+ if "! [remote rejected]" in line:
1166
+ # Extract the reason in parentheses
1167
+ if "(" in line and ")" in line:
1168
+ reason = line[line.find("(") + 1 : line.find(")")]
1169
+ return f"Gerrit rejected the push: {reason}"
1170
+ return f"Gerrit rejected the push: {line.strip()}"
1171
+ return "Gerrit rejected the push for an unknown reason"
1172
+ elif "permission denied" in combined_lower:
1173
+ return "Permission denied - check SSH key and user permissions"
1174
+ elif "connection" in combined_lower and (
1175
+ "refused" in combined_lower or "timeout" in combined_lower
1176
+ ):
1177
+ return (
1178
+ "Connection failed - check network connectivity and "
1179
+ "Gerrit server availability"
1180
+ )
1181
+ else:
1182
+ return f"Unknown error: {exc}"
1183
+
1135
1184
  def _query_gerrit_for_results(
1136
1185
  self,
1137
1186
  *,
@@ -1352,6 +1401,19 @@ class Orchestrator:
1352
1401
  if not commit_shas:
1353
1402
  log.warning("No commit shas to comment on in Gerrit")
1354
1403
  return
1404
+
1405
+ # Check if back-reference comments are disabled
1406
+ if os.getenv("G2G_SKIP_GERRIT_COMMENTS", "").lower() in (
1407
+ "true",
1408
+ "1",
1409
+ "yes",
1410
+ ):
1411
+ log.info(
1412
+ "Skipping back-reference comments "
1413
+ "(G2G_SKIP_GERRIT_COMMENTS=true)"
1414
+ )
1415
+ return
1416
+
1355
1417
  log.info("Adding back-reference comment in Gerrit")
1356
1418
  user = os.getenv("GERRIT_SSH_USER_G2G", "")
1357
1419
  server = gerrit.host
@@ -1368,12 +1430,24 @@ class Orchestrator:
1368
1430
  continue
1369
1431
  try:
1370
1432
  log.debug("Executing SSH command for commit %s", csha)
1371
- run_cmd(
1433
+ # Build SSH command with our configured SSH options
1434
+ ssh_cmd = ["ssh", "-n", "-p", str(gerrit.port)]
1435
+
1436
+ # Add our SSH options if we have custom SSH config
1437
+ if self._git_ssh_command:
1438
+ # Extract SSH options from GIT_SSH_COMMAND
1439
+ # Format: "ssh -i /path/to/key -o Option=value ..."
1440
+ git_ssh_parts = self._git_ssh_command.split()
1441
+ if len(git_ssh_parts) > 1: # Skip the "ssh" part
1442
+ ssh_options = git_ssh_parts[1:]
1443
+ log.debug("Adding SSH options: %s", ssh_options)
1444
+ ssh_cmd.extend(ssh_options)
1445
+ else:
1446
+ log.debug("No custom SSH config, using default SSH options")
1447
+
1448
+ # Add the target and gerrit command
1449
+ ssh_cmd.extend(
1372
1450
  [
1373
- "ssh",
1374
- "-n",
1375
- "-p",
1376
- str(gerrit.port),
1377
1451
  f"{user}@{server}",
1378
1452
  "gerrit",
1379
1453
  "review",
@@ -1386,14 +1460,40 @@ class Orchestrator:
1386
1460
  csha,
1387
1461
  ]
1388
1462
  )
1463
+
1464
+ log.debug("Final SSH command: %s", " ".join(ssh_cmd))
1465
+ run_cmd(ssh_cmd, cwd=self.workspace)
1389
1466
  log.info(
1390
1467
  "Successfully added back-reference comment for %s: %s",
1391
1468
  csha,
1392
1469
  message,
1393
1470
  )
1394
- except Exception:
1395
- log.exception(
1396
- "Failed to add back-reference comment for %s", csha
1471
+ except CommandError as exc:
1472
+ log.warning(
1473
+ "Failed to add back-reference comment for %s "
1474
+ "(non-fatal): %s",
1475
+ csha,
1476
+ exc,
1477
+ )
1478
+ if exc.stderr:
1479
+ log.debug("SSH stderr: %s", exc.stderr)
1480
+ if exc.stdout:
1481
+ log.debug("SSH stdout: %s", exc.stdout)
1482
+ log.info(
1483
+ "Back-reference comment failed but change was successfully "
1484
+ "submitted. You can set G2G_SKIP_GERRIT_COMMENTS=true to "
1485
+ "disable these comments."
1486
+ )
1487
+ # Continue processing - this is not a fatal error
1488
+ except Exception as exc:
1489
+ log.warning(
1490
+ "Failed to add back-reference comment for %s "
1491
+ "(non-fatal): %s",
1492
+ csha,
1493
+ exc,
1494
+ )
1495
+ log.debug(
1496
+ "Back-reference comment failure details:", exc_info=True
1397
1497
  )
1398
1498
  # Continue processing - this is not a fatal error
1399
1499
 
@@ -1,5 +1,5 @@
1
- # SPDX-FileCopyrightText: 2024 Matthew Watkins
2
1
  # SPDX-License-Identifier: Apache-2.0
2
+ # SPDX-FileCopyrightText: 2025 The Linux Foundation
3
3
 
4
4
  """
5
5
  Duplicate change detection for github2gerrit.
@@ -123,6 +123,8 @@ def _getenv_str(name: str) -> str:
123
123
  def _backoff_delay(attempt: int, base: float = 0.5, cap: float = 6.0) -> float:
124
124
  # Exponential backoff with jitter; cap prevents unbounded waits.
125
125
  delay: float = float(min(base * (2 ** max(0, attempt - 1)), cap))
126
+ # Using random.uniform for jitter is appropriate here - we only need
127
+ # pseudorandom distribution to avoid thundering herd, not crypto security
126
128
  jitter: float = float(random.uniform(0.0, delay / 2.0)) # noqa: S311
127
129
  return float(delay + jitter)
128
130
 
github2gerrit/gitutils.py CHANGED
@@ -258,7 +258,6 @@ def run_cmd_with_retries(
258
258
 
259
259
  predicate = retry_on or _default_retry_on
260
260
  attempt = 0
261
- # removed unused variable 'last_res'
262
261
 
263
262
  while True:
264
263
  attempt += 1
@@ -1,14 +1,16 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.4
2
2
  Name: github2gerrit
3
- Version: 0.1.3
3
+ Version: 0.1.4
4
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
5
10
  Keywords: github,gerrit,ci,actions,typer,cli
6
- Author-Email: Matthew Watkins <mwatkins@linuxfoundation.org>
7
- License: Apache-2.0
8
11
  Classifier: Development Status :: 4 - Beta
9
12
  Classifier: Environment :: Console
10
13
  Classifier: Intended Audience :: Developers
11
- Classifier: License :: OSI Approved :: Apache Software License
12
14
  Classifier: Programming Language :: Python :: 3
13
15
  Classifier: Programming Language :: Python :: 3 :: Only
14
16
  Classifier: Programming Language :: Python :: 3.11
@@ -17,15 +19,22 @@ Classifier: Programming Language :: Python :: 3.13
17
19
  Classifier: Topic :: Software Development :: Build Tools
18
20
  Classifier: Topic :: Software Development :: Version Control
19
21
  Classifier: Typing :: Typed
20
- Project-URL: Homepage, https://github.com//lfreleng-actions/github2gerrit
21
- Project-URL: Repository, https://github.com//lfreleng-actions/github2gerrit
22
- Project-URL: Issues, https://github.com//lfreleng-actions/github2gerrit/issues
23
22
  Requires-Python: <3.14,>=3.11
23
+ Description-Content-Type: text/markdown
24
+ License-File: LICENSE
24
25
  Requires-Dist: typer>=0.12.5
25
26
  Requires-Dist: PyGithub>=2.3.0
26
27
  Requires-Dist: pygerrit2>=2.0.0
27
28
  Requires-Dist: git-review>=2.3.1
28
- Description-Content-Type: text/markdown
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
+ Dynamic: license-file
29
38
 
30
39
  <!--
31
40
  SPDX-License-Identifier: Apache-2.0
@@ -227,11 +236,18 @@ Debug output includes:
227
236
 
228
237
  Common issues and solutions:
229
238
 
230
- 1. **SSH Permission Denied**: Ensure `GERRIT_SSH_PRIVKEY_G2G` and
239
+ 1. **Configuration Validation Errors**: The tool provides clear error messages when
240
+ required configuration is missing or invalid. Look for messages starting with
241
+ "Configuration validation failed:" that specify missing inputs like
242
+ `GERRIT_KNOWN_HOSTS`, `GERRIT_SSH_PRIVKEY_G2G`, etc.
243
+ 2. **SSH Permission Denied**: Ensure `GERRIT_SSH_PRIVKEY_G2G` and
231
244
  `GERRIT_KNOWN_HOSTS` are properly set
232
- 2. **Branch Not Found**: Check that the target branch exists in both GitHub and Gerrit
233
- 3. **Change-Id Issues**: Enable debug logging to see Change-Id generation and validation
234
- 4. **Gerrit API Errors**: Verify Gerrit server connectivity and project permissions
245
+ 3. **Branch Not Found**: Check that the target branch exists in both GitHub and Gerrit
246
+ 4. **Change-Id Issues**: Enable debug logging to see Change-Id generation and validation
247
+ 5. **Gerrit API Errors**: Verify Gerrit server connectivity and project permissions
248
+
249
+ > **Note**: The tool displays configuration errors cleanly without Python tracebacks.
250
+ > If you see a traceback in the output, please report it as a bug.
235
251
 
236
252
  ### Environment Variables
237
253
 
@@ -383,6 +399,78 @@ the environment as:
383
399
  - GERRIT_CHANGE_REQUEST_URL
384
400
  - GERRIT_CHANGE_REQUEST_NUM
385
401
 
402
+ ## Known Keys
403
+
404
+ The table below lists all the configuration directives supported by the tool,
405
+ along with the corresponding environment variable (also GitHub action input)
406
+ and the corresponding CLI flags.
407
+
408
+ <!-- markdownlint-disable MD013 -->
409
+
410
+ | Environment Variable / GitHub Input | Configuration Directive | CLI Flag | Description |
411
+ |-------------------------------------|-------------------------|----------|-------------|
412
+ | `SUBMIT_SINGLE_COMMITS` | `submit_single_commits` | `--submit-single-commits` | Submit one commit at a time to the Gerrit repository |
413
+ | `USE_PR_AS_COMMIT` | `use_pr_as_commit` | `--use-pr-as-commit` | Use PR title and body as the commit message |
414
+ | `FETCH_DEPTH` | `fetch_depth` | `--fetch-depth` | Fetch-depth for the clone (default: 10) |
415
+ | `GERRIT_KNOWN_HOSTS` | `gerrit_known_hosts` | `--gerrit-known-hosts` | Known hosts entries for Gerrit SSH |
416
+ | `GERRIT_SSH_PRIVKEY_G2G` | `gerrit_ssh_privkey_g2g` | `--gerrit-ssh-privkey-g2g` | SSH private key for Gerrit (string content) |
417
+ | `GERRIT_SSH_USER_G2G` | `gerrit_ssh_user_g2g` | `--gerrit-ssh-user-g2g` | Gerrit SSH user |
418
+ | `GERRIT_SSH_USER_G2G_EMAIL` | `gerrit_ssh_user_g2g_email` | `--gerrit-ssh-user-g2g-email` | Email address for the Gerrit SSH user |
419
+ | `ORGANIZATION` | `organization` | `--organization` | Organization (defaults to GITHUB_REPOSITORY_OWNER when unset) |
420
+ | `REVIEWERS_EMAIL` | `reviewers_email` | `--reviewers-email` | Comma-separated list of reviewer emails |
421
+ | `ALLOW_GHE_URLS` | `allow_ghe_urls` | `--allow-ghe-urls` | Allow non-github.com GitHub Enterprise URLs in direct URL mode |
422
+ | `PRESERVE_GITHUB_PRS` | `preserve_github_prs` | `--preserve-github-prs` | Do not close GitHub PRs after pushing to Gerrit |
423
+ | `DRY_RUN` | `dry_run` | `--dry-run` | Check settings and PR metadata; do not write to Gerrit |
424
+ | `GERRIT_SERVER` | `gerrit_server` | `--gerrit-server` | Gerrit server hostname (optional; .gitreview preferred) |
425
+ | `GERRIT_SERVER_PORT` | `gerrit_server_port` | `--gerrit-server-port` | Gerrit SSH port (default: 29418) |
426
+ | `GERRIT_PROJECT` | `gerrit_project` | `--gerrit-project` | Gerrit project (optional; .gitreview preferred) |
427
+ | `ISSUE_ID` | `issue_id` | `--issue-id` | Issue ID to include in commit message (e.g., Issue-ID: ABC-123) |
428
+ | `ALLOW_DUPLICATES` | `allow_duplicates` | `--allow-duplicates` | Allow submitting duplicate changes without error |
429
+ | `G2G_VERBOSE` | `g2g_verbose` | `--verbose` / `-v` | Enable verbose debug logging |
430
+ | `G2G_SKIP_GERRIT_COMMENTS` | `g2g_skip_gerrit_comments` | N/A | Skip adding back-reference comments to Gerrit changes |
431
+ | `GITHUB_TOKEN` | `github_token` | N/A | GitHub API token for accessing repository and PR data |
432
+ | `PR_NUMBER` | `pr_number` | N/A | Pull request number (set automatically in CI) |
433
+ | `SYNC_ALL_OPEN_PRS` | `sync_all_open_prs` | N/A | Process all open pull requests (internal use) |
434
+ | `GERRIT_HTTP_BASE_PATH` | `gerrit_http_base_path` | N/A | HTTP base path for Gerrit API (e.g., "/r") |
435
+ | `GERRIT_HTTP_USER` | `gerrit_http_user` | N/A | Gerrit HTTP username for REST API authentication |
436
+ | `GERRIT_HTTP_PASSWORD` | `gerrit_http_password` | N/A | Gerrit HTTP password/token for REST API authentication |
437
+
438
+ <!-- markdownlint-enable MD013 -->
439
+
440
+ ### Configuration Precedence
441
+
442
+ The tool follows this precedence order for configuration values:
443
+
444
+ 1. **CLI flags** (highest priority)
445
+ 2. **Environment variables**
446
+ 3. **Configuration file values**
447
+ 4. **Tool defaults** (lowest priority)
448
+
449
+ ### Configuration File Format
450
+
451
+ Configuration files use INI format with organization-specific sections:
452
+
453
+ ```ini
454
+ [default]
455
+ GERRIT_SERVER = "gerrit.example.org"
456
+ PRESERVE_GITHUB_PRS = "true"
457
+
458
+ [onap]
459
+ ISSUE_ID = "CIMAN-33"
460
+ REVIEWERS_EMAIL = "user@example.org"
461
+
462
+ [opendaylight]
463
+ GERRIT_HTTP_USER = "bot-user"
464
+ GERRIT_HTTP_PASSWORD = "${ENV:ODL_GERRIT_TOKEN}"
465
+ ```
466
+
467
+ The tool loads configuration from `~/.config/github2gerrit/configuration.txt`
468
+ by default, or from the path specified in the `G2G_CONFIG_PATH` environment
469
+ variable.
470
+
471
+ **Note**: Unknown configuration keys will generate warnings to help catch typos
472
+ and missing functionality.
473
+
386
474
  ## Behavior details
387
475
 
388
476
  - Branch resolution
@@ -428,7 +516,7 @@ This repository follows the guidelines in `CLAUDE.md`.
428
516
  - Language and CLI
429
517
  - Python 3.11. The CLI uses Typer.
430
518
  - Packaging
431
- - `pyproject.toml` with PDM backend. Use `uv` to install and run.
519
+ - `pyproject.toml` with setuptools backend. Use `uv` to install and run.
432
520
  - Structure
433
521
  - `src/github2gerrit/cli.py` (CLI entrypoint)
434
522
  - `src/github2gerrit/core.py` (orchestration)
@@ -0,0 +1,14 @@
1
+ github2gerrit/__init__.py,sha256=N1Vj1HJ28LKCJLAynQdm5jFGQQAz9YSMzZhEfvbBgow,886
2
+ github2gerrit/cli.py,sha256=gvgyoKvNzOdh5H_BaBAkAFXvJEQLsSa4ACqYg_9QdyA,29768
3
+ github2gerrit/config.py,sha256=_r5BAowI3x5vRKSGcZsJn6NGJqkiPF8hAmfqT1id3I8,10282
4
+ github2gerrit/core.py,sha256=qatoJ_M6I8kiQeAA9kFT32uuw5Xo7pnUUWht0RL24io,69593
5
+ github2gerrit/duplicate_detection.py,sha256=J6a8t3ih-ebr6FEhWsaKnXYPQCzwcnFEWhdstmtjnMo,19475
6
+ github2gerrit/github_api.py,sha256=mgiz55GrTgAVozmoOKSLrnUcX59YxV3p2Llch2COmyE,10523
7
+ github2gerrit/gitutils.py,sha256=1KmBACvvVDIte0WiuR-AlgswbWEm69G0J2OpmAgPn7Y,18058
8
+ github2gerrit/models.py,sha256=DAm0pEWvAexOInnxTVrvTnKWhLMd86TfSqT78UohOCo,1791
9
+ github2gerrit-0.1.4.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
10
+ github2gerrit-0.1.4.dist-info/METADATA,sha256=jJml8yKtMJgtQSfZ1F-UE5dhQmtdEQeo1kyGoBjf17w,21441
11
+ github2gerrit-0.1.4.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
12
+ github2gerrit-0.1.4.dist-info/entry_points.txt,sha256=MxN2_liIKo3-xJwtAulAeS5GcOS6JS96nvwOQIkP3W8,56
13
+ github2gerrit-0.1.4.dist-info/top_level.txt,sha256=bWTYXjvuu4sSU90KLT1JlnjD7xV_iXZ-vKoulpjLTy8,14
14
+ github2gerrit-0.1.4.dist-info/RECORD,,
@@ -1,4 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: pdm-backend (2.4.5)
2
+ Generator: setuptools (80.9.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
+
@@ -1,5 +1,2 @@
1
1
  [console_scripts]
2
2
  github2gerrit = github2gerrit.cli:app
3
-
4
- [gui_scripts]
5
-
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1 @@
1
+ github2gerrit
@@ -1,12 +0,0 @@
1
- github2gerrit-0.1.3.dist-info/METADATA,sha256=W1uO2Iw4S8iK2t-YUUMIKEDCvoSovGZ0YuQDJm265ns,16565
2
- github2gerrit-0.1.3.dist-info/WHEEL,sha256=9P2ygRxDrTJz3gsagc0Z96ukrxjr-LFBGOgv3AuKlCA,90
3
- github2gerrit-0.1.3.dist-info/entry_points.txt,sha256=k9o_IZVaczDj5WeWlM3q5l86YJyVK5TEhJLV09ZPU_4,72
4
- github2gerrit/__init__.py,sha256=N1Vj1HJ28LKCJLAynQdm5jFGQQAz9YSMzZhEfvbBgow,886
5
- github2gerrit/cli.py,sha256=IAVoFdR5svmPMKLpdWe0I_EysuddIrmrkN44w0haSpA,29144
6
- github2gerrit/config.py,sha256=Kaeg67L4T477PNCP0olCyYNJ95B1XKxAFfEjPT4Mrh8,9755
7
- github2gerrit/core.py,sha256=d9b0VnmNKkbOwz2mREdFnSlX_LrNZrUFK2qbjqWHT0Q,65156
8
- github2gerrit/duplicate_detection.py,sha256=B6l98fFHC3vIk7-RcGRN5Tse1zvok4D2JwRlXGSvvO4,19470
9
- github2gerrit/github_api.py,sha256=pmWeA0_pwvVlWLCBisG2bRpUQEqyDqr0b2EY01mviIY,10372
10
- github2gerrit/gitutils.py,sha256=y77L4HPZoz_XfSyoRyCTK8og0BHXUreZb0kwLLrXKyI,18099
11
- github2gerrit/models.py,sha256=DAm0pEWvAexOInnxTVrvTnKWhLMd86TfSqT78UohOCo,1791
12
- github2gerrit-0.1.3.dist-info/RECORD,,