From 4f8a49ac1e40a565289cb30d2b378a56e826cdfc Mon Sep 17 00:00:00 2001 From: zeviraty Date: Thu, 18 Dec 2025 14:21:21 +0100 Subject: [PATCH 1/3] Made a None token revert -> '' --- src/gitfetch/config.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gitfetch/config.py b/src/gitfetch/config.py index f01b069..5fb2f42 100644 --- a/src/gitfetch/config.py +++ b/src/gitfetch/config.py @@ -255,7 +255,7 @@ def set_custom_box(self, box: str) -> None: self.config['DEFAULT'] = {} self.config['DEFAULT']['custom_box'] = box - def get_token(self) -> Optional[str]: + def get_token(self) -> str: """ Get the personal access token from config. @@ -263,7 +263,7 @@ def get_token(self) -> Optional[str]: Token or None if not set """ token = self.config.get('DEFAULT', 'token', fallback='') - return token if token else None + return token if token else '' def set_token(self, token: str) -> None: """ From a6cc20a84b5b7cd4f1bb6ab9134691d578e5f0df Mon Sep 17 00:00:00 2001 From: zeviraty Date: Thu, 18 Dec 2025 14:26:58 +0100 Subject: [PATCH 2/3] Fixed unset token variable --- src/gitfetch/fetcher.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/gitfetch/fetcher.py b/src/gitfetch/fetcher.py index 23a1591..5a5deca 100644 --- a/src/gitfetch/fetcher.py +++ b/src/gitfetch/fetcher.py @@ -79,7 +79,6 @@ def _build_contribution_graph_from_git(repo_path: str = ".") -> list: result = subprocess.run( ['git', 'log', '--pretty=format:%ai', '--all'], capture_output=True, text=True, cwd=repo_path, - env={**os.environ, 'GH_TOKEN': os.getenv('GH_TOKEN')} ) if result.returncode != 0: return [] @@ -217,7 +216,7 @@ def _gh_api(self, endpoint: str, method: str = "GET") -> Any: capture_output=True, text=True, timeout=30, - env={**os.environ, 'GH_TOKEN': os.getenv('GH_TOKEN')} + env={'GH_TOKEN': self.token} if self.token != None else {} ) if result.returncode != 0: raise Exception(f"gh api failed: {result.stderr}") @@ -442,7 +441,7 @@ def _search_items(self, query: str, per_page: int = 5) -> Dict[str, Any]: capture_output=True, text=True, timeout=30, - env={**os.environ, 'GH_TOKEN': os.getenv('GH_TOKEN')} + env={'GH_TOKEN': self.token} if self.token != None else {} ) if result.returncode != 0: return {'total_count': 0, 'items': []} @@ -554,7 +553,7 @@ def _fetch_contribution_graph(self, username: str) -> list: capture_output=True, text=True, timeout=30, - env={**os.environ, 'GH_TOKEN': os.getenv('GH_TOKEN')} + env={'GH_TOKEN': self.token} if self.token != None else {} ) if result.returncode != 0: @@ -647,7 +646,7 @@ def _api_request(self, endpoint: str) -> Any: capture_output=True, text=True, timeout=30, - env={**os.environ, 'GH_TOKEN': os.getenv('GH_TOKEN')} + env={'GH_TOKEN': self.token} if self.token != None else {} ) if result.returncode != 0: raise Exception(f"API request failed: {result.stderr}") From 0152c04948429147229ce91e31e73e3c14952835 Mon Sep 17 00:00:00 2001 From: zeviraty Date: Thu, 18 Dec 2025 14:29:09 +0100 Subject: [PATCH 3/3] Fixed gitlab _api_request using github token --- src/gitfetch/fetcher.py | 1 - 1 file changed, 1 deletion(-) diff --git a/src/gitfetch/fetcher.py b/src/gitfetch/fetcher.py index 5a5deca..065ae06 100644 --- a/src/gitfetch/fetcher.py +++ b/src/gitfetch/fetcher.py @@ -646,7 +646,6 @@ def _api_request(self, endpoint: str) -> Any: capture_output=True, text=True, timeout=30, - env={'GH_TOKEN': self.token} if self.token != None else {} ) if result.returncode != 0: raise Exception(f"API request failed: {result.stderr}")