Changeset 10044 for sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/tools/class-svn.php
- Timestamp:
- 07/09/2020 07:35:02 AM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/tools/class-svn.php
r9025 r10044 8 8 */ 9 9 class SVN { 10 /** 11 * Get SVN info about a URL. 12 * 13 * @static 14 * 15 * @param string $url The URL of the svn repo. 16 * @param array $options Optional. A list of options to pass to SVN. Default: empty array. 17 * 18 * @return array { 19 * @type bool|array $result False on failure. Otherwise an associative array. 20 * @type bool|array $errors Whether any errors or warnings were encountered. 21 * } 22 */ 23 public static function info( $url, $options = array() ) { 24 $esc_url = escapeshellarg( $url ); 25 26 $options[] = 'non-interactive'; 27 if ( empty( $options['username'] ) ) { 28 $options['username'] = PLUGIN_SVN_MANAGEMENT_USER; 29 $options['password'] = PLUGIN_SVN_MANAGEMENT_PASS; 30 } 31 $esc_options = self::parse_esc_parameters( $options ); 32 33 $output = self::shell_exec( "svn info $esc_options $esc_url 2>&1" ); 34 if ( preg_match( '!URL: ' . untrailingslashit( $url ) . '\n!i', $output ) ) { 35 $lines = explode( "\n", $output ); 36 $result = array_filter( array_reduce( 37 $lines, 38 function( $carry, $item ) { 39 $pair = explode( ':', $item, 2 ); 40 if ( isset( $pair[1] ) ) { 41 $key = trim( $pair[0] ); 42 $carry[ $key ] = trim( $pair[1] ); 43 } else { 44 $carry[] = trim( $pair[0] ); 45 } 46 47 return $carry; 48 }, 49 array() 50 ) ); 51 $errors = false; 52 } else { 53 $result = false; 54 $errors = self::parse_svn_errors( $output ); 55 } 56 57 return compact( 'result', 'errors' ); 58 } 10 59 11 60 /**
Note: See TracChangeset
for help on using the changeset viewer.