mirror of
https://github.com/vitodeploy/vito.git
synced 2025-04-20 02:11:36 +00:00
fix: ensure newly created branches are available for switching (#511)
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.
This commit is contained in:
parent
1a5cf4c57a
commit
e52903c649
@ -16,6 +16,7 @@ class UpdateBranch
|
|||||||
public function update(Site $site, array $input): void
|
public function update(Site $site, array $input): void
|
||||||
{
|
{
|
||||||
$site->branch = $input['branch'];
|
$site->branch = $input['branch'];
|
||||||
|
app(Git::class)->fetchOrigin($site);
|
||||||
app(Git::class)->checkout($site);
|
app(Git::class)->checkout($site);
|
||||||
$site->save();
|
$site->save();
|
||||||
}
|
}
|
||||||
|
@ -39,4 +39,18 @@ public function checkout(Site $site): void
|
|||||||
$site->id
|
$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
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
7
resources/views/ssh/git/fetch-origin.blade.php
Normal file
7
resources/views/ssh/git/fetch-origin.blade.php
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
if ! cd {{ $path }}; then
|
||||||
|
echo 'VITO_SSH_ERROR' && exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ! git fetch origin; then
|
||||||
|
echo 'VITO_SSH_ERROR' && exit 1
|
||||||
|
fi
|
Loading…
x
Reference in New Issue
Block a user