mirror of
https://github.com/tiennm99/coolify.git
synced 2026-10-14 02:15:51 +00:00
fix: application rollback uses correct commit sha
- setGitImportSettings() now accepts optional $commit parameter - Uses passed commit over application's git_commit_sha (typically HEAD) - Fixes rollback deploying latest instead of selected commit - Also fixes shallow clone "bad object" error on rollback Fixes #8445
This commit is contained in:
1 parent
021605dbf0
commit
1935403053
2 files changed
+65
-8
No files matched your search
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
use App\Models\Application;
|
||||
use App\Models\ApplicationSetting;
|
||||
use App\Models\Environment;
|
||||
use App\Models\Project;
|
||||
use App\Models\Server;
|
||||
use App\Models\Team;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
|
||||
uses(RefreshDatabase::class);
|
||||
|
||||
describe('Application Rollback', function () {
|
||||
test('setGitImportSettings uses passed commit instead of application git_commit_sha', function () {
|
||||
$team = Team::factory()->create();
|
||||
$project = Project::create([
|
||||
'team_id' => $team->id,
|
||||
'name' => 'Test Project',
|
||||
'uuid' => (string) str()->uuid(),
|
||||
]);
|
||||
$environment = Environment::create([
|
||||
'project_id' => $project->id,
|
||||
'name' => 'rollback-test-env',
|
||||
'uuid' => (string) str()->uuid(),
|
||||
]);
|
||||
$server = Server::factory()->create(['team_id' => $team->id]);
|
||||
|
||||
// Create application with git_commit_sha = 'HEAD' (default - use latest)
|
||||
$application = Application::factory()->create([
|
||||
'environment_id' => $environment->id,
|
||||
'destination_id' => $server->id,
|
||||
'git_commit_sha' => 'HEAD',
|
||||
]);
|
||||
|
||||
// Create application settings
|
||||
ApplicationSetting::create([
|
||||
'application_id' => $application->id,
|
||||
'is_git_shallow_clone_enabled' => false,
|
||||
]);
|
||||
|
||||
// The rollback commit SHA we want to deploy
|
||||
$rollbackCommit = 'abc123def456';
|
||||
|
||||
// This should use the passed commit, not the application's git_commit_sha
|
||||
$result = $application->setGitImportSettings(
|
||||
deployment_uuid: 'test-uuid',
|
||||
git_clone_command: 'git clone',
|
||||
public: true,
|
||||
commit: $rollbackCommit
|
||||
);
|
||||
|
||||
// Assert: The command should checkout the ROLLBACK commit
|
||||
expect($result)->toContain($rollbackCommit);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user