Repository API model now contains GitHub repo owner and name

This commit is contained in:
Cyberboss
2018-09-10 10:56:12 -04:00
parent a8f54a1ea9
commit 4d2f4c1414
2 changed files with 12 additions and 4 deletions
@@ -23,9 +23,14 @@ namespace Tgstation.Server.Api.Models
public RevisionInformation RevisionInformation { get; set; }
/// <summary>
/// If the repository was cloned from GitHub.com. If <see langword="true"/> this enables test merge functionality
/// If the repository was cloned from GitHub.com this will be set with the owner of the repository
/// </summary>
public bool? IsGitHub { get; set; }
public string GitHubOwner { get; set; }
/// <summary>
/// If the repository was cloned from GitHub.com this will be set with the name of the repository
/// </summary>
public string GitHubName { get; set; }
/// <summary>
/// The <see cref="Job"/> started by the <see cref="Repository"/> if any
@@ -94,7 +94,11 @@ namespace Tgstation.Server.Host.Controllers
static async Task<bool> PopulateApi(Repository model, Components.Repository.IRepository repository, IDatabaseContext databaseContext, Models.Instance instance, CancellationToken cancellationToken)
{
model.IsGitHub = repository.IsGitHubRepository;
if (repository.IsGitHubRepository)
{
model.GitHubOwner = repository.GitHubOwner;
model.GitHubName = repository.GitHubRepoName;
}
model.Origin = repository.Origin;
model.Reference = repository.Reference;
@@ -187,7 +191,6 @@ namespace Tgstation.Server.Host.Controllers
api.Origin = model.Origin;
api.Reference = model.Reference;
api.IsGitHub = model.Origin.ToUpperInvariant().Contains(uiGitHub);
api.ActiveJob = job.ToApi();
return StatusCode((int)HttpStatusCode.Created, api);