mirror of
https://github.com/tgstation/tgstation-server.git
synced 2026-08-22 20:47:28 +01:00
Fix NonFastForwardException in Repository.CommittishIsParent
This commit is contained in:
@@ -800,21 +800,32 @@ namespace Tgstation.Server.Host.Components.Repository
|
||||
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
var startSha = Head;
|
||||
var mergeResult = libGitRepo.Merge(
|
||||
targetCommit,
|
||||
new Signature(
|
||||
DefaultCommitterName,
|
||||
DefaultCommitterEmail,
|
||||
DateTimeOffset.UtcNow),
|
||||
new MergeOptions
|
||||
{
|
||||
FastForwardStrategy = FastForwardStrategy.FastForwardOnly,
|
||||
FailOnConflict = true,
|
||||
});
|
||||
logger.LogTrace("Testing if {committish} is a parent of {startSha}...", committish, startSha);
|
||||
MergeResult mergeResult;
|
||||
try
|
||||
{
|
||||
mergeResult = libGitRepo.Merge(
|
||||
targetCommit,
|
||||
new Signature(
|
||||
DefaultCommitterName,
|
||||
DefaultCommitterEmail,
|
||||
DateTimeOffset.UtcNow),
|
||||
new MergeOptions
|
||||
{
|
||||
FastForwardStrategy = FastForwardStrategy.FastForwardOnly,
|
||||
FailOnConflict = true,
|
||||
});
|
||||
}
|
||||
catch (NonFastForwardException ex)
|
||||
{
|
||||
logger.LogTrace(ex, "{committish} is not a parent of {startSha}", committish, startSha);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (mergeResult.Status == MergeStatus.UpToDate)
|
||||
return true;
|
||||
|
||||
logger.LogTrace("{committish} is not a parent of {startSha} ({mergeStatus}). Moving back...", committish, startSha, mergeResult.Status);
|
||||
commands.Checkout(
|
||||
libGitRepo,
|
||||
new CheckoutOptions
|
||||
|
||||
Reference in New Issue
Block a user