diff --git a/docs/API.dox b/docs/API.dox
index 49c19ce3ee..759c73ff56 100644
--- a/docs/API.dox
+++ b/docs/API.dox
@@ -287,7 +287,7 @@ Modifications to the repository are done with the following request:
I POST "/Repository" => @ref Tgstation.Server.Api.Models.Repository => @ref Tgstation.Server.Api.Models.Repository
-Each update creates a job specified in the @ref Tgstation.Server.Api.Models.Repository.ActiveJob field jobs will be queued in succession. See below for post examples.
+Each update that requires git changes creates a job specified in the @ref Tgstation.Server.Api.Models.Repository.ActiveJob field jobs will be queued in succession. See below for POST examples.
@subsubsection api_repopost Repository Commands for Git Aliases
diff --git a/src/Tgstation.Server.Host/Components/Instance.cs b/src/Tgstation.Server.Host/Components/Instance.cs
index 080c469aab..21e7edc06d 100644
--- a/src/Tgstation.Server.Host/Components/Instance.cs
+++ b/src/Tgstation.Server.Host/Components/Instance.cs
@@ -186,6 +186,7 @@ namespace Tgstation.Server.Host.Components
Id = metadata.Id
}
};
+ logger.LogWarning(Repository.Repository.OriginTrackingErrorTemplate, currentSha);
db.Instances.Attach(revInfo.Instance);
}
diff --git a/src/Tgstation.Server.Host/Components/Repository/IRepository.cs b/src/Tgstation.Server.Host/Components/Repository/IRepository.cs
index 48f6ff2d06..244ef15f91 100644
--- a/src/Tgstation.Server.Host/Components/Repository/IRepository.cs
+++ b/src/Tgstation.Server.Host/Components/Repository/IRepository.cs
@@ -105,7 +105,7 @@ namespace Tgstation.Server.Host.Components.Repository
/// The name of the merge committer
/// The e-mail of the merge committer
/// The for the operation
- /// A resulting in a representing the merge result that is after a fast forward or up to date, on a merge, on a conflict
+ /// A resulting in a representing the merge result that is after a fast forward, on a merge or up to date, on a conflict
Task MergeOrigin(string committerName, string committerEmail, CancellationToken cancellationToken);
///
diff --git a/src/Tgstation.Server.Host/Components/Repository/Repository.cs b/src/Tgstation.Server.Host/Components/Repository/Repository.cs
index 1b704da4f5..e8f54cc2a2 100644
--- a/src/Tgstation.Server.Host/Components/Repository/Repository.cs
+++ b/src/Tgstation.Server.Host/Components/Repository/Repository.cs
@@ -18,13 +18,18 @@ namespace Tgstation.Server.Host.Components.Repository
///
public const string GitHubUrl = "://github.com/";
- const string UnknownReference = "";
+ ///
+ /// Template error message for when tracking of the most recent origin commit fails
+ ///
+ public const string OriginTrackingErrorTemplate = "Unable to determine most recent origin commit of {0}. Marking it as an origin commit. This may result in invalid git metadata until the next hard reset to an origin reference.";
///
/// The branch name used for publishing testmerge commits
///
public const string RemoteTemporaryBranchName = "___TGSTempBranch";
+ const string UnknownReference = "";
+
///
public bool IsGitHubRepository { get; }
@@ -366,7 +371,7 @@ namespace Tgstation.Server.Host.Components.Repository
return null;
}
- return result.Status != MergeStatus.NonFastForward;
+ return result.Status == MergeStatus.FastForward;
}
///
diff --git a/src/Tgstation.Server.Host/Controllers/DreamMakerController.cs b/src/Tgstation.Server.Host/Controllers/DreamMakerController.cs
index 9341fd8dd3..d2cb696917 100644
--- a/src/Tgstation.Server.Host/Controllers/DreamMakerController.cs
+++ b/src/Tgstation.Server.Host/Controllers/DreamMakerController.cs
@@ -10,6 +10,7 @@ using System.Threading.Tasks;
using Tgstation.Server.Api;
using Tgstation.Server.Api.Rights;
using Tgstation.Server.Host.Components;
+using Tgstation.Server.Host.Components.Repository;
using Tgstation.Server.Host.Core;
using Tgstation.Server.Host.Models;
using Tgstation.Server.Host.Security;
@@ -179,6 +180,7 @@ namespace Tgstation.Server.Host.Controllers
Id = Instance.Id
}
};
+ Logger.LogWarning(Repository.OriginTrackingErrorTemplate, repoSha);
databaseContext.Instances.Attach(revInfo.Instance);
}
diff --git a/src/Tgstation.Server.Host/Controllers/RepositoryController.cs b/src/Tgstation.Server.Host/Controllers/RepositoryController.cs
index a5e749c6d4..fc916acae6 100644
--- a/src/Tgstation.Server.Host/Controllers/RepositoryController.cs
+++ b/src/Tgstation.Server.Host/Controllers/RepositoryController.cs
@@ -67,7 +67,7 @@ namespace Tgstation.Server.Host.Controllers
generalConfiguration = generalConfigurationOptions?.Value ?? throw new ArgumentNullException(nameof(generalConfigurationOptions));
}
- static async Task LoadRevisionInformation(Components.Repository.IRepository repository, IDatabaseContext databaseContext, Models.Instance instance, string lastOriginCommitSha, Action revInfoSink, CancellationToken cancellationToken)
+ async Task LoadRevisionInformation(Components.Repository.IRepository repository, IDatabaseContext databaseContext, Models.Instance instance, string lastOriginCommitSha, Action revInfoSink, CancellationToken cancellationToken)
{
var repoSha = repository.Head;
@@ -96,12 +96,17 @@ namespace Tgstation.Server.Host.Controllers
lock (databaseContext) //cleaner this way
databaseContext.RevisionInformations.Add(revisionInfo);
}
- revisionInfo.OriginCommitSha = revisionInfo.OriginCommitSha ?? lastOriginCommitSha ?? repository.Head;
+ revisionInfo.OriginCommitSha = revisionInfo.OriginCommitSha ?? lastOriginCommitSha;
+ if (revisionInfo.OriginCommitSha == null)
+ {
+ revisionInfo.OriginCommitSha = repoSha;
+ Logger.LogWarning(Components.Repository.Repository.OriginTrackingErrorTemplate, repoSha);
+ }
revInfoSink?.Invoke(revisionInfo);
return needsDbUpdate;
}
- static async Task PopulateApi(Repository model, Components.Repository.IRepository repository, IDatabaseContext databaseContext, Models.Instance instance, CancellationToken cancellationToken)
+ async Task PopulateApi(Repository model, Components.Repository.IRepository repository, IDatabaseContext databaseContext, Models.Instance instance, CancellationToken cancellationToken)
{
if (repository.IsGitHubRepository)
{
@@ -381,9 +386,33 @@ namespace Tgstation.Server.Host.Controllers
//this is just db stuf so stow it away
await DatabaseContext.Save(cancellationToken).ConfigureAwait(false);
+ //format the job description
+ string description = null;
+ if (model.UpdateFromOrigin == true)
+ if (model.Reference != null)
+ description = String.Format(CultureInfo.InvariantCulture, "Fetch and hard reset repsitory to origin/{0}", model.Reference);
+ else if (model.CheckoutSha != null)
+ description = String.Format(CultureInfo.InvariantCulture, "Fetch and checkout {0} in repository", model.CheckoutSha);
+ else
+ description = "Pull current repository reference";
+ else if (model.Reference != null || model.CheckoutSha != null)
+ description = String.Format(CultureInfo.InvariantCulture, "Checkout repository {0} {1}", model.Reference != null ? "reference" : "SHA", model.Reference ?? model.CheckoutSha);
+
+ if (newTestMerges)
+ description = String.Format(CultureInfo.InvariantCulture, "{0}est merge pull request(s) {1}{2}",
+ description != null ? String.Format(CultureInfo.InvariantCulture, "{0} and t", description) : "T",
+ String.Join(", ", model.NewTestMerges.Select(x =>
+ String.Format(CultureInfo.InvariantCulture, "#{0}{1}", x.Number,
+ x.PullRequestRevision != null ? String.Format(CultureInfo.InvariantCulture, " {0}", x.PullRequestRevision.Substring(0, 7)) : String.Empty))),
+ description != null ? String.Empty : " in repository");
+
+ if (description == null)
+ //no git changes
+ return Json(api);
+
var job = new Models.Job
{
- Description = "Apply repository changes",
+ Description = description,
StartedBy = AuthenticationContext.User,
Instance = Instance,
CancelRightsType = RightsType.Repository,