[IMP] runbot: support github display for branch search

Supports the format (?owner)/repo#id in the `_search_dname` method.
This commit is contained in:
William Braeckman 2025-01-22 15:25:14 +01:00 committed by William Braeckman (wbr)
parent 1fa7e4c0c7
commit c9c31f843c
2 changed files with 5 additions and 1 deletions

View File

@ -51,7 +51,7 @@ class Branch(models.Model):
def _search_dname(self, operator, value): def _search_dname(self, operator, value):
# Match format (owner?, repo, branch) # Match format (owner?, repo, branch)
owner = repo = branch = None owner = repo = branch = None
if (m := re.match(r'(?:([\w-]+)/)?([\w-]+):([\w\.-]+)', value)): if (m := re.match(r'(?:([\w-]+)/)?([\w-]+)[:#]([\w\.-]+)', value)):
owner, repo, branch = m.groups() owner, repo, branch = m.groups()
# Match PR url format # Match PR url format
if (m := re.search(r'/([\w-]+)/([\w-]+)/pull/(\d+)', value)): if (m := re.search(r'/([\w-]+)/([\w-]+)/pull/(\d+)', value)):

View File

@ -35,6 +35,10 @@ class TestBranch(RunbotCase):
self.branch_server, self.branch_server,
self.Branch.search([('dname', '=', self.branch_server.dname)]), self.Branch.search([('dname', '=', self.branch_server.dname)]),
) )
self.assertEqual(
self.branch_server,
self.Branch.search([('dname', '=', self.branch_server.dname.replace(':', '#'))]),
)
# Basic pr # Basic pr
self.assertEqual( self.assertEqual(
self.dev_pr, self.dev_pr,