Changeset 7064
- Timestamp:
- 04/08/2018 11:43:27 AM (7 years ago)
- Location:
- sites/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/common/includes/slack/trac/comment-handler.php
r7041 r7064 37 37 $line = array_shift( $lines ); 38 38 if ( 0 === strpos( $line, 'X-Trac-Ticket-URL:' ) ) { 39 // X-Trac-Ticket-URL: https://core.trac.wordpress.org/ticket/12345#comment:139 $comment_id = 0; 40 40 list( , $comment_url ) = explode( ': ', $line ); 41 list( $ticket_url, $comment_id ) = explode( '#comment:', $comment_url ); 41 42 // Get ticket URL, attachment notifcations have no specific URL. 43 if ( false !== strpos( $line, '#comment:' ) ) { 44 // X-Trac-Ticket-URL: https://core.trac.wordpress.org/ticket/12345#comment:1 45 list( $ticket_url, $comment_id ) = explode( '#comment:', $comment_url ); 46 } else { 47 // X-Trac-Ticket-URL: https://core.trac.wordpress.org/ticket/12345 48 $ticket_url = $comment_url; 49 } 50 42 51 list( $trac_url, $ticket_id ) = explode( '/ticket/', $ticket_url ); 43 52 … … 167 176 if ( $has_changes ) { 168 177 while ( $lines && '' !== current( $lines ) ) { 169 $changes[] = preg_replace( '~^ \* (.*?): ~', '_*$1:*_ ', array_shift( $lines ) ); 178 $line = array_shift( $lines ); 179 180 if ( preg_match( '~Attachment "([^"]+)" (added|removed)\.$~', $line, $matches ) ) { // * Attachment "test.txt" added/removed. 181 $changes[] = "_*attachment:*_ `{$matches[1]}` {$matches[2]}"; 182 } else { // * status: assigned => closed 183 $changes[] = preg_replace( '~^ \* (.*?): ~', '_*$1:*_ ', $line ); 184 } 170 185 } 171 186 } -
sites/trunk/svn.wordpress.org/bin/slack-trac-hook.php
r3062 r7064 24 24 $ticket_base_url = $matches[3]; 25 25 $ticket = $matches[4]; 26 $type = isset( $matches[5] ) ? 'comment' : 'ticket'; 26 // Attachment notifcations use the ticket URL, check for attachment change line and process mail as comment on match. 27 $is_attachment = (bool) preg_grep( '/^ \* Attachment "([^"]+)"/', $lines ); 28 $type = ( isset( $matches[5] ) || $is_attachment ) ? 'comment' : 'ticket'; 27 29 preg_match( '~^https?://([^.]+)\.trac~i', $ticket_base_url, $matches ); 28 30 $trac = $matches[1];
Note: See TracChangeset
for help on using the changeset viewer.