@@ -737,6 +737,9 @@ def _determine_sequence_number(self) -> int:
737737 # the directory for the sequence number exists but no PR yet
738738 return highest_sequence_number
739739 else :
740+ log_message (LoggingScope .TASK_OPS , 'INFO' , "pull request found: %s" , pull_request )
741+ log_message (LoggingScope .TASK_OPS , 'INFO' , "pull request state/merged: %s/%s" ,
742+ pull_request .state , str (pull_request .is_merged ()))
740743 if pull_request .is_merged ():
741744 # the PR is merged, so we use the next sequence number
742745 return highest_sequence_number + 1
@@ -872,15 +875,22 @@ def _find_pr_for_branch(self, branch_name: str) -> Optional[PullRequest]:
872875 try :
873876 # head_ref = f"{self.git_repo.owner.login}:{branch_name}"
874877 # apparently, the head_ref does not contain the login
875- head_ref = f"{ branch_name } "
876- log_message (LoggingScope .TASK_OPS , 'INFO' , "searching for PRs with head_ref: '%s'" , head_ref )
878+ last_dash = branch_name .rfind ('-' )
879+ if last_dash != - 1 :
880+ head_ref_wout_seq_num = branch_name [:last_dash + 1 ] # +1 to include the separator
881+ else :
882+ head_ref_wout_seq_num = branch_name
883+
884+ log_message (LoggingScope .TASK_OPS , 'INFO' ,
885+ "searching for PRs starting with head_ref: '%s'" , head_ref_wout_seq_num )
877886 filter_prs = [16 , 17 , 18 , 19 , 20 , 21 , 22 ] # TODO: remove this once the PR is merged
878887
879- all_prs = list (self .git_repo .get_pulls (state = 'all' ))
888+ all_prs = [pr for pr in list (self .git_repo .get_pulls (state = 'all' ))
889+ if pr .head .ref .startswith (head_ref_wout_seq_num )]
880890 for pr in all_prs :
881891 log_message (LoggingScope .TASK_OPS , 'INFO' , "PR #%d: %s" , pr .number , pr .head .ref )
882892
883- prs = [pr for pr in list (self .git_repo .get_pulls (state = 'all' , head = head_ref ))
893+ prs = [pr for pr in list (self .git_repo .get_pulls (state = 'all' , head = branch_name ))
884894 if pr .number not in filter_prs ]
885895 log_message (LoggingScope .TASK_OPS , 'INFO' , "number of PRs found: %d" , len (prs ))
886896 if len (prs ):
@@ -896,7 +906,10 @@ def _find_pr_for_sequence_number(self, sequence_number: int) -> Optional[PullReq
896906 repo_name = self .description .get_repo_name ()
897907 pr_number = self .description .get_pr_number ()
898908 feature_branch_name = f"{ repo_name } -PR-{ pr_number } -SEQ-{ sequence_number } "
899- return self ._find_pr_for_branch (feature_branch_name )
909+ pull_request = self ._find_pr_for_branch (feature_branch_name )
910+ log_message (LoggingScope .TASK_OPS , 'INFO' , "pull request for branch '%s': %s" ,
911+ feature_branch_name , pull_request )
912+ return pull_request
900913
901914 @log_function_entry_exit ()
902915 def _determine_sequence_number_from_pull_request_directory (self ) -> int :
0 commit comments