Changeset 11847
- Timestamp:
- 05/16/2022 04:00:33 AM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/api.wordpress.org/public_html/dotorg/trac/pr/functions.php
r11666 r11847 244 244 $ticket = false; 245 245 246 // If the trac found is the key, return the value. 247 $trac_redirects = [ 248 // Themes trac mentions are likely Meta tickets. 249 'themes' => 'meta', 250 ]; 251 246 252 // For now, we assume everything is destined for the Core Trac. 247 253 $trac = 'core'; … … 253 259 $trac = 'core'; 254 260 break; 261 case 'buddypress/buddypress': 262 $trac = 'buddypress'; 263 break; 264 case 'bbpress/bbPress': 265 $trac = 'bbpress'; 266 break; 255 267 default: 268 // If `?trac=....` is passed to the webhook endpoint: 256 269 if ( defined( 'WEBHOOK_TRAC_HINT' ) && WEBHOOK_TRAC_HINT ) { 257 270 $trac = WEBHOOK_TRAC_HINT; 258 271 } 272 273 // If a specific trac is mentioned within the PR body: 274 elseif ( preg_match( '!/(?P<trac>[a-z]+).trac.wordpress.org/!i', $pr->body, $m ) ) { 275 $trac = $m['trac']; 276 } 277 278 // If the repo starts with 'wporg-' assume Meta. 279 elseif ( str_starts_with( $pr->base->repo->full_name, 'WordPress/wporg-' ) ) { 280 $trac = 'meta'; 281 } 259 282 break; 260 283 } 261 284 262 285 $regexes = [ 263 '! ' . $trac . '.trac.wordpress.org/ticket/(\d+)!i',286 '!(?P<trac>[a-z]+).trac.wordpress.org/ticket/(?P<id>\d+)!i', 264 287 '!(?:^|\s)#WP(\d+)!', // #WP1234 265 288 '!(?:^|\s)#(\d{4,5})!', // #1234 … … 268 291 '!\b(\d+)(\.\d)?\.(?:diff|patch)!i', 269 292 // Formats of common branches 270 '!( ?:' . $trac . '|WordPress|fix|trac)[-/](\d+)!i',293 '!((?P<trac>core|meta|bbpress|buddypress|themes)|WordPress|fix|trac)[-/](?P<id>\d+)!i', 271 294 // Starts or ends with a ticketish number 272 295 // These match things it really shouldn't, and are a last-ditch effort. … … 284 307 ] as $field ) { 285 308 if ( preg_match( $regex, $field, $m ) ) { 309 $id = $m['id'] ?? $m[1]; 310 311 // If a Trac-specific link is detected, use that trac. 312 if ( ! empty( $m['trac'] ) ) { 313 $trac = $m['trac']; 314 } 315 316 $trac = $trac_redirects[ $trac ] ?? $trac; 317 286 318 return [ $trac, $m[1] ]; 287 319 }
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)