ChangedFilesByPatchSetCache: Get changed files without rename detection

The only caller of ChangedFilesByPatchSetCache is
CodeOwnerApprovalCheck. CodeOwnerApprovalCheck only uses
ChangedFilesByPatchSetCache to check whether the path has been
code-owner approved in a previous patch set. For this it doesn't matter
whether renamed are represented as a single ChangedFile (with new and
old path set) or by 2 separate ChangedFile's (one that only has the new
path set and one that only has the old path set).

Bug: Google b/461456634
Change-Id: Ifdea3fed3379132d6271270e27866eb7a988f2ec
Signed-off-by: Edwin Kempin <ekempin@google.com>
diff --git a/java/com/google/gerrit/plugins/codeowners/backend/ChangedFilesByPatchSetCache.java b/java/com/google/gerrit/plugins/codeowners/backend/ChangedFilesByPatchSetCache.java
index 48382d0..511a90c 100644
--- a/java/com/google/gerrit/plugins/codeowners/backend/ChangedFilesByPatchSetCache.java
+++ b/java/com/google/gerrit/plugins/codeowners/backend/ChangedFilesByPatchSetCache.java
@@ -35,6 +35,8 @@
  * <p>The changed files for a patch set are computed lazily. This way we do not compute changed
  * files unnecessarily that are never requested.
  *
+ * <p>The changed files are computed without rename detection.
+ *
  * <p>This class is not thread-safe.
  */
 public class ChangedFilesByPatchSetCache {
@@ -71,7 +73,7 @@
         changeNotes.getChange().getId().get());
     PatchSet patchSet = getPatchSet(patchSetId);
     try {
-      return changedFiles.get(
+      return changedFiles.getWithoutRenameDetection(
           changeNotes.getProjectName(),
           patchSet.commitId(),
           codeOwnersConfig.getMergeCommitStrategy());
diff --git a/java/com/google/gerrit/plugins/codeowners/backend/CodeOwnerApprovalCheck.java b/java/com/google/gerrit/plugins/codeowners/backend/CodeOwnerApprovalCheck.java
index e776abd..4e30b1a 100644
--- a/java/com/google/gerrit/plugins/codeowners/backend/CodeOwnerApprovalCheck.java
+++ b/java/com/google/gerrit/plugins/codeowners/backend/CodeOwnerApprovalCheck.java
@@ -902,6 +902,8 @@
       CodeOwnerApprovalCheckInput input,
       AtomicReference<String> reason) {
     for (PatchSet.Id patchSetId : input.previouslyApprovedPatchSetsInReverseOrder()) {
+      // changedFilesByPatchSetCache doesn't detect renames. That's fine since we only check whether
+      // the path has been code-owner approved in a previous patch set.
       if (changedFilesByPatchSetCache.get(patchSetId).stream()
           .anyMatch(
               changedFile ->