Skip to content

Commit b9aefe5

Browse files
authored
Revert "Fixed issues with handling of gh token"
1 parent c255264 commit b9aefe5

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

src/gitfetch/config.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -255,15 +255,15 @@ def set_custom_box(self, box: str) -> None:
255255
self.config['DEFAULT'] = {}
256256
self.config['DEFAULT']['custom_box'] = box
257257

258-
def get_token(self) -> str:
258+
def get_token(self) -> Optional[str]:
259259
"""
260260
Get the personal access token from config.
261261
262262
Returns:
263263
Token or None if not set
264264
"""
265265
token = self.config.get('DEFAULT', 'token', fallback='')
266-
return token if token else ''
266+
return token if token else None
267267

268268
def set_token(self, token: str) -> None:
269269
"""

src/gitfetch/fetcher.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ def _build_contribution_graph_from_git(repo_path: str = ".") -> list:
7979
result = subprocess.run(
8080
['git', 'log', '--pretty=format:%ai', '--all'],
8181
capture_output=True, text=True, cwd=repo_path,
82+
env={**os.environ, 'GH_TOKEN': os.getenv('GH_TOKEN')}
8283
)
8384
if result.returncode != 0:
8485
return []
@@ -216,7 +217,7 @@ def _gh_api(self, endpoint: str, method: str = "GET") -> Any:
216217
capture_output=True,
217218
text=True,
218219
timeout=30,
219-
env={'GH_TOKEN': self.token} if self.token != None else {}
220+
env={**os.environ, 'GH_TOKEN': os.getenv('GH_TOKEN')}
220221
)
221222
if result.returncode != 0:
222223
raise Exception(f"gh api failed: {result.stderr}")
@@ -441,7 +442,7 @@ def _search_items(self, query: str, per_page: int = 5) -> Dict[str, Any]:
441442
capture_output=True,
442443
text=True,
443444
timeout=30,
444-
env={'GH_TOKEN': self.token} if self.token != None else {}
445+
env={**os.environ, 'GH_TOKEN': os.getenv('GH_TOKEN')}
445446
)
446447
if result.returncode != 0:
447448
return {'total_count': 0, 'items': []}
@@ -553,7 +554,7 @@ def _fetch_contribution_graph(self, username: str) -> list:
553554
capture_output=True,
554555
text=True,
555556
timeout=30,
556-
env={'GH_TOKEN': self.token} if self.token != None else {}
557+
env={**os.environ, 'GH_TOKEN': os.getenv('GH_TOKEN')}
557558
)
558559

559560
if result.returncode != 0:
@@ -646,6 +647,7 @@ def _api_request(self, endpoint: str) -> Any:
646647
capture_output=True,
647648
text=True,
648649
timeout=30,
650+
env={**os.environ, 'GH_TOKEN': os.getenv('GH_TOKEN')}
649651
)
650652
if result.returncode != 0:
651653
raise Exception(f"API request failed: {result.stderr}")

0 commit comments

Comments
 (0)