diff --git a/src/Tgstation.Server.Host/Components/Events/EventType.cs b/src/Tgstation.Server.Host/Components/Events/EventType.cs
index dabb822de7..5de479b2a6 100644
--- a/src/Tgstation.Server.Host/Components/Events/EventType.cs
+++ b/src/Tgstation.Server.Host/Components/Events/EventType.cs
@@ -32,6 +32,7 @@ namespace Tgstation.Server.Host.Components.Events
///
/// Parameters: Absolute path to repository root
///
+ /// Changes made to the repository during this event will be pushed to the tracked branch if no test merges are present.
[EventScript("PreSynchronize")]
RepoPreSynchronize,
diff --git a/src/Tgstation.Server.Host/Components/Instance.cs b/src/Tgstation.Server.Host/Components/Instance.cs
index 1bbc2d6975..8a10a76828 100644
--- a/src/Tgstation.Server.Host/Components/Instance.cs
+++ b/src/Tgstation.Server.Host/Components/Instance.cs
@@ -152,6 +152,16 @@ namespace Tgstation.Server.Host.Components
}
}
+ ///
+ /// The for updating the repository.
+ ///
+ /// The for the .
+ /// The for the .
+ /// The being run.
+ /// The progress reporter action for the .
+ /// The for the operation.
+ /// A representing the running operation.
+#pragma warning disable CA1502 // Cyclomatic complexity
Task RepositoryAutoUpdateJob(
IInstanceCore core,
IDatabaseContextFactory databaseContextFactory,
@@ -321,7 +331,7 @@ namespace Tgstation.Server.Host.Components
}
// synch if necessary
- if (repositorySettings.AutoUpdatesSynchronize.Value && startSha != repo.Head)
+ if (repositorySettings.AutoUpdatesSynchronize.Value && startSha != repo.Head && (shouldSyncTracked || repositorySettings.PushTestMergeCommits.Value))
{
var pushedOrigin = await repo.Sychronize(
repositorySettings.AccessUser,
@@ -350,6 +360,7 @@ namespace Tgstation.Server.Host.Components
progressReporter(5 * ProgressStep);
});
+#pragma warning restore CA1502 // Cyclomatic complexity
///
/// Pull the repository and compile for every set of given
diff --git a/src/Tgstation.Server.Host/Components/Repository/Repository.cs b/src/Tgstation.Server.Host/Components/Repository/Repository.cs
index 89c958eb70..c4f9eaaea9 100644
--- a/src/Tgstation.Server.Host/Components/Repository/Repository.cs
+++ b/src/Tgstation.Server.Host/Components/Repository/Repository.cs
@@ -610,7 +610,14 @@ namespace Tgstation.Server.Host.Components.Repository
}
///
- public async Task Sychronize(string username, string password, string committerName, string committerEmail, Action progressReporter, bool synchronizeTrackedBranch, CancellationToken cancellationToken)
+ public async Task Sychronize(
+ string username,
+ string password,
+ string committerName,
+ string committerEmail,
+ Action progressReporter,
+ bool synchronizeTrackedBranch,
+ CancellationToken cancellationToken)
{
if (committerName == null)
throw new ArgumentNullException(nameof(committerName));
@@ -659,12 +666,12 @@ namespace Tgstation.Server.Host.Components.Repository
logger.LogTrace("Resetting and cleaning untracked files...");
await Task.Factory.StartNew(() =>
{
- libGitRepo.RemoveUntrackedFiles();
- cancellationToken.ThrowIfCancellationRequested();
libGitRepo.Reset(ResetMode.Hard, libGitRepo.Head.Tip, new CheckoutOptions
{
OnCheckoutProgress = CheckoutProgressHandler(progress => progressReporter(progress / 10))
});
+ cancellationToken.ThrowIfCancellationRequested();
+ libGitRepo.RemoveUntrackedFiles();
}, cancellationToken, DefaultIOManager.BlockingTaskCreationOptions, TaskScheduler.Current).ConfigureAwait(false);
}
diff --git a/src/Tgstation.Server.Host/Controllers/RepositoryController.cs b/src/Tgstation.Server.Host/Controllers/RepositoryController.cs
index 1114813a45..b342d9e1ee 100644
--- a/src/Tgstation.Server.Host/Controllers/RepositoryController.cs
+++ b/src/Tgstation.Server.Host/Controllers/RepositoryController.cs
@@ -586,7 +586,15 @@ namespace Tgstation.Server.Host.Controllers
await UpdateRevInfo().ConfigureAwait(false);
if (fastForward.Value)
{
- await repo.Sychronize(currentModel.AccessUser, currentModel.AccessToken, currentModel.CommitterName, currentModel.CommitterEmail, NextProgressReporter(), true, ct).ConfigureAwait(false);
+ await repo.Sychronize(
+ currentModel.AccessUser,
+ currentModel.AccessToken,
+ currentModel.CommitterName,
+ currentModel.CommitterEmail,
+ NextProgressReporter(),
+ true,
+ ct)
+ .ConfigureAwait(false);
postUpdateSha = repo.Head;
}
else
@@ -622,7 +630,15 @@ namespace Tgstation.Server.Host.Controllers
if (!repo.Tracking)
throw new JobException(ErrorCode.RepoReferenceNotTracking);
await repo.ResetToOrigin(NextProgressReporter(), ct).ConfigureAwait(false);
- await repo.Sychronize(currentModel.AccessUser, currentModel.AccessToken, currentModel.CommitterName, currentModel.CommitterEmail, NextProgressReporter(), true, ct).ConfigureAwait(false);
+ await repo.Sychronize(
+ currentModel.AccessUser,
+ currentModel.AccessToken,
+ currentModel.CommitterName,
+ currentModel.CommitterEmail,
+ NextProgressReporter(),
+ true,
+ ct)
+ .ConfigureAwait(false);
await CallLoadRevInfo().ConfigureAwait(false);
// repo head is on origin so force this
@@ -836,9 +852,17 @@ namespace Tgstation.Server.Host.Controllers
}
var currentHead = repo.Head;
- if (startSha != currentHead || (postUpdateSha != null && postUpdateSha != currentHead))
+ if (currentModel.PushTestMergeCommits.Value && (startSha != currentHead || (postUpdateSha != null && postUpdateSha != currentHead)))
{
- await repo.Sychronize(currentModel.AccessUser, currentModel.AccessToken, currentModel.CommitterName, currentModel.CommitterEmail, NextProgressReporter(), false, ct).ConfigureAwait(false);
+ await repo.Sychronize(
+ currentModel.AccessUser,
+ currentModel.AccessToken,
+ currentModel.CommitterName,
+ currentModel.CommitterEmail,
+ NextProgressReporter(),
+ false,
+ ct)
+ .ConfigureAwait(false);
await UpdateRevInfo().ConfigureAwait(false);
}
diff --git a/src/Tgstation.Server.Host/Jobs/IJobManager.cs b/src/Tgstation.Server.Host/Jobs/IJobManager.cs
index 567d622d40..ba72d618d0 100644
--- a/src/Tgstation.Server.Host/Jobs/IJobManager.cs
+++ b/src/Tgstation.Server.Host/Jobs/IJobManager.cs
@@ -34,9 +34,7 @@ namespace Tgstation.Server.Host.Jobs
/// A that will cancel the
/// The for the operation
/// A representing the
-#pragma warning disable CA1068 // CancellationToken parameters must come last https://github.com/dotnet/roslyn-analyzers/issues/1816
Task WaitForJobCompletion(Job job, User canceller, CancellationToken jobCancellationToken, CancellationToken cancellationToken);
-#pragma warning restore CA1068 // CancellationToken parameters must come last
///
/// Cancels a give