@@ -78,7 +78,8 @@ def _build_contribution_graph_from_git(repo_path: str = ".") -> list:
7878 # Get commit dates
7979 result = subprocess .run (
8080 ['git' , 'log' , '--pretty=format:%ai' , '--all' ],
81- capture_output = True , text = True , cwd = repo_path
81+ 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 []
@@ -130,8 +131,9 @@ def __init__(self, token: Optional[str] = None):
130131 Initialize the GitHub fetcher.
131132
132133 Args:
133- token: Optional GitHub personal access token (ignored, uses gh CLI)
134+ token: Optional GitHub personal access token
134135 """
136+ self .token = token
135137 pass
136138
137139 def _check_gh_cli (self ) -> None :
@@ -141,7 +143,8 @@ def _check_gh_cli(self) -> None:
141143 ['gh' , 'auth' , 'status' ],
142144 capture_output = True ,
143145 text = True ,
144- timeout = 5
146+ timeout = 5 ,
147+ env = {** os .environ , 'GH_TOKEN' : self .token }
145148 )
146149 if result .returncode != 0 :
147150 print ("\n ⚠️ GitHub CLI is not authenticated!" , file = sys .stderr )
@@ -173,7 +176,8 @@ def get_authenticated_user(self) -> str:
173176 ['gh' , 'auth' , 'status' , '--json' , 'hosts' ],
174177 capture_output = True ,
175178 text = True ,
176- timeout = 5
179+ timeout = 5 ,
180+ env = {** os .environ , 'GH_TOKEN' : os .getenv ('GH_TOKEN' )}
177181 )
178182 if result .returncode != 0 :
179183 try :
@@ -214,7 +218,8 @@ def _gh_api(self, endpoint: str, method: str = "GET") -> Any:
214218 ['gh' , 'api' , endpoint , '-X' , method ],
215219 capture_output = True ,
216220 text = True ,
217- timeout = 30
221+ timeout = 30 ,
222+ env = {** os .environ , 'GH_TOKEN' : os .getenv ('GH_TOKEN' )}
218223 )
219224 if result .returncode != 0 :
220225 raise Exception (f"gh api failed: { result .stderr } " )
@@ -438,7 +443,8 @@ def _search_items(self, query: str, per_page: int = 5) -> Dict[str, Any]:
438443 cmd ,
439444 capture_output = True ,
440445 text = True ,
441- timeout = 30
446+ timeout = 30 ,
447+ env = {** os .environ , 'GH_TOKEN' : os .getenv ('GH_TOKEN' )}
442448 )
443449 if result .returncode != 0 :
444450 return {'total_count' : 0 , 'items' : []}
@@ -531,7 +537,7 @@ def _fetch_contribution_graph(self, username: str) -> list:
531537 # GraphQL query for contribution calendar (inline username)
532538 query = f'''{{
533539 user(login: "{ username } ") {{
534- contributionsCollection {{
540+ contributionsCollection(includePrivate: true) {{
535541 contributionCalendar {{
536542 weeks {{
537543 contributionDays {{
@@ -549,7 +555,8 @@ def _fetch_contribution_graph(self, username: str) -> list:
549555 ['gh' , 'api' , 'graphql' , '-f' , f'query={ query } ' ],
550556 capture_output = True ,
551557 text = True ,
552- timeout = 30
558+ timeout = 30 ,
559+ env = {** os .environ , 'GH_TOKEN' : os .getenv ('GH_TOKEN' )}
553560 )
554561
555562 if result .returncode != 0 :
@@ -588,7 +595,8 @@ def _check_glab_cli(self) -> None:
588595 ['glab' , 'auth' , 'status' ],
589596 capture_output = True ,
590597 text = True ,
591- timeout = 5
598+ timeout = 5 ,
599+ env = {** os .environ , 'GH_TOKEN' : os .getenv ('GH_TOKEN' )}
592600 )
593601 if result .returncode != 0 :
594602 print ("GitLab CLI not authenticated" , file = sys .stderr )
@@ -615,7 +623,8 @@ def get_authenticated_user(self) -> str:
615623 ['glab' , 'api' , '/user' ],
616624 capture_output = True ,
617625 text = True ,
618- timeout = 10
626+ timeout = 10 ,
627+ env = {** os .environ , 'GH_TOKEN' : os .getenv ('GH_TOKEN' )}
619628 )
620629 if result .returncode != 0 :
621630 raise Exception ("Failed to get user info" )
@@ -641,7 +650,8 @@ def _api_request(self, endpoint: str) -> Any:
641650 cmd ,
642651 capture_output = True ,
643652 text = True ,
644- timeout = 30
653+ timeout = 30 ,
654+ env = {** os .environ , 'GH_TOKEN' : os .getenv ('GH_TOKEN' )}
645655 )
646656 if result .returncode != 0 :
647657 raise Exception (f"API request failed: { result .stderr } " )
0 commit comments