diff --git a/src/Tgstation.Server.Host/Components/Repository/IRepository.cs b/src/Tgstation.Server.Host/Components/Repository/IRepository.cs index 3ca1a934bc..48f6ff2d06 100644 --- a/src/Tgstation.Server.Host/Components/Repository/IRepository.cs +++ b/src/Tgstation.Server.Host/Components/Repository/IRepository.cs @@ -45,6 +45,14 @@ namespace Tgstation.Server.Host.Components.Repository /// string Origin { get; } + /// + /// Checks if a given is a sha + /// + /// The git object to check + /// The for the operation + /// A resulting in if is a sha, otherwise + Task IsSha(string committish, CancellationToken cancellationToken); + /// /// Checks out a given /// diff --git a/src/Tgstation.Server.Host/Components/Repository/Repository.cs b/src/Tgstation.Server.Host/Components/Repository/Repository.cs index b7fa727904..0ed716b751 100644 --- a/src/Tgstation.Server.Host/Components/Repository/Repository.cs +++ b/src/Tgstation.Server.Host/Components/Repository/Repository.cs @@ -418,5 +418,12 @@ namespace Tgstation.Server.Host.Components.Repository } }, cancellationToken, TaskCreationOptions.LongRunning, TaskScheduler.Current).ConfigureAwait(false); } + + /// + public Task IsSha(string committish, CancellationToken cancellationToken) => Task.Factory.StartNew(() => + { + var gitObject = repository.Lookup(committish, ObjectType.Commit); + return gitObject != null; + }, cancellationToken, TaskCreationOptions.LongRunning, TaskScheduler.Current); } }