- Timestamp:
- 12/31/2014 04:48:29 PM (10 years ago)
- Location:
- sites/trunk/svn.wordpress.org/includes/slack-trac-hooks
- Files:
-
- 1 copied
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/svn.wordpress.org/includes/slack-trac-hooks/trac.php
r1077 r1078 1 1 <?php 2 2 3 namespace SlackCommitHook;3 namespace Dotorg\SlackTracHooks; 4 4 5 5 abstract class Trac { 6 protected $channels = '#test'; 7 protected $username = 'Commit'; 6 protected $commit_channels = '#test'; 7 protected $commit_username = 'Commit'; 8 protected $ticket_channels = '#test'; 9 protected $ticket_username; 10 11 protected $firehose_channel = false; 12 8 13 protected $color = '#21759b'; 9 14 protected $emoji = ':wordpress:'; … … 15 20 16 21 function __construct() { 17 // 'SlackCommitHook\Core_Trac' => 'core' 18 $this->trac = strtolower( str_replace( array( __NAMESPACE__, '\\', '_Trac' ), '', get_class( $this ) ) ); 22 // 'Dotorg\SlackTracHooks\Core_Trac' => 'Core_Trac' 23 $class = str_replace( __NAMESPACE__ . '\\', '', get_class( $this ) ); 24 25 // 'Core_Trac' => 'core' 26 $this->trac = strtolower( str_replace( '_Trac', '', $class ) ); 27 28 if ( ! isset( $this->ticket_username ) ) { 29 // 'Core_Trac' => 'Core Trac' 30 $this->ticket_username = str_replace( '_', ' ', $class ); 31 } 19 32 } 20 33 21 function get_username() { 22 return $this->username; 34 function get_commit_username() { 35 return $this->commit_username; 36 } 37 38 function get_ticket_username() { 39 return $this->ticket_username; 23 40 } 24 41 … … 57 74 } 58 75 59 function get_c hannels( $changed_files = null ) {60 $channels = (array) $this->c hannels;76 function get_commit_channels( $changed_files = null ) { 77 $channels = (array) $this->commit_channels; 61 78 62 if ( empty( $this->channel_matcher ) || empty( $changed_files ) ) { 79 if ( isset( $this->firehose_channel ) ) { 80 $channels[] = $this->firehose_channel; 81 } 82 83 if ( empty( $this->commit_path_filters ) || empty( $changed_files ) ) { 63 84 return $channels; 64 85 } 65 86 66 foreach ( $this->c hannel_matcheras $needle => $channels_to_add ) {87 foreach ( $this->commit_path_filters as $needle => $channels_to_add ) { 67 88 if ( $needle[0] === '#' ) { 68 89 // Append PCRE_MULTILINE so ^ and $ refer to individual lines. … … 74 95 } 75 96 } 97 76 98 return $channels; 77 99 } 100 101 function get_ticket_channels( $ticket = null ) { 102 $channels = (array) $this->ticket_channels; 103 104 if ( isset( $this->firehose_channel ) ) { 105 $channels[] = $this->firehose_channel; 106 } 107 108 if ( empty( $this->ticket_component_filters ) || empty( $ticket ) ) { 109 return $channels; 110 } 111 112 if ( isset( $ticket->component ) && isset( $this->ticket_component_filters[ $ticket->component ] ) ) { 113 $channels = array_merge( $channels, (array) $this->ticket_component_filters[ $ticket->component ] ); 114 } 115 116 if ( isset( $ticket->focuses ) ) { 117 foreach ( explode( ', ', $ticket->focuses ) as $focus ) { 118 if ( isset( $this->ticket_component_filters[ $focus ] ) ) { 119 $channels = array_merge( $channels, (array) $this->ticket_component_filters[ $focus ] ); 120 } 121 } 122 } 123 return $channels; 124 } 125 126 function get_firehose_channel() { 127 return $this->firehose_channel; 128 } 78 129 } 130
Note: See TracChangeset
for help on using the changeset viewer.