From 4c9368b056de7d5d1f9699a608e23e7cc6e68ca3 Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Wed, 31 May 2023 10:57:00 +0200 Subject: [PATCH] wait #5972 @0.25 --- src/CommandLine/Git.php | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/src/CommandLine/Git.php b/src/CommandLine/Git.php index 1a18e6e..e907454 100644 --- a/src/CommandLine/Git.php +++ b/src/CommandLine/Git.php @@ -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; } -- 2.39.5