Skip to content

Commit c204035

Browse files
committed
Adding ability to pass options to the constructor
And fixing SVN path (double slash) for file in SVN command
1 parent 0a4d437 commit c204035

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

class-phpcs-diff-svn.php

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,13 @@ class PHPCS_Diff_SVN {
1010
public $repo; // repository's slug.
1111
public $repo_url; // SVN repository URL.
1212

13-
function __construct( $repo ) {
13+
function __construct( $repo, $options = array() ) {
14+
15+
if ( true === is_array( $options ) && false === empty( $options ) ) {
16+
foreach( $options as $option => $value ) {
17+
$this->$option = $value;
18+
}
19+
}
1420

1521
$repo = sanitize_title( $repo );
1622

@@ -158,8 +164,8 @@ public static function parse_diff_for_info( $diff_file ){
158164
}
159165

160166
public function run_phpcs_for_file_at_revision( $filename, $revision, $phpcs_command, $standards_location, $phpcs_standard ) {
161-
$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',
162-
escapeshellarg( esc_url_raw( trailingslashit( $this->repo_url ) . $filename ) ),
167+
$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',
168+
escapeshellarg( esc_url_raw( trailingslashit( $this->repo_url ) . ltrim( $filename, '/' ) ) ),
163169
escapeshellarg( $this->svn_username ),
164170
escapeshellarg( $this->svn_password ),
165171
absint( $revision ),
@@ -172,4 +178,4 @@ public function run_phpcs_for_file_at_revision( $filename, $revision, $phpcs_com
172178
return shell_exec( $command_string );
173179
}
174180

175-
}
181+
}

0 commit comments

Comments
 (0)