diff --git a/src/Tgstation.Server.Api/Models/Internal/RevisionInformation.cs b/src/Tgstation.Server.Api/Models/Internal/RevisionInformation.cs
index efdb763aa2..1ee31b1993 100644
--- a/src/Tgstation.Server.Api/Models/Internal/RevisionInformation.cs
+++ b/src/Tgstation.Server.Api/Models/Internal/RevisionInformation.cs
@@ -11,14 +11,14 @@ namespace Tgstation.Server.Api.Models.Internal
/// The revision sha
///
[Required]
- [StringLength(40)]
+ [StringLength(Limits.MaximumCommitShaLength)]
public string? CommitSha { get; set; }
///
/// The sha of the most recent remote commit
///
[Required]
- [StringLength(40)]
+ [StringLength(Limits.MaximumCommitShaLength)]
public string? OriginCommitSha { get; set; }
}
}
diff --git a/src/Tgstation.Server.Api/Models/Limits.cs b/src/Tgstation.Server.Api/Models/Limits.cs
index be61530fe7..249ecd0763 100644
--- a/src/Tgstation.Server.Api/Models/Limits.cs
+++ b/src/Tgstation.Server.Api/Models/Limits.cs
@@ -14,5 +14,10 @@
/// Length limit for s.
///
public const int MaximumIndexableStringLength = 100;
+
+ ///
+ /// Length limit for git commit SHAs.
+ ///
+ public const int MaximumCommitShaLength = 40;
}
}
\ No newline at end of file
diff --git a/src/Tgstation.Server.Api/Models/Repository.cs b/src/Tgstation.Server.Api/Models/Repository.cs
index 26a3e1fa46..88b53ab95c 100644
--- a/src/Tgstation.Server.Api/Models/Repository.cs
+++ b/src/Tgstation.Server.Api/Models/Repository.cs
@@ -1,4 +1,5 @@
using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
namespace Tgstation.Server.Api.Models
{
@@ -12,9 +13,15 @@ namespace Tgstation.Server.Api.Models
///
public string? Origin { get; set; }
+ ///
+ /// If submodules should be recursively cloned.
+ ///
+ public bool? RecurseSubmodules { get; set; }
+
///
/// The commit HEAD should point to. Not populated in responses, use instead for retrieval
///
+ [StringLength(Limits.MaximumCommitShaLength)]
public string? CheckoutSha { get; set; }
///
@@ -45,6 +52,7 @@ namespace Tgstation.Server.Api.Models
///
/// The branch or tag HEAD points to
///
+ [StringLength(Limits.MaximumStringLength)]
public string? Reference { get; set; }
///
diff --git a/src/Tgstation.Server.Host/Components/Repository/IRepositoryManager.cs b/src/Tgstation.Server.Host/Components/Repository/IRepositoryManager.cs
index 2f9c59df69..06bf3fb467 100644
--- a/src/Tgstation.Server.Host/Components/Repository/IRepositoryManager.cs
+++ b/src/Tgstation.Server.Host/Components/Repository/IRepositoryManager.cs
@@ -15,7 +15,7 @@ namespace Tgstation.Server.Host.Components.Repository
bool InUse { get; }
///
- /// If a operation is in progress
+ /// If a operation is in progress.
///
bool CloneInProgress { get; }
@@ -34,9 +34,17 @@ namespace Tgstation.Server.Host.Components.Repository
/// The username to clone from
/// The password to clone from
/// A function to report 0-100 progress of the clone
+ /// If submodules should be recusively cloned and initialized.
/// The for the operation
/// The newly cloned , if one already exists
- Task CloneRepository(Uri url, string initialBranch, string username, string password, Action progressReporter, CancellationToken cancellationToken);
+ Task CloneRepository(
+ Uri url,
+ string initialBranch,
+ string username,
+ string password,
+ Action progressReporter,
+ bool recurseSubmodules,
+ CancellationToken cancellationToken);
///
/// Delete the current repository
diff --git a/src/Tgstation.Server.Host/Components/Repository/RepositoryManager.cs b/src/Tgstation.Server.Host/Components/Repository/RepositoryManager.cs
index 4c5fefc314..55c19fdc82 100644
--- a/src/Tgstation.Server.Host/Components/Repository/RepositoryManager.cs
+++ b/src/Tgstation.Server.Host/Components/Repository/RepositoryManager.cs
@@ -89,7 +89,14 @@ namespace Tgstation.Server.Host.Components.Repository
}
///
- public async Task CloneRepository(Uri url, string initialBranch, string username, string password, Action progressReporter, CancellationToken cancellationToken)
+ public async Task CloneRepository(
+ Uri url,
+ string initialBranch,
+ string username,
+ string password,
+ Action progressReporter,
+ bool recurseSubmodules,
+ CancellationToken cancellationToken)
{
if (url == null)
throw new ArgumentNullException(nameof(url));
@@ -122,7 +129,7 @@ namespace Tgstation.Server.Host.Components.Repository
progressReporter((int)percentage);
return !cancellationToken.IsCancellationRequested;
},
- RecurseSubmodules = true,
+ RecurseSubmodules = recurseSubmodules,
OnUpdateTips = (a, b, c) => !cancellationToken.IsCancellationRequested,
RepositoryOperationStarting = (a) => !cancellationToken.IsCancellationRequested,
BranchName = initialBranch,
diff --git a/src/Tgstation.Server.Host/Controllers/RepositoryController.cs b/src/Tgstation.Server.Host/Controllers/RepositoryController.cs
index d6536518e3..0094cb8764 100644
--- a/src/Tgstation.Server.Host/Controllers/RepositoryController.cs
+++ b/src/Tgstation.Server.Host/Controllers/RepositoryController.cs
@@ -204,7 +204,15 @@ namespace Tgstation.Server.Host.Controllers
var api = currentModel.ToApi();
await jobManager.RegisterOperation(job, async (paramJob, databaseContextFactory, progressReporter, ct) =>
{
- using var repos = await repoManager.CloneRepository(new Uri(origin), cloneBranch, currentModel.AccessUser, currentModel.AccessToken, progressReporter, ct).ConfigureAwait(false);
+ using var repos = await repoManager.CloneRepository(
+ new Uri(origin),
+ cloneBranch,
+ currentModel.AccessUser,
+ currentModel.AccessToken,
+ progressReporter,
+ model.RecurseSubmodules ?? true,
+ ct)
+ .ConfigureAwait(false);
if (repos == null)
throw new JobException(ErrorCode.RepoExists);
var instance = new Models.Instance