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: """ diff --git a/src/gitfetch/fetcher.py b/src/gitfetch/fetcher.py index 23a1591..065ae06 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,6 @@ def _api_request(self, endpoint: str) -> Any: capture_output=True, text=True, timeout=30, - env={**os.environ, 'GH_TOKEN': os.getenv('GH_TOKEN')} ) if result.returncode != 0: raise Exception(f"API request failed: {result.stderr}")