コード例 #1
0
ファイル: GitProcess.php プロジェクト: shirone/git-wrapper
 /**
  * Constructs a GitProcess object.
  *
  * @param \GitWrapper\GitWrapper $git
  * @param \GitWrapper\GitCommand $command
  * @param string|null $cwd
  */
 public function __construct(GitWrapper $git, GitCommand $command, $cwd = null)
 {
     $this->git = $git;
     $this->command = $command;
     // Build the command line options, flags, and arguments.
     $binary = ProcessUtils::escapeArgument($git->getGitBinary());
     $commandLine = rtrim($binary . ' ' . $command->getCommandLine());
     // Resolve the working directory of the Git process. Use the directory
     // in the command object if it exists.
     if (null === $cwd) {
         if (null !== ($directory = $command->getDirectory())) {
             if (!($cwd = realpath($directory))) {
                 throw new GitException('Path to working directory could not be resolved: ' . $directory);
             }
         }
     }
     // Finalize the environment variables, an empty array is converted
     // to null which enherits the environment of the PHP process.
     $env = $git->getEnvVars();
     if (!$env) {
         $env = null;
     }
     parent::__construct($commandLine, $cwd, $env, null, $git->getTimeout(), $git->getProcOptions());
 }