Project

General

Profile

action #178771

Updated by tinita about 1 month ago

## Motivation 

 The code for bugrefs can be improved. 

 The urls are currently hardcoded. 
 https://github.com/os-autoinst/openQA/blob/master/lib/OpenQA/Utils.pm#L41-L73 

 There is code that handles some exceptions for certain bugtrackers: 
 https://github.com/os-autoinst/openQA/blob/master/lib/OpenQA/Utils.pm#L459-L460 
 ``` 
     my $issuetext = $+{marker} eq 'pio' ? 'issue' : 'issues'; 
     return $BUGREFS{$+{marker}} . ($+{repo} ? "$+{repo}/$issuetext/" : '') . $+{id}; 
 ``` 

 There is a regex that tries to make it work for all bugtrackers but this is hard to understand by now: 
 https://github.com/os-autoinst/openQA/blob/master/lib/OpenQA/Utils.pm#L477 
 ``` 
     $regex = qr{(?<!["\(\[])(?<url_root>$regex)((?<repo>.*?)/(-/)?(issues?|pull)/)?(?<id>([A-Z]+-)?\d+)(?![\w])}; 
 ``` 
 We have extra code for matching `recognized_referers` that needs to be improved to only match links to issues: #176826  

 We should not invent a second list or mapping, if we are basically talking about the same urls. 
 The configured bugtrackers are usually the same urls that you would want for referer matching. 

 A configuration section would probably be a bit more verbose, but easier to understand and maintain, and we don't need to add all possible bugtrackers just because other openQA instances are using them. 

 This would block or replace #176826 

 Benefit for users: They can add additional bugtrackers themselves and don't have to patch the source. 
 If it's a known kind, e.g. gitea, gitlab, redmine, jira it's very easy to do. 
 If it's a new kind that would require to update our horrible regex it is probably also easier to use the new format. 

 Benefit for us: cleaner code. I wouldn't be proud of the current code. And also we are users.

Back