Dereckson has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/245467

Change subject: Improved comments and code style issues
......................................................................

Improved comments and code style issues

We're introducing phpcs as a way to ensure the code quality of the
extension. This has raised some issues, and highlighted some others.

* Improved comments
* Split long wfShellExec calls into several lines

Change-Id: Idee10c70da54b08aeaa0b8ba5860820d802c48b7
---
M Git2Pages.body.php
M GitRepository.php
2 files changed, 26 insertions(+), 11 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Git2Pages 
refs/changes/67/245467/1

diff --git a/Git2Pages.body.php b/Git2Pages.body.php
index 1dc986f..b9e02b2 100644
--- a/Git2Pages.body.php
+++ b/Git2Pages.body.php
@@ -6,16 +6,17 @@
 class Git2PagesHooks {
 
        /**
-       * Sets the value of $wgGit2PagesDataDir
-       */
-
+        * Sets the value of $wgGit2PagesDataDir
+        **/
        public static function setGit2PagesDataDir() {
                global $wgGit2PagesDataDir;
                // Options default values
                $wgGit2PagesDataDir = sys_get_temp_dir();
        }
 
-
+       /**
+        * Registers the parser function hook
+        */
        public static function Git2PagesSetup( $parser ) {
                $parser->setFunctionHook( 'snippet', array( 'Git2PagesHooks', 
'PullContentFromRepo' ) );
                return true;
@@ -44,17 +45,17 @@
        /**
         * Checks if value is an int whether it is type string or int.
         *
-        * @param $mixed contains value to be checked
+        * @param mixed $mixed contains value to be checked
         * @return bool true if it is an int value, false otherwise
         */
        static function isint( $mixed ) {
-               return ( preg_match( '/^\d*$/' , $mixed ) == 1 );
+               return preg_match( '/^\d*$/', $mixed ) == 1;
        }
 
        /**
         * Pulls the content from a repository
         *
-        * @param $parser will contain an array of params. The first element is 
the Parser object. The rest of the elements will be the user input values that 
will be converted.
+        * @param array $parser Array, the first element a Parser instance, 
then the user input values
         */
        public static function PullContentFromRepo( $parser ) {
                global $wgGit2PagesDataDir;
diff --git a/GitRepository.php b/GitRepository.php
index f54904c..fbcd518 100644
--- a/GitRepository.php
+++ b/GitRepository.php
@@ -42,11 +42,17 @@
                $sparseCheckoutFile = '.git/info/sparse-checkout';
                if ( $file = file_get_contents( $gitFolder . 
DIRECTORY_SEPARATOR . $sparseCheckoutFile ) ) {
                        if ( strpos( $file, $checkoutItem ) === false ) {
-                               wfShellExec( 'echo ' . wfEscapeShellArg( 
$checkoutItem ) . ' >> ' . wfEscapeShellArg( $sparseCheckoutFile ) );
+                               wfShellExec(
+                                       'echo ' . wfEscapeShellArg( 
$checkoutItem ) .
+                                       ' >> ' . wfEscapeShellArg( 
$sparseCheckoutFile )
+                               );
                        }
                } else {
                        wfShellExec( 'touch ' . wfEscapeShellArg( 
$sparseCheckoutFile ) );
-                       wfShellExec( 'echo ' . wfEscapeShellArg( $checkoutItem 
) . ' >> ' . wfEscapeShellArg( $sparseCheckoutFile ) );
+                       wfShellExec(
+                               'echo ' . wfEscapeShellArg( $checkoutItem ) .
+                               ' >> ' . wfEscapeShellArg( $sparseCheckoutFile )
+                       );
                }
                wfShellExec( 'git read-tree -mu HEAD' );
                chdir( $oldDir );
@@ -67,7 +73,10 @@
                        wfShellExec( 'git remote add -f origin ' . 
wfEscapeShellArg( $url ) );
                        wfShellExec( 'git config core.sparsecheckout true' );
                        wfShellExec( 'touch ' . wfEscapeShellArg( 
$sparseCheckoutFile ) );
-                       wfShellExec( 'echo ' . wfEscapeShellArg( $checkoutItem 
) . ' >> ' . wfEscapeShellArg( $sparseCheckoutFile ) );
+                       wfShellExec(
+                               'echo ' . wfEscapeShellArg( $checkoutItem ) .
+                               ' >> ' . wfEscapeShellArg( $sparseCheckoutFile )
+                       );
                        wfShellExec( 'git pull ' . wfEscapeShellArg( $url ) . ' 
' . wfEscapeShellArg( $branch ) );
                        wfDebug( 'GitRepository: Sparse checkout subdirectory' 
);
                        chdir( $oldDir );
@@ -84,7 +93,12 @@
         * @param string $gitFolder is the Git repository in which the branch 
will be checked in
         */
        function GitCheckoutBranch( $branch, $gitFolder ) {
-               wfShellExec( 'git --git-dir=' . wfEscapeShellArg( $gitFolder ) 
. '/.git --work-tree=' . wfEscapeShellArg( $gitFolder ) . ' checkout ' . 
wfEscapeShellArg( $branch ) );
+               $folder = wfEscapeShellArg( $gitFolder );
+               wfShellExec(
+                       'git --git-dir=' . $folder . '/.git' .
+                       ' --work-tree=' . $folder . ' checkout ' .
+                       wfEscapeShellArg( $branch )
+               );
                wfDebug( 'GitRepository: Changed to branch ' . $branch );
        }
 

-- 
To view, visit https://gerrit.wikimedia.org/r/245467
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Idee10c70da54b08aeaa0b8ba5860820d802c48b7
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Git2Pages
Gerrit-Branch: master
Gerrit-Owner: Dereckson <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to