Exemplo n.º 1
0
 public function run(Directory $workingDirectory, Argument ...$arguments) : Result
 {
     $descriptorSpec = [['pipe', 'r'], ['pipe', 'w'], ['pipe', 'w']];
     $process = proc_open($this->buildCommand(...$arguments), $descriptorSpec, $pipes, $workingDirectory->getPath());
     $stdOut = stream_get_contents($pipes[1]);
     $stdErr = stream_get_contents($pipes[2]);
     foreach ($pipes as $pipe) {
         fclose($pipe);
     }
     return new Result(proc_close($process), $stdOut, $stdErr);
 }
Exemplo n.º 2
0
 public function testCreateThrowsWhenTheDirectoryCouldNotBeCreated()
 {
     if (strncasecmp(PHP_OS, 'WIN', 3) == 0) {
         $this->markTestSkipped('Windows does not support POSIX permissions.');
         return;
     }
     $this->markTestSkipped('Is there any sane way to test this?');
     return;
     $newDirectory = DATA_DIR . '/new-directory';
     Directory::create($newDirectory, 0444);
     $this->expectException(PermissionDeniedException::class);
     Directory::create($newDirectory . '/foobar');
     chmod($newDirectory, 0770);
     rmdir($newDirectory . '/foobar');
     rmdir($newDirectory);
 }
<?php

namespace Gitilicious\GitClient;

use Gitilicious\GitClient\Cli\Client as CliClient;
use Gitilicious\GitClient\Cli\Input\Binary;
use Gitilicious\GitClient\FileSystem\Directory;
use Gitilicious\GitClient\Git\Author;
use Gitilicious\GitClient\Git\Repository;
use Gitilicious\GitClient\FileSystem\File;
require_once __DIR__ . '/../vendor/autoload.php';
$client = new Client(new CliClient(new Binary('/usr/bin/git')));
$bareRepository = Repository::createBare($client, Directory::create('/var/git/bare'), 'Gitilicious.git');
$workRepository = $bareRepository->clone(Directory::create('/var/git/work'), 'Gitilicious');
$readme = File::create($workRepository->getPath() . '/README.md', "# My awesome repo\n");
$workRepository->add($readme);
$workRepository->commit(new Author('Git User', '*****@*****.**'), 'Added readme');
$workRepository->push();