Skip to content

Commit

Permalink
Do not attempt to checkout a detached SHA on reclone
Browse files Browse the repository at this point in the history
  • Loading branch information
Cyberboss committed Nov 10, 2024
1 parent 2aa16e8 commit 08f0caf
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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);
}
}
}
}
4 changes: 2 additions & 2 deletions tests/Tgstation.Server.Tests/Live/Instance/RepositoryTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,6 @@ public async Task AbortLongCloneAndCloneSomethingQuick(Task<JobResponse> longClo
await ApiAssert.ThrowsException<ApiConflictException, RepositoryResponse>(() => 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);

Expand All @@ -127,6 +125,8 @@ public async Task AbortLongCloneAndCloneSomethingQuick(Task<JobResponse> 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))
Expand Down

0 comments on commit 08f0caf

Please sign in to comment.