mirror of
https://github.com/tgstation/tgstation-server.git
synced 2026-08-30 08:33:19 +01:00
Merge pull request #676 from Cyberboss/NoCommitOnlyStage
Configure committer name and email in local repository settings before synchronization script
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
@@ -113,10 +113,12 @@ namespace Tgstation.Server.Host.Components.Repository
|
||||
/// </summary>
|
||||
/// <param name="username">The username to fetch from the origin repository</param>
|
||||
/// <param name="password">The password to fetch from the origin repository</param>
|
||||
/// <param name="committerName">The name of the potential committer</param>
|
||||
/// <param name="committerEmail">The e-mail of the potential committer</param>
|
||||
/// <param name="synchronizeTrackedBranch">If the synchronizations should be made to the tracked reference as opposed to a temporary branch</param>
|
||||
/// <param name="cancellationToken">The <see cref="CancellationToken"/> for the operation</param>
|
||||
/// <returns>A <see cref="Task"/> representing the running operation</returns>
|
||||
Task Sychronize(string username, string password, bool synchronizeTrackedBranch, CancellationToken cancellationToken);
|
||||
Task Sychronize(string username, string password, string committerName, string committerEmail, bool synchronizeTrackedBranch, CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// Copies the current working directory to a given <paramref name="path"/>
|
||||
|
||||
@@ -375,7 +375,7 @@ namespace Tgstation.Server.Host.Components.Repository
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
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("user.name", committerName);
|
||||
repository.Config.Set("user.email", committerEmail);
|
||||
}, cancellationToken, TaskCreationOptions.LongRunning, TaskScheduler.Current).ConfigureAwait(false);
|
||||
|
||||
if (!await eventConsumer.HandleEvent(EventType.RepoPreSynchronize, new List<string> { ioMananger.ResolvePath(".") }, cancellationToken).ConfigureAwait(false))
|
||||
return;
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user