@@ -98,6 +98,11 @@ def get_readme(self) -> str:
98
98
@property
99
99
def repo (self ):
100
100
return self .get_repo ()
101
+
102
+ def set_github (self , github_instance : ExtendedGithub ):
103
+ self ._github = github_instance
104
+ with self ._repo_lock : # Locking for write action
105
+ self ._repo = self ._github .get_repo (self .full_name )
101
106
102
107
def get_repo (self ):
103
108
"""
@@ -118,8 +123,8 @@ def get_repo(self):
118
123
self .default_branch = self ._repo .default_branch
119
124
self .updated_at = self ._repo .updated_at
120
125
except GithubException as e :
121
- logger .exception (
122
- f"Error retrieving repository '{ self .full_name } ':" )
126
+ logger .error (
127
+ f"Error retrieving repository '{ self .full_name } ':{ str ( e ) } " )
123
128
return None
124
129
self .update_last_read_time ()
125
130
return self ._repo
@@ -303,8 +308,8 @@ def extract_related_issues(self, pr_data: Dict[str, Any]) -> List[int]:
303
308
# Full GitHub issue/PR URL pattern
304
309
rf'(?:https?://)?github\.com/{ re .escape (self .full_name )} /(?:issues|pull)/(\d+)' ,
305
310
306
- # Standard #123 reference with proper boundaries
307
- r'(?:^|[^\w/])#(\d+)(?=[^\w/]|$)' ,
311
+ # # Standard #123 reference with proper boundaries
312
+ # r'(?:^|[^\w/])#(\d+)(?=[^\w/]|$)',
308
313
309
314
# Closing keywords (fixes #123)
310
315
fr'(?:^|[^\w/])(?:{ "|" .join (closing_keywords )} ):?\s+#(\d+)(?=[^\w/]|$)' ,
@@ -377,7 +382,7 @@ def to_isoformat(self, dt: datetime) -> Optional[str]:
377
382
return dt .astimezone (timezone .utc ).replace (microsecond = 0 ).isoformat ().replace ('+00:00' , 'Z' )
378
383
return None
379
384
380
- def get_pr_content (self , number , pr = None , context_lines = 10 ) -> Dict [str , Any ]:
385
+ def get_pr_content (self , number , pr = None , context_lines = 10 , force_update = False ) -> Dict [str , Any ]:
381
386
"""
382
387
Retrieves and processes the content of a pull request.
383
388
@@ -386,9 +391,9 @@ def get_pr_content(self, number, pr=None, context_lines=10) -> Dict[str, Any]:
386
391
:param context_lines: Number of context lines for diffs.
387
392
:return: A dictionary containing detailed PR information.
388
393
"""
389
- if number not in self ._prs : # Check if issue has already been fetched
394
+ if number not in self ._prs or force_update : # Check if issue has already been fetched
390
395
with self ._pr_lock : # Locking for write action
391
- if number not in self ._prs : # Check if issue has already been fetched after get lock
396
+ if number not in self ._prs or force_update : # Check if issue has already been fetched after get lock
392
397
try :
393
398
logger .debug (f"Processing PR #{ number } " )
394
399
if pr is None :
@@ -691,13 +696,29 @@ def _get_repo_lock(self, full_name):
691
696
self ._locks_registry [full_name ] = Lock ()
692
697
return self ._locks_registry [full_name ]
693
698
694
- def get_repository (self , full_name , ** kwargs ) -> Repository :
695
- """Retrieve a repository from the pool or create a new one if it doesn't exist."""
699
+ def get_repository (self , full_name , github_instance = None , ** kwargs ) -> Repository :
700
+ """
701
+ Retrieve a repository from the pool or create a new one if it doesn't exist.
702
+
703
+ If you are using github_install_id to generate a new repository object, you should pass new github_instance to the function.
704
+ Otherwise the default github_instance within the pool might not fit to the new repository object.
705
+ """
706
+
696
707
if full_name in self ._pool :
708
+ # repo = self._pool[full_name]
709
+ # repo.update_last_read_time()
710
+ # if github_instance is not None:
711
+ # repo.set_github(github_instance)
712
+ # return repo
697
713
return self ._pool [full_name ]
714
+
698
715
repo_lock = self ._get_repo_lock (full_name )
699
716
with repo_lock :
700
717
if full_name not in self ._pool :
701
- self ._pool [full_name ] = Repository (
702
- full_name , self .github_instance , ** kwargs )
703
- return self ._pool [full_name ]
718
+ if github_instance is not None :
719
+ repo = Repository (full_name , github_instance , ** kwargs )
720
+ else :
721
+ repo = Repository (full_name , self .github_instance , ** kwargs )
722
+ self ._pool [full_name ] = repo
723
+
724
+ return self ._pool [full_name ]
0 commit comments