Update package version on automatic API revision (#7819)
* Update package version on automatic API revision
This commit is contained in:
Родитель
f644c2425e
Коммит
be7ca14528
|
@ -35,7 +35,7 @@ namespace APIViewWeb.Controllers
|
|||
}
|
||||
|
||||
[HttpPost]
|
||||
public async Task<ActionResult> UploadAutoReview([FromForm] IFormFile file, string label, bool compareAllRevisions = false)
|
||||
public async Task<ActionResult> UploadAutoReview([FromForm] IFormFile file, string label, bool compareAllRevisions = false, string packageVersion = null)
|
||||
{
|
||||
if (file != null)
|
||||
{
|
||||
|
@ -46,9 +46,9 @@ namespace APIViewWeb.Controllers
|
|||
runAnalysis: false, memoryStream: memoryStream);
|
||||
|
||||
var apiRevision = await CreateAutomaticRevisionAsync(codeFile: codeFile, label: label, originalName: file.FileName, memoryStream: memoryStream, compareAllRevisions);
|
||||
|
||||
if (apiRevision != null)
|
||||
{
|
||||
apiRevision = await _apiRevisionsManager.UpdateRevisionMetadataAsync(apiRevision, packageVersion ?? codeFile.PackageVersion, label);
|
||||
var reviewUrl = $"{this.Request.Scheme}://{this.Request.Host}/Assemblies/Review/{apiRevision.ReviewId}?revisionId={apiRevision.Id}";
|
||||
return apiRevision.IsApproved ? Ok(reviewUrl) : StatusCode(statusCode: StatusCodes.Status201Created, reviewUrl);
|
||||
}
|
||||
|
@ -100,7 +100,8 @@ namespace APIViewWeb.Controllers
|
|||
string repoName,
|
||||
string packageName,
|
||||
bool compareAllRevisions,
|
||||
string project
|
||||
string project,
|
||||
string packageVersion = null
|
||||
)
|
||||
{
|
||||
using var memoryStream = new MemoryStream();
|
||||
|
@ -115,6 +116,7 @@ namespace APIViewWeb.Controllers
|
|||
var apiRevision = await CreateAutomaticRevisionAsync(codeFile: codeFile, label: label, originalName: originalFilePath, memoryStream: memoryStream, compareAllRevisions);
|
||||
if (apiRevision != null)
|
||||
{
|
||||
apiRevision = await _apiRevisionsManager.UpdateRevisionMetadataAsync(apiRevision, packageVersion ?? codeFile.PackageVersion, label);
|
||||
var reviewUrl = $"{this.Request.Scheme}://{this.Request.Host}/Assemblies/Review/{apiRevision.ReviewId}?revisionId={apiRevision.Id}";
|
||||
return apiRevision.IsApproved ? Ok(reviewUrl) : StatusCode(statusCode: StatusCodes.Status201Created, reviewUrl);
|
||||
}
|
||||
|
@ -198,8 +200,8 @@ namespace APIViewWeb.Controllers
|
|||
if (apiRev.IsApproved && await _apiRevisionsManager.AreAPIRevisionsTheSame(apiRev, renderedCodeFile))
|
||||
{
|
||||
await _apiRevisionsManager.ToggleAPIRevisionApprovalAsync(user: User, id: review.Id, apiRevision: apiRevision, notes: $"Approval Copied over from Revision with Id : {apiRev.Id}", approver: apiRev.Approvers.LastOrDefault());
|
||||
}
|
||||
break;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -828,5 +828,16 @@ namespace APIViewWeb.Managers
|
|||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public async Task<APIRevisionListItemModel> UpdateRevisionMetadataAsync(APIRevisionListItemModel revision, string packageVersion, string label)
|
||||
{
|
||||
if (packageVersion != null && !packageVersion.Equals(revision.Files[0].PackageVersion))
|
||||
{
|
||||
revision.Files[0].PackageVersion = packageVersion;
|
||||
revision.Label = label;
|
||||
await _apiRevisionsRepository.UpsertAPIRevisionAsync(revision);
|
||||
}
|
||||
return revision;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,5 +40,6 @@ namespace APIViewWeb.Managers.Interfaces
|
|||
public Task AutoArchiveAPIRevisions(int archiveAfterMonths);
|
||||
public Task AssignReviewersToAPIRevisionAsync(ClaimsPrincipal User, string apiRevisionId, HashSet<string> reviewers);
|
||||
public Task<IEnumerable<APIRevisionListItemModel>> GetAPIRevisionsAssignedToUser(string userName);
|
||||
public Task<APIRevisionListItemModel> UpdateRevisionMetadataAsync(APIRevisionListItemModel revision, string packageVersion, string label);
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче