Skip to content

Commit

Permalink
Parse AZDO PR's numbers with enabled auto-complete
Browse files Browse the repository at this point in the history
  • Loading branch information
bonddim committed Jun 28, 2024
1 parent 45a3ec2 commit 16bd450
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/repositories/azdo_git_repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# Licensed under the MIT License.

import os
import re
import json
import requests
import utils
Expand Down Expand Up @@ -123,12 +124,16 @@ def get_commit_message(self, commit_id):

def get_pr_num(self, commit_id) -> str:
comment = self.get_commit_message(commit_id)
MERGED_PR = "Merged PR "
pr_num = None
if MERGED_PR in comment:
merged_pr_index = comment.index(MERGED_PR)
pr_num = comment[merged_pr_index + len(MERGED_PR): comment.index(":", merged_pr_index)]
return pr_num
# Regex pattern to match "Merged PR <number>" or "Merge pull request <number>"
pattern = r'Merged PR (\d+)|Merge pull request (\d+)'

match = re.search(pattern, comment)
if match:
# Group 1 is for "Merged PR", Group 2 is for "Merge pull request"
pr_num = match.group(1) or match.group(2)
return pr_num

return ""

def is_commit_finished(self, commit_id):
return False

0 comments on commit 16bd450

Please sign in to comment.