Skip to content

Commit

Permalink
Merge pull request #177 from fortrabbit/fix/git-output
Browse files Browse the repository at this point in the history
WIP: Stream 'git push' output
  • Loading branch information
Oliver Stark authored Oct 13, 2023
2 parents 4293704 + 6d32aaf commit 20530d0
Show file tree
Hide file tree
Showing 5 changed files with 213 additions and 175 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Changelog

## 2.4.3 - 2023-10-13
- Show git/composer output when using `copy/code/up`

## 2.4.2 - 2023-07-10
- SSH check fails when no keys are SSH configured
- `--interactive=0` works with all/up and all/down commands
Expand Down
16 changes: 8 additions & 8 deletions src/Actions/CodeUpAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,15 +128,15 @@ public function run(?string $stage = null): int
return ExitCode::UNSPECIFIED_ERROR;
}

try {
$this->section("git push ({$msg})");
$git->push($upstream, "{$branch}:master");
} catch (GitException $gitException) {
$lines = count(explode(PHP_EOL, $gitException->getMessage()));
$this->output->write(str_repeat("\x1B[1A\x1B[2K", $lines));
$this->errorBlock('Ooops.');
$this->output->write("<fg=red>{$gitException->getMessage()}</>");
$this->section("git push ({$msg})");

$process = $git->push($upstream, "{$branch}:master");

foreach ($process as $type => $data) {
$this->output->write($data);
}

if (! $process->isSuccessful()) {
return ExitCode::UNSPECIFIED_ERROR;
}

Expand Down
5 changes: 3 additions & 2 deletions src/Services/Git.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use fortrabbit\Copy\Services\Git\Client;
use fortrabbit\Copy\Services\Git\GitonomyClient;
use InvalidArgumentException;
use Symfony\Component\Process\Process;

/**
* Git Service
Expand Down Expand Up @@ -51,9 +52,9 @@ public static function fromClone(
return new self($client);
}

public function push(string $upstream, string $branch = 'master'): string
public function push(string $upstream, string $branch = 'master'): Process
{
return $this->gitClient->push($upstream, $branch);
return $this->gitClient->pushAndStream($upstream, $branch);
}

public function pull(string $upstream, string $branch = 'master'): string
Expand Down
6 changes: 5 additions & 1 deletion src/Services/Git/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace fortrabbit\Copy\Services\Git;

use Symfony\Component\Process\Process;

interface Client
{
public function clone(
Expand All @@ -12,7 +14,9 @@ public function clone(

public function push(string $upstream, string $branch = 'master'): string;

public function pull(string $upstream, string $branch = 'master'): string;
public function pushAndStream(string $upstream, string $branch = 'master'): Process;

public function pull(string $upstream, string $branch = 'master'): string;

public function getLocalHead(): ?string;

Expand Down
Loading

0 comments on commit 20530d0

Please sign in to comment.