Changeset 3370
- Timestamp:
- 06/15/2016 03:53:51 AM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/tools/class-svn.php
r3291 r3370 115 115 return $files; 116 116 } 117 } 118 119 /** 120 * Fetch SVN revisions for a given revision or range of revisions. 121 * 122 * @param string $url The URL to fetch. 123 * @param string|array $revision The revision to get information about. Default HEAD. 124 * @param array $options A list of options to pass to SVN. Optional. 125 * 126 * @return array { 127 * @type array|false $errors Whether any errors or warnings were encountered. 128 * @type array $log The SVN log data struct. 129 * } 130 */ 131 public static function log( $url, $revision = 'HEAD', $options = array() ) { 132 $options[] = 'non-interactive'; 133 $options[] = 'verbose'; 134 $options[] = 'xml'; 135 $options['revision'] = is_array( $revision ) ? "{$revision[0]}:{$revision[1]}" : $revision; 136 $esc_options = self::parse_esc_parameters( $options ); 137 138 $esc_url = escapeshellarg( $url ); 139 140 $output = self::shell_exec( "svn log $esc_options $esc_url 2>&1" ); 141 142 $errors = self::parse_svn_errors( $output ); 143 144 $log = array(); 145 146 // We use funky string mangling here to extract the XML as it may have been truncated by a SVN error, or suffixed by a SVN warning 147 $xml = substr( $output, $start = stripos( $output, '<?xml' ), $end = ( strripos( $output, '</log>' ) - $start + 6 ) ); 148 if ( $xml && false !== $start && false !== $end ) { 149 150 $user_errors = libxml_use_internal_errors( true ); 151 $simple_xml = simplexml_load_string( $xml ); 152 libxml_use_internal_errors( $user_errors ); 153 154 if ( ! $simple_xml ) { 155 $errors[] = "SimpleXML failed to parse input"; 156 } else { 157 foreach ( $simple_xml->logentry as $entry ) { 158 $revision = (int) $entry->attributes()['revision']; 159 $paths = array(); 160 foreach ( $entry->paths->children() as $p ) { 161 $paths[] = (string) $p; 162 } 163 164 $log[ $revision ] = array( 165 'revision' => $revision, 166 'author' => (string) $entry->author, 167 'date' => strtotime( (string) $entry->date ), 168 'paths' => $paths, 169 'message' => (string) $entry->msg, 170 ); 171 } 172 } 173 } 174 175 return compact( 'log', 'errors' ); 117 176 } 118 177
Note: See TracChangeset
for help on using the changeset viewer.