mirror of
https://github.com/vitodeploy/vito.git
synced 2025-04-21 19:01:37 +00:00
Fixed an issue where the "Change Branch" button didn't work when switching to a newly created remote branch after initially cloning the repository. Added `git fetch origin` to update branch references before switching.
57 lines
1.3 KiB
PHP
57 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace App\SSH\Git;
|
|
|
|
use App\Exceptions\SSHError;
|
|
use App\Models\Site;
|
|
|
|
class Git
|
|
{
|
|
/**
|
|
* @throws SSHError
|
|
*/
|
|
public function clone(Site $site): void
|
|
{
|
|
$site->server->ssh($site->user)->exec(
|
|
view('ssh.git.clone', [
|
|
'host' => str($site->getFullRepositoryUrl())->after('@')->before('-'),
|
|
'repo' => $site->getFullRepositoryUrl(),
|
|
'path' => $site->path,
|
|
'branch' => $site->branch,
|
|
'key' => $site->getSshKeyName(),
|
|
]),
|
|
'clone-repository',
|
|
$site->id
|
|
);
|
|
}
|
|
|
|
/**
|
|
* @throws SSHError
|
|
*/
|
|
public function checkout(Site $site): void
|
|
{
|
|
$site->server->ssh($site->user)->exec(
|
|
view('ssh.git.checkout', [
|
|
'path' => $site->path,
|
|
'branch' => $site->branch,
|
|
]),
|
|
'checkout-branch',
|
|
$site->id
|
|
);
|
|
}
|
|
|
|
/**
|
|
* @throws SSHError
|
|
*/
|
|
public function fetchOrigin(Site $site): void
|
|
{
|
|
$site->server->ssh($site->user)->exec(
|
|
view('ssh.git.fetch-origin', [
|
|
'path' => $site->path,
|
|
]),
|
|
'fetch-origin',
|
|
$site->id
|
|
);
|
|
}
|
|
}
|