github2gerrit 0.1.7__py3-none-any.whl → 0.1.8__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
@@ -3,10 +3,13 @@
3
3
 
4
4
  from __future__ import annotations
5
5
 
6
+ import io
6
7
  import json
7
8
  import logging
8
9
  import os
10
+ import shutil
9
11
  import tempfile
12
+ import zipfile
10
13
  from collections.abc import Callable
11
14
  from concurrent.futures import ThreadPoolExecutor
12
15
  from concurrent.futures import as_completed
@@ -17,6 +20,8 @@ from typing import Protocol
17
20
  from typing import TypeVar
18
21
  from typing import cast
19
22
  from urllib.parse import urlparse
23
+ from urllib.request import Request
24
+ from urllib.request import urlopen
20
25
 
21
26
  import click
22
27
  import typer
@@ -290,14 +295,11 @@ def main(
290
295
  """
291
296
  Tool to convert GitHub pull requests into Gerrit changes
292
297
 
293
- - Providing a URL to a pull request: converts that pull request
294
- into a Gerrit change
298
+ - Providing a URL to a pull request: converts that pull request into a Gerrit change
295
299
 
296
- - Providing a URL to a GitHub repository converts all open pull
297
- requests into Gerrit changes
300
+ - Providing a URL to a GitHub repository converts all open pull requests into Gerrit changes
298
301
 
299
- - No arguments for CI/CD environment; reads parameters from
300
- environment variables
302
+ - No arguments for CI/CD environment; reads parameters from environment variables
301
303
  """
302
304
  # Override boolean parameters with properly parsed environment variables
303
305
  # This ensures that string "false" from GitHub Actions is handled correctly
@@ -746,13 +748,6 @@ def _prepare_local_checkout(workspace: Path, gh: GitHubContext, data: Inputs) ->
746
748
 
747
749
  def _fallback_to_api_archive(workspace: Path, gh: GitHubContext, data: Inputs, pr_num_str: str) -> None:
748
750
  """Fallback to GitHub API archive download for private repos."""
749
- import io
750
- import json
751
- import shutil
752
- import zipfile
753
- from urllib.request import Request
754
- from urllib.request import urlopen
755
-
756
751
  log.info("Attempting API archive fallback for PR #%s", pr_num_str)
757
752
 
758
753
  # Get GitHub token for authenticated requests
github2gerrit/core.py CHANGED
@@ -30,7 +30,10 @@ import logging
30
30
  import os
31
31
  import re
32
32
  import shlex
33
+ import shutil
34
+ import socket
33
35
  import stat
36
+ import tempfile
34
37
  import urllib.parse
35
38
  import urllib.request
36
39
  from collections.abc import Iterable
@@ -786,8 +789,6 @@ class Orchestrator:
786
789
 
787
790
  def _strategy_open_fchmod(self, key_path: Path, key_content: str) -> None:
788
791
  """Strategy: open with os.open and specific flags, then fchmod."""
789
- import os
790
- import stat
791
792
 
792
793
  flags = os.O_WRONLY | os.O_CREAT | os.O_EXCL
793
794
  mode = stat.S_IRUSR | stat.S_IWUSR # 0o600
@@ -801,7 +802,6 @@ class Orchestrator:
801
802
 
802
803
  def _strategy_umask_open(self, key_path: Path, key_content: str) -> None:
803
804
  """Strategy: set umask, create file, restore umask."""
804
- import os
805
805
 
806
806
  original_umask = os.umask(0o077) # Only owner can read/write
807
807
  try:
@@ -813,8 +813,6 @@ class Orchestrator:
813
813
 
814
814
  def _strategy_stat_constants(self, key_path: Path, key_content: str) -> None:
815
815
  """Strategy: use stat constants for permission setting."""
816
- import os
817
- import stat
818
816
 
819
817
  with open(key_path, "w", encoding="utf-8") as f:
820
818
  f.write(key_content)
@@ -826,13 +824,9 @@ class Orchestrator:
826
824
 
827
825
  def _create_key_in_memory_fs(self, key_path: Path, key_content: str) -> bool:
828
826
  """Fallback: try to create key in memory filesystem."""
829
- import shutil
830
- import tempfile
831
-
832
827
  try:
833
828
  # Try to create in memory filesystem if available
834
829
  # Use secure temporary directories
835
- import tempfile
836
830
 
837
831
  temp_dir = tempfile.gettempdir()
838
832
  memory_dirs = [temp_dir]
@@ -2343,7 +2337,6 @@ class Orchestrator:
2343
2337
  - Verify GitHub token by fetching repository and PR metadata
2344
2338
  - Do NOT perform any write operations
2345
2339
  """
2346
- import socket
2347
2340
 
2348
2341
  log.info("Dry-run: starting preflight checks")
2349
2342
  if os.getenv("G2G_DRYRUN_DISABLE_NETWORK", "").strip().lower() in (
@@ -289,8 +289,6 @@ class DuplicateDetector:
289
289
  Returns:
290
290
  Hex-encoded SHA256 hash string (first 16 characters for readability)
291
291
  """
292
- import hashlib
293
-
294
292
  # Build hash input from stable, unique PR identifiers
295
293
  # Use server_url + repository + pr_number for global uniqueness
296
294
  hash_input = f"{gh.server_url}/{gh.repository}/pull/{gh.pr_number}"
@@ -29,12 +29,14 @@ import functools
29
29
  import logging
30
30
  import random
31
31
  import socket
32
+ import subprocess
32
33
  import time
33
34
  import urllib.error
34
35
  from collections.abc import Callable
35
36
  from dataclasses import dataclass
36
37
  from dataclasses import field
37
38
  from enum import Enum
39
+ from pathlib import Path
38
40
  from typing import Any
39
41
  from typing import NoReturn
40
42
  from typing import TypeVar
@@ -441,9 +443,6 @@ def curl_download(
441
443
  Raises:
442
444
  RuntimeError: If curl command fails after retries
443
445
  """
444
- import subprocess
445
- from pathlib import Path
446
-
447
446
  if policy is None:
448
447
  policy = RetryPolicy(max_attempts=3, timeout=timeout)
449
448
 
github2gerrit/gitutils.py CHANGED
@@ -11,8 +11,10 @@ from __future__ import annotations
11
11
 
12
12
  import logging
13
13
  import os
14
+ import re
14
15
  import shlex
15
16
  import subprocess
17
+ import tempfile
16
18
  import time
17
19
  from collections.abc import Callable
18
20
  from collections.abc import Iterable
@@ -481,9 +483,7 @@ def git_commit_amend(
481
483
  # Write message to a temp file to avoid shell-escaping issues
482
484
  tmp_path: Path | None = None
483
485
  if message is not None:
484
- import tempfile as _tempfile
485
-
486
- with _tempfile.NamedTemporaryFile("w", delete=False, encoding="utf-8") as _tf:
486
+ with tempfile.NamedTemporaryFile("w", delete=False, encoding="utf-8") as _tf:
487
487
  _tf.write(message)
488
488
  _tf.flush()
489
489
  tmp_path = Path(_tf.name)
@@ -493,9 +493,6 @@ def git_commit_amend(
493
493
  # Determine whether to add -s; only suppress if message already has a sign-off for current committer
494
494
  effective_signoff = bool(signoff)
495
495
  try:
496
- import os
497
- import re
498
-
499
496
  # Resolve committer email (prefer repo-local; fallback to global/env)
500
497
  committer_email = os.getenv("GIT_COMMITTER_EMAIL", "").strip()
501
498
  if not committer_email:
@@ -586,9 +583,7 @@ def git_commit_new(
586
583
  # Write message to a temp file to avoid shell-escaping issues
587
584
  tmp_path: Path | None = None
588
585
  if message is not None:
589
- import tempfile as _tempfile
590
-
591
- with _tempfile.NamedTemporaryFile("w", delete=False, encoding="utf-8") as _tf:
586
+ with tempfile.NamedTemporaryFile("w", delete=False, encoding="utf-8") as _tf:
592
587
  _tf.write(message)
593
588
  _tf.flush()
594
589
  tmp_path = Path(_tf.name)
@@ -598,9 +593,6 @@ def git_commit_new(
598
593
  # Determine whether to add -s; only suppress if message already has a sign-off for current committer
599
594
  effective_signoff = bool(signoff)
600
595
  try:
601
- import os
602
- import re
603
-
604
596
  # Resolve committer email (prefer repo-local; fallback to global/env)
605
597
  committer_email = os.getenv("GIT_COMMITTER_EMAIL", "").strip()
606
598
  if not committer_email:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: github2gerrit
3
- Version: 0.1.7
3
+ Version: 0.1.8
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
@@ -1,14 +1,14 @@
1
1
  github2gerrit/__init__.py,sha256=N1Vj1HJ28LKCJLAynQdm5jFGQQAz9YSMzZhEfvbBgow,886
2
- github2gerrit/cli.py,sha256=heW3rwfUwPiBVIPyxDq49kF7fdtKunJAUer9z31mg_o,45538
2
+ github2gerrit/cli.py,sha256=j2jdsfO3WZqHF0UIINVWJrPzMUHtIwzGKmbAhvP1Q3c,45483
3
3
  github2gerrit/commit_normalization.py,sha256=u4AZigz3qOpz5XYpUOq3WUqsY-o08YrkgaT160eyIIs,16594
4
4
  github2gerrit/config.py,sha256=sTiujlOjCsJbaA-Ftr5XR--9nxs7XH8uEWD-IbGqLYk,17370
5
- github2gerrit/core.py,sha256=Mjo_TNocFE5HDmRTxh54LEHAEw5y1u6lc1qItEZ76GA,105180
6
- github2gerrit/duplicate_detection.py,sha256=5j6EDz2P3GnnT2JkR1tGbzWCjA6TV0l5VjsEMs-tfCM,26544
7
- github2gerrit/external_api.py,sha256=EVHh__v6lRq_ojpBI_nkGZ31AQSZ9NG8tDqVUid23XY,17638
5
+ github2gerrit/core.py,sha256=xSUBhB_xOpCrVbnNu2m1QqKrZJTa8zJrmEK28-ehqPg,105033
6
+ github2gerrit/duplicate_detection.py,sha256=enzLMsMQOeB5yU_iEOfTN5oGuZ0LUZNENsQ4fFnKKRg,26520
7
+ github2gerrit/external_api.py,sha256=ypMKGIsCAYTvP2u55l8X5eUC88T6EKvyZvlsAWRFVcU,17629
8
8
  github2gerrit/gerrit_rest.py,sha256=NmC95hb2hLpnko8Uu3OwPEKktNv-k3qrmuA7A2q-H0Y,10562
9
9
  github2gerrit/gerrit_urls.py,sha256=pw4rjIQeQ-i-vbPqsOZjZpdz7FO03pnMUMWc8L9Mcic,12893
10
10
  github2gerrit/github_api.py,sha256=1cTZMunDx6_oLNR3Z__ya6vsw0_PFS5ww3jQla5SVFA,8229
11
- github2gerrit/gitutils.py,sha256=3ob1K7dlKeWYYYOPXIIJ56p2N49lm1yj8XHHg2zSlhw,25929
11
+ github2gerrit/gitutils.py,sha256=7E-bYux4E-5IJMSxYx8U0sKzD-wkn3QyEfZ7SGHkGrY,25803
12
12
  github2gerrit/models.py,sha256=sRS4rPMF_wjV19HMFTzhHXFMfsLFzm9TFb1JydJsSyQ,1875
13
13
  github2gerrit/pr_content_filter.py,sha256=w4MqSZ4uLX-3Da1DL_A56zVQa7xJ4h5jHMNteOOG2AE,16896
14
14
  github2gerrit/similarity.py,sha256=xPqdypI-Fmpeb74K4lcqZBxj17i8avS_x73dXckeicA,15268
@@ -16,9 +16,9 @@ github2gerrit/ssh_agent_setup.py,sha256=fvKuMdF9Hv5ioaSu_alzLcjeoQLGGFRLS2wb46Kd
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.7.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
20
- github2gerrit-0.1.7.dist-info/METADATA,sha256=4EZvJoxh9EhKSxcHrv-SJ1IHE7rbe5VYFH7WhKzxJD0,30930
21
- github2gerrit-0.1.7.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
22
- github2gerrit-0.1.7.dist-info/entry_points.txt,sha256=MxN2_liIKo3-xJwtAulAeS5GcOS6JS96nvwOQIkP3W8,56
23
- github2gerrit-0.1.7.dist-info/top_level.txt,sha256=bWTYXjvuu4sSU90KLT1JlnjD7xV_iXZ-vKoulpjLTy8,14
24
- github2gerrit-0.1.7.dist-info/RECORD,,
19
+ github2gerrit-0.1.8.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
20
+ github2gerrit-0.1.8.dist-info/METADATA,sha256=XMojs1cbwj9CPacFK6YDE3TczE5s4tE4YFPKZXGUUIY,30930
21
+ github2gerrit-0.1.8.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
22
+ github2gerrit-0.1.8.dist-info/entry_points.txt,sha256=MxN2_liIKo3-xJwtAulAeS5GcOS6JS96nvwOQIkP3W8,56
23
+ github2gerrit-0.1.8.dist-info/top_level.txt,sha256=bWTYXjvuu4sSU90KLT1JlnjD7xV_iXZ-vKoulpjLTy8,14
24
+ github2gerrit-0.1.8.dist-info/RECORD,,