From 6d0006f3606d152078883f6110d63867c0869c73 Mon Sep 17 00:00:00 2001 From: Cyberboss Date: Tue, 18 Sep 2018 17:25:34 -0400 Subject: [PATCH 1/3] Configure committer name and email in local repository settings before synchronization script --- .../Components/Repository/IRepository.cs | 4 +++- .../Components/Repository/Repository.cs | 12 +++++++++++- .../Controllers/RepositoryController.cs | 6 +++--- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Repository/IRepository.cs b/src/Tgstation.Server.Host/Components/Repository/IRepository.cs index 244ef15f91..5cdd2e08ea 100644 --- a/src/Tgstation.Server.Host/Components/Repository/IRepository.cs +++ b/src/Tgstation.Server.Host/Components/Repository/IRepository.cs @@ -113,10 +113,12 @@ namespace Tgstation.Server.Host.Components.Repository /// /// The username to fetch from the origin repository /// The password to fetch from the origin repository + /// The name of the potential committer + /// The e-mail of the potential committer /// If the synchronizations should be made to the tracked reference as opposed to a temporary branch /// The for the operation /// A representing the running operation - Task Sychronize(string username, string password, bool synchronizeTrackedBranch, CancellationToken cancellationToken); + Task Sychronize(string username, string password, string committerName, string committerEmail, bool synchronizeTrackedBranch, CancellationToken cancellationToken); /// /// Copies the current working directory to a given diff --git a/src/Tgstation.Server.Host/Components/Repository/Repository.cs b/src/Tgstation.Server.Host/Components/Repository/Repository.cs index afa1e36c5c..889f899ecb 100644 --- a/src/Tgstation.Server.Host/Components/Repository/Repository.cs +++ b/src/Tgstation.Server.Host/Components/Repository/Repository.cs @@ -375,7 +375,7 @@ namespace Tgstation.Server.Host.Components.Repository } /// - public async Task Sychronize(string username, string password, bool synchronizeTrackedBranch, CancellationToken cancellationToken) + public async Task Sychronize(string username, string password, string committerName, string committerEmail, bool synchronizeTrackedBranch, CancellationToken cancellationToken) { if (username == null && password == null) return; @@ -384,9 +384,19 @@ namespace Tgstation.Server.Host.Components.Repository throw new ArgumentNullException(nameof(username)); if (password == null) throw new ArgumentNullException(nameof(password)); + if (committerName == null) + throw new ArgumentNullException(nameof(committerName)); + if (committerEmail == null) + throw new ArgumentNullException(nameof(committerEmail)); var startHead = Head; + await Task.Factory.StartNew(() => + { + repository.Config.Set("name", committerName); + repository.Config.Set("email", committerEmail); + }, cancellationToken, TaskCreationOptions.LongRunning, TaskScheduler.Current).ConfigureAwait(false); + if (!await eventConsumer.HandleEvent(EventType.RepoPreSynchronize, new List { ioMananger.ResolvePath(".") }, cancellationToken).ConfigureAwait(false)) return; diff --git a/src/Tgstation.Server.Host/Controllers/RepositoryController.cs b/src/Tgstation.Server.Host/Controllers/RepositoryController.cs index 240227aaaf..330d242422 100644 --- a/src/Tgstation.Server.Host/Controllers/RepositoryController.cs +++ b/src/Tgstation.Server.Host/Controllers/RepositoryController.cs @@ -476,7 +476,7 @@ namespace Tgstation.Server.Host.Controllers if (fastForward.Value) { lastRevisionInfo.OriginCommitSha = repo.Head; - await repo.Sychronize(currentModel.AccessUser, currentModel.AccessToken, true, ct).ConfigureAwait(false); + await repo.Sychronize(currentModel.AccessUser, currentModel.AccessToken, currentModel.CommitterName, currentModel.CommitterEmail, true, ct).ConfigureAwait(false); } } } @@ -502,7 +502,7 @@ namespace Tgstation.Server.Host.Controllers if (!repo.Tracking) throw new JobException("Checked out reference does not track a remote object!"); await repo.ResetToOrigin(ct).ConfigureAwait(false); - await repo.Sychronize(currentModel.AccessUser, currentModel.AccessToken, true, ct).ConfigureAwait(false); + await repo.Sychronize(currentModel.AccessUser, currentModel.AccessToken, currentModel.CommitterName, currentModel.CommitterEmail, true, ct).ConfigureAwait(false); await LoadRevisionInformation(repo, databaseContext, attachedInstance, null, x => lastRevisionInfo = x, ct).ConfigureAwait(false); //repo head is on origin so force this //will update the db if necessary @@ -695,7 +695,7 @@ namespace Tgstation.Server.Host.Controllers if (startSha != repo.Head) { - await repo.Sychronize(currentModel.AccessUser, currentModel.AccessToken, false, ct).ConfigureAwait(false); + await repo.Sychronize(currentModel.AccessUser, currentModel.AccessToken, currentModel.CommitterName, currentModel.CommitterEmail, false, ct).ConfigureAwait(false); await UpdateRevInfo().ConfigureAwait(false); } await databaseContext.Save(ct).ConfigureAwait(false); From beb6661bda0a9604a7de4a931227fe81af044f4d Mon Sep 17 00:00:00 2001 From: Cyberboss Date: Tue, 18 Sep 2018 17:26:40 -0400 Subject: [PATCH 2/3] Use correct configuration keys --- src/Tgstation.Server.Host/Components/Repository/Repository.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Repository/Repository.cs b/src/Tgstation.Server.Host/Components/Repository/Repository.cs index 889f899ecb..30cb9c1d94 100644 --- a/src/Tgstation.Server.Host/Components/Repository/Repository.cs +++ b/src/Tgstation.Server.Host/Components/Repository/Repository.cs @@ -393,8 +393,8 @@ namespace Tgstation.Server.Host.Components.Repository await Task.Factory.StartNew(() => { - repository.Config.Set("name", committerName); - repository.Config.Set("email", committerEmail); + repository.Config.Set("user.name", committerName); + repository.Config.Set("user.email", committerEmail); }, cancellationToken, TaskCreationOptions.LongRunning, TaskScheduler.Current).ConfigureAwait(false); if (!await eventConsumer.HandleEvent(EventType.RepoPreSynchronize, new List { ioMananger.ResolvePath(".") }, cancellationToken).ConfigureAwait(false)) From 573316547bf04e3be64baa50b2a7b1cb5749e0fd Mon Sep 17 00:00:00 2001 From: Jordan Brown Date: Tue, 18 Sep 2018 19:49:57 -0400 Subject: [PATCH 3/3] Fix build --- src/Tgstation.Server.Host/Components/Instance.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Tgstation.Server.Host/Components/Instance.cs b/src/Tgstation.Server.Host/Components/Instance.cs index 708725c349..1c36c2e917 100644 --- a/src/Tgstation.Server.Host/Components/Instance.cs +++ b/src/Tgstation.Server.Host/Components/Instance.cs @@ -251,7 +251,7 @@ namespace Tgstation.Server.Host.Components //synch if necessary if (repositorySettings.AutoUpdatesSynchronize.Value && startSha != repo.Head) - await repo.Sychronize(repositorySettings.AccessUser, repositorySettings.AccessToken, shouldSyncTracked, jobCancellationToken).ConfigureAwait(false); + await repo.Sychronize(repositorySettings.AccessUser, repositorySettings.AccessToken, repositorySettings.CommitterName, repositorySettings.CommitterEmail, shouldSyncTracked, jobCancellationToken).ConfigureAwait(false); progressReporter(5 * ProgressStep); }