Skip to content

Commit 0a4d437

Browse files
committed
Remove the need to specify folder, since it can be included in the repository URL by default
1 parent 1b1bb17 commit 0a4d437

File tree

2 files changed

+8
-17
lines changed

2 files changed

+8
-17
lines changed

class-phpcs-diff-svn.php

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,28 +7,23 @@ class PHPCS_Diff_SVN {
77
private $svn_password = ''; // @todo: add your SVN password here
88

99
// Used to store details about the repo the class was initialized with.
10-
public $repo; // Specific repository - eg.: plugin's name.
10+
public $repo; // repository's slug.
1111
public $repo_url; // SVN repository URL.
12-
public $folder = ''; // In case the repository has some other specific folders.
1312

14-
function __construct( $repo, $folder = false ) {
13+
function __construct( $repo ) {
1514

1615
$repo = sanitize_title( $repo );
1716

1817
switch ( $repo ) {
1918

2019
case 'hello-dolly':
21-
$this->repo_url = 'https://plugins.svn.wordpress.org/';
20+
$this->repo_url = 'https://plugins.svn.wordpress.org/hello-dolly';
2221
break;
2322

2423
# Add new repos here. See details at the top of this file.
2524
}
2625

2726
$this->repo = $repo;
28-
29-
if ( false !== $folder && 0 === validate_file( $folder ) ) {
30-
$this->folder = $folder;
31-
}
3227
}
3328

3429
public function get_diff( $end_revision, $start_revision = null, $options = array() ) {
@@ -58,7 +53,7 @@ public function get_diff( $end_revision, $start_revision = null, $options = arra
5853
$start_revision = 1;
5954
}
6055

61-
$repo_url = esc_url_raw( trailingslashit( $this->repo_url ) . trailingslashit( $this->repo ) . $this->folder );
56+
$repo_url = esc_url_raw( trailingslashit( $this->repo_url ) );
6257

6358
$diff = shell_exec(
6459
sprintf( 'svn diff %s --non-interactive --no-auth-cache --username %s --password %s -r %d:%d %s %s %s',
@@ -164,7 +159,7 @@ public static function parse_diff_for_info( $diff_file ){
164159

165160
public function run_phpcs_for_file_at_revision( $filename, $revision, $phpcs_command, $standards_location, $phpcs_standard ) {
166161
$command_string = sprintf( 'svn cat %s --non-interactive --no-auth-cache --username %s --password %s -r %d | %s --runtime-set installed_paths %s --standard=%s --stdin-path=%s',
167-
escapeshellarg( esc_url_raw( $this->repo_url . $filename ) ),
162+
escapeshellarg( esc_url_raw( trailingslashit( $this->repo_url ) . $filename ) ),
168163
escapeshellarg( $this->svn_username ),
169164
escapeshellarg( $this->svn_password ),
170165
absint( $revision ),

wp-cli-command.php

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class PHPCS_Diff_CLI_Command extends WP_CLI_Command {
4141
* wp phpcs-diff --repo="hello-dolly" --start_revision=99998 --end_revision=100000
4242
*
4343
* @subcommand phpcs-diff
44-
* @synopsis --repo=<repo> --start_revision=<start-revision> --end_revision=<end-revision> [--standard=<standard>] [--format=<format>] [--nocache] [--ignore-diff-too-big] [--excluded-exts=<excluded-exts>] [--folder=<folder>]
44+
* @synopsis --repo=<repo> --start_revision=<start-revision> --end_revision=<end-revision> [--standard=<standard>] [--format=<format>] [--nocache] [--ignore-diff-too-big] [--excluded-exts=<excluded-exts>]
4545
*/
4646
public function __invoke( $args, $assoc_args ) {
4747

@@ -58,14 +58,10 @@ public function __invoke( $args, $assoc_args ) {
5858
if ( true === array_key_exists( 'excluded-exts', $assoc_args ) && false === empty( $assoc_args['excluded-exts'] ) ) {
5959
$excluded_exts = array_map( 'sanitize_text_field', explode( ',', $assoc_args['excluded-exts'] ) );
6060
}
61-
$folder = false;
62-
if ( true === array_key_exists( 'folder', $assoc_args ) && false === empty( sanitize_text_field( $assoc_args['folder'] ) && 0 === validate_file( sanitize_text_field( $assoc_args['folder'] ) ) ) ) {
63-
$folder = sanitize_text_field( $assoc_args['folder'] );
64-
}
6561

6662
// @todo: replace SVN version control backend with any other parser you might want to use - eg.: git
6763
require_once( __DIR__ . 'class-phpcs-diff-svn.php' );
68-
$phpcs = new PHPCS_Diff( new PHPCS_Diff_SVN( $repo, $folder ) );
64+
$phpcs = new PHPCS_Diff( new PHPCS_Diff_SVN( $repo ) );
6965

7066
if ( true === array_key_exists( 'ignore-diff-too-big', $assoc_args ) ) {
7167
$phpcs->set_no_diff_too_big( true );
@@ -81,7 +77,7 @@ public function __invoke( $args, $assoc_args ) {
8177
if ( true === isset( $excluded_exts ) && false === empty( $excluded_exts ) && true === is_array( $excluded_exts ) ) {
8278
$phpcs->set_excluded_extensions( $excluded_exts );
8379
}
84-
$found_issues = $phpcs->run( $repo, $start_revision, $end_revision );
80+
$found_issues = $phpcs->run( $start_revision, $end_revision );
8581

8682
if ( is_wp_error( $found_issues ) ) {
8783
WP_CLI::error( $found_issues->get_error_message(), true );

0 commit comments

Comments
 (0)