]> _ Git - cubist_util.git/commitdiff
wait #5972 @0.25
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 31 May 2023 08:57:00 +0000 (10:57 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 31 May 2023 08:57:00 +0000 (10:57 +0200)
src/CommandLine/Git.php

index 1a18e6e4780907be30de21df7ed96fa8472a7bf5..e9074549953494e3c41620bfd614e12a642caf53 100644 (file)
@@ -8,19 +8,19 @@ class Git extends CommandLine
 {
     protected $_repos;
 
-    public static function executeCommands($repos, $commands)
+    public static function executeCommands($repos, $commands, $debug = false)
     {
         $res = [];
         foreach ($commands as $command) {
-            $res[] = self::executeCommand($repos, $command);
+            $res[] = self::executeCommand($repos, $command, $debug);
         }
         return $res;
     }
 
-    public static function executeCommand($repos, $command)
+    public static function executeCommand($repos, $command, $debug = false)
     {
         $git = new self($repos);
-        return $git->executeCmd($command);
+        return $git->executeCmd($command, $debug);
     }
 
     public function __construct($repos, $output = null, $error = true)
@@ -30,10 +30,13 @@ class Git extends CommandLine
         $this->cd($repos);
     }
 
-    public function executeCmd($cmd)
+    public function executeCmd($cmd, $debug = false)
     {
         $this->setManualArg($cmd);
         $this->execute();
+        if ($debug) {
+            $this->debug();
+        }
         return $this->getOutput();
     }
 
@@ -63,12 +66,16 @@ class Git extends CommandLine
      * @param $repos
      * @return bool
      */
-    public static function pull($repos, $restoreMtime = false)
+    public static function pull($repos, $rebase = false, $restoreMtime = false, $debug = false)
     {
-        $res=self::executeCommand($repos,'pull');
+        $args = '';
+        if ($rebase) {
+            $args .= '--rebase';
+        }
+        $res = self::executeCommand($repos, 'pull ' . $args, $debug);
         $changes = (trim($res) !== 'Already up to date.');
-        if($restoreMtime && $changes){
-            self::executeCommand($repos,'restore-mtime');
+        if ($restoreMtime && $changes) {
+            self::executeCommand($repos, 'restore-mtime', $debug);
         }
         return $changes;
     }