mirror of
https://github.com/tgstation/tgstation-server.git
synced 2026-08-30 16:39:21 +01:00
Adds IRepository.IsSha
This commit is contained in:
@@ -45,6 +45,14 @@ namespace Tgstation.Server.Host.Components.Repository
|
||||
/// </summary>
|
||||
string Origin { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Checks if a given <paramref name="committish"/> is a sha
|
||||
/// </summary>
|
||||
/// <param name="committish">The git object to check</param>
|
||||
/// <param name="cancellationToken">The <see cref="CancellationToken"/> for the operation</param>
|
||||
/// <returns>A <see cref="Task{TResult}"/> resulting in <see langword="true"/> if <paramref name="committish"/> is a sha, <see langword="false"/> otherwise</returns>
|
||||
Task<bool> IsSha(string committish, CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// Checks out a given <paramref name="committish"/>
|
||||
/// </summary>
|
||||
|
||||
@@ -418,5 +418,12 @@ namespace Tgstation.Server.Host.Components.Repository
|
||||
}
|
||||
}, cancellationToken, TaskCreationOptions.LongRunning, TaskScheduler.Current).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public Task<bool> IsSha(string committish, CancellationToken cancellationToken) => Task.Factory.StartNew(() =>
|
||||
{
|
||||
var gitObject = repository.Lookup(committish, ObjectType.Commit);
|
||||
return gitObject != null;
|
||||
}, cancellationToken, TaskCreationOptions.LongRunning, TaskScheduler.Current);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user