Skip to content

Commit

Permalink
Merge pull request #1991 from tgstation/RepoRecloneFix
Browse files Browse the repository at this point in the history
Do not attempt to checkout a detached SHA on reclone
  • Loading branch information
Cyberboss authored Nov 10, 2024
2 parents 2aa16e8 + 08f0caf commit c500ec4
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 c500ec4

Please sign in to comment.