From 08f0cafb556202e78739b2cdabbb0609f767db65 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sun, 27 Oct 2024 11:56:05 -0400 Subject: [PATCH] Do not attempt to checkout a detached SHA on reclone --- .../Repository/RepositoryUpdateService.cs | 18 ++---------------- .../Live/Instance/RepositoryTest.cs | 4 ++-- 2 files changed, 4 insertions(+), 18 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Repository/RepositoryUpdateService.cs b/src/Tgstation.Server.Host/Components/Repository/RepositoryUpdateService.cs index 341db7f617..cb15e878f1 100644 --- a/src/Tgstation.Server.Host/Components/Repository/RepositoryUpdateService.cs +++ b/src/Tgstation.Server.Host/Components/Repository/RepositoryUpdateService.cs @@ -642,11 +642,10 @@ public async ValueTask RepositoryRecloneJob( await deleteTask; } - IRepository newRepo; try { - using var cloneReporter = progressReporter.CreateSection("Cloning New Repository", 0.8); - newRepo = await instance.RepositoryManager.CloneRepository( + using var cloneReporter = progressReporter.CreateSection("Cloning New Repository", 0.9); + using var newRepo = await instance.RepositoryManager.CloneRepository( origin, oldReference, currentModel.AccessUser, @@ -671,19 +670,6 @@ await databaseContextFactory.UseContextTaskReturn(context => throw; } - - using (newRepo) - using (var checkoutReporter = progressReporter.CreateSection("Checking out previous Detached Commit", 0.1)) - { - await newRepo.CheckoutObject( - oldSha, - currentModel.AccessUser, - currentModel.AccessToken, - false, - oldReference != null, - checkoutReporter, - cancellationToken); - } } } } diff --git a/tests/Tgstation.Server.Tests/Live/Instance/RepositoryTest.cs b/tests/Tgstation.Server.Tests/Live/Instance/RepositoryTest.cs index 4179a82cc1..f5599d88c9 100644 --- a/tests/Tgstation.Server.Tests/Live/Instance/RepositoryTest.cs +++ b/tests/Tgstation.Server.Tests/Live/Instance/RepositoryTest.cs @@ -116,8 +116,6 @@ public async Task AbortLongCloneAndCloneSomethingQuick(Task longClo await ApiAssert.ThrowsException(() => Checkout(new RepositoryUpdateRequest { Reference = "master", CheckoutSha = "286bb75" }, false, false, cancellationToken), ErrorCode.RepoMismatchShaAndReference); var updated = await Checkout(new RepositoryUpdateRequest { CheckoutSha = "286bb75" }, false, false, cancellationToken); - await RecloneTest(cancellationToken); - // Fake SHA updated = await Checkout(new RepositoryUpdateRequest { CheckoutSha = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" }, true, false, cancellationToken); @@ -127,6 +125,8 @@ public async Task AbortLongCloneAndCloneSomethingQuick(Task longClo // Back updated = await Checkout(new RepositoryUpdateRequest { Reference = "master" }, false, true, cancellationToken); + await RecloneTest(cancellationToken); + // enable the good shit if possible if (!String.IsNullOrWhiteSpace(Environment.GetEnvironmentVariable("TGS_TEST_GITHUB_TOKEN")) && !(Boolean.TryParse(Environment.GetEnvironmentVariable("TGS_TEST_OD_EXCLUSIVE"), out var odExclusive) && odExclusive))