Skip to content

Commit

Permalink
Remove duplicate PR API review revisions (#3949)
Browse files Browse the repository at this point in the history
* Remove duplicate pull request API review revisions
  • Loading branch information
praveenkuttappan authored Aug 16, 2022
1 parent c0698a7 commit 7daac93
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ public void AddRange(IEnumerable<ReviewRevisionModel> revisionModels)
}
}

public void RemoveAll(System.Predicate<ReviewRevisionModel> match)
{
_list.RemoveAll(match);
}

public void Clear()
{
_list.Clear();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,12 @@ private async Task CreateRevisionIfRequired(CodeFile codeFile,
var prevRevisionId = review.Revisions.Last().RevisionId;
review = await GetBaseLineReview(codeFile.Language, codeFile.PackageName, pullRequestModel, true);
review.ReviewId = pullRequestModel.ReviewId;
//Remove previous revisions with revision ID.
//Currently revision ID is getting duplicated when a PR api review is created for a brand new package.
//In case of brand new package, we don't have any baseline from automatic review. So it uses previous PR api review as baseline and
//below revision ID copy step makes duplicate revision IDs in such cases.
//We should ensure that no revision exists in review with previous revision ID before we update new revision
review.Revisions.RemoveAll(r => r.RevisionId == prevRevisionId);
newRevision.RevisionId = prevRevisionId;
}
}
Expand Down

0 comments on commit 7daac93

Please sign in to comment.