Changeset 14314 for sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/tools/class-svn.php
- Timestamp:
- 12/18/2024 06:25:51 AM (22 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/tools/class-svn.php
r14313 r14314 446 446 */ 447 447 public static function rename( $from, $to, $options = array() ) { 448 return SVN::_copy_rename_helper( 'mv', $from, $to, $options ); 449 } 450 451 /** 452 * Copy a file or folder in a SVN checkout. 453 * 454 * @static 455 * 456 * @param string $source The path of the file to copy. May be a URL. 457 * @param string $destination The path to copy the file to. May be a URL. 458 * @param array $options Optional. A list of options to pass to SVN. Default: empty array. 459 * @return array { 460 * @type bool $result The result of the operation. 461 * @type int $revision The revision. 462 * @type false|array $errors Whether any errors or warnings were encountered. 463 * } 464 */ 465 public static function copy( $from, $to, $options = array() ) { 466 return SVN::_copy_rename_helper( 'cp', $from, $to, $options = array() ); 467 } 468 469 /** 470 * Helper function for copy and rename operations. 471 * 472 * @static 473 * @param string $svn_op The SVN operation to perform. 'cp' or 'mv'. 474 * @param string $from The path of the SVN folder to rename. May be a URL. 475 * @param string $to The new path of the SVN folder. May be a URL. 476 * @param array $options Optional. A list of options to pass to SVN. Default: empty array. 477 * @return array { 478 * @type bool $result The result of the operation. 479 * @type int $revision The revision. 480 * @type false|array $errors Whether any errors or warnings were encountered. 481 * } 482 */ 483 public static function _copy_rename_helper( $svn_op, $from, $to, $options = array() ) { 448 484 $options[] = 'non-interactive'; 449 485 $is_url = ( preg_match( '#https?://#i', $from ) && preg_match( '#https?://#i', $to ) ); … … 452 488 // Set the message if not provided. 453 489 if ( ! isset( $options['message'] ) && ! isset( $options['m'] ) ) { 454 $options['message'] = sprintf( "Rename %s to %s.", basename( $from ), basename( $to ) ); 490 $options['message'] = sprintf( 491 "%s %s to %s.", 492 'mv' === $svn_op ? 'Rename' : 'Copy', 493 basename( $from ), 494 basename( $to ) 495 ); 455 496 } 456 497 … … 463 504 $esc_options = self::parse_esc_parameters( $options ); 464 505 506 $esc_op = escapeshellarg( $svn_op ); 465 507 $esc_from = escapeshellarg( $from ); 466 508 $esc_to = escapeshellarg( $to ); 467 509 468 $output = self::shell_exec( "svn mv$esc_from $esc_to $esc_options 2>&1" );510 $output = self::shell_exec( "svn $esc_op $esc_from $esc_to $esc_options 2>&1" ); 469 511 if ( $is_url && preg_match( '/Committed revision (?P<revision>\d+)[.]/i', $output, $m ) ) { 470 512 $revision = (int) $m['revision'];
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)