Factor out command creation from execution
Factor out command creation from execution

--- a/include/git/GitExe.class.php
+++ b/include/git/GitExe.class.php
@@ -97,21 +97,37 @@
 	 */
 	public function Execute($command, $args)
 	{
+		$fullCommand = $this->CreateCommand($command, $args);
+
+		GitPHP_Log::GetInstance()->Log('Begin executing "' . $fullCommand . '"');
+
+		$ret = shell_exec($fullCommand);
+
+		GitPHP_Log::GetInstance()->Log('Finish executing "' . $fullCommand . '"' .
+			"\nwith result: " . $ret);
+
+		return $ret;
+	}
+
+	/**
+	 * BuildCommand
+	 *
+	 * Creates a command
+	 *
+	 * @access protected
+	 *
+	 * @param string $command the command to execute
+	 * @param array $args arguments
+	 * @return string result of command
+	 */
+	protected function CreateCommand($command, $args)
+	{
 		$gitDir = '';
 		if ($this->project) {
 			$gitDir = '--git-dir=' . $this->project->GetPath();
 		}
 		
-		$fullCommand = $this->binary . ' ' . $gitDir . ' ' . $command . ' ' . implode(' ', $args);
-
-		GitPHP_Log::GetInstance()->Log('Begin executing "' . $fullCommand . '"');
-
-		$ret = shell_exec($fullCommand);
-
-		GitPHP_Log::GetInstance()->Log('Finish executing "' . $fullCommand . '"' .
-			"\nwith result: " . $ret);
-
-		return $ret;
+		return $this->binary . ' ' . $gitDir . ' ' . $command . ' ' . implode(' ', $args);
 	}
 
 	/**

comments