Skip to content

Commit 82cf8ad

Browse files
committed
hotfix glab with same token setup
1 parent adb07e4 commit 82cf8ad

1 file changed

Lines changed: 16 additions & 2 deletions

File tree

src/gitfetch/fetcher.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -596,6 +596,18 @@ def __init__(self, base_url: str = "https://gitlab.com",
596596
self.base_url = base_url.rstrip('/')
597597
self.api_base = f"{self.base_url}/api/v4"
598598

599+
def _build_env(self) -> dict:
600+
"""
601+
Build environment dict with token if available.
602+
603+
Returns:
604+
Environment dict for subprocess calls
605+
"""
606+
env = os.environ.copy()
607+
if self.token:
608+
env['GITLAB_TOKEN'] = self.token
609+
return env
610+
599611
def _check_glab_cli(self) -> None:
600612
"""Check if GitLab CLI is installed and authenticated."""
601613
try:
@@ -630,7 +642,8 @@ def get_authenticated_user(self) -> str:
630642
['glab', 'api', '/user'],
631643
capture_output=True,
632644
text=True,
633-
timeout=10
645+
timeout=10,
646+
env=self._build_env()
634647
)
635648
if result.returncode != 0:
636649
raise Exception("Failed to get user info")
@@ -656,7 +669,8 @@ def _api_request(self, endpoint: str) -> Any:
656669
cmd,
657670
capture_output=True,
658671
text=True,
659-
timeout=30
672+
timeout=30,
673+
env=self._build_env()
660674
)
661675
if result.returncode != 0:
662676
raise Exception(f"API request failed: {result.stderr}")

0 commit comments

Comments
 (0)