Skip to content

Commit 2275007

Browse files
committed
restructure logging when determining PRR”
1 parent 251b60e commit 2275007

1 file changed

Lines changed: 20 additions & 14 deletions

File tree

scripts/automated_ingestion/eessi_task.py

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -875,21 +875,7 @@ def _find_pr_for_branch(self, branch_name: str) -> Optional[PullRequest]:
875875
try:
876876
# head_ref = f"{self.git_repo.owner.login}:{branch_name}"
877877
# apparently, the head_ref does not contain the login
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)
886878
filter_prs = [16, 17, 18, 19, 20, 21, 22] # TODO: remove this once the PR is merged
887-
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)]
890-
for pr in all_prs:
891-
log_message(LoggingScope.TASK_OPS, 'INFO', "PR #%d: %s", pr.number, pr.head.ref)
892-
893879
prs = [pr for pr in list(self.git_repo.get_pulls(state='all', head=branch_name))
894880
if pr.number not in filter_prs]
895881
log_message(LoggingScope.TASK_OPS, 'INFO', "number of PRs found: %d", len(prs))
@@ -906,6 +892,26 @@ def _find_pr_for_sequence_number(self, sequence_number: int) -> Optional[PullReq
906892
repo_name = self.description.get_repo_name()
907893
pr_number = self.description.get_pr_number()
908894
feature_branch_name = f"{repo_name.replace('/', '-')}-PR-{pr_number}-SEQ-{sequence_number}"
895+
896+
# list all PRs with head_ref starting with the feature branch name without the sequence number
897+
last_dash = feature_branch_name.rfind('-')
898+
if last_dash != -1:
899+
head_ref_wout_seq_num = feature_branch_name[:last_dash + 1] # +1 to include the separator
900+
else:
901+
head_ref_wout_seq_num = feature_branch_name
902+
903+
log_message(LoggingScope.TASK_OPS, 'INFO',
904+
"searching for PRs whose head_ref starts with: '%s'", head_ref_wout_seq_num)
905+
906+
all_prs = [pr for pr in list(self.git_repo.get_pulls(state='all'))
907+
if pr.head.ref.startswith(head_ref_wout_seq_num)]
908+
log_message(LoggingScope.TASK_OPS, 'INFO', " number of PRs found: %d", len(all_prs))
909+
for pr in all_prs:
910+
log_message(LoggingScope.TASK_OPS, 'INFO', " PR #%d: %s", pr.number, pr.head.ref)
911+
912+
# now, find the PR for the feature branch name (if any)
913+
log_message(LoggingScope.TASK_OPS, 'INFO',
914+
"searching PR for feature branch name: '%s'", feature_branch_name)
909915
pull_request = self._find_pr_for_branch(feature_branch_name)
910916
log_message(LoggingScope.TASK_OPS, 'INFO', "pull request for branch '%s': %s",
911917
feature_branch_name, pull_request)

0 commit comments

Comments
 (0)