Fix ISE during validation of new merge commit that was created via REST

If a revision is newly inserted, but not committed to the repository
yet, it can only be seen from the RevWalk instance that created it, but
not by newly instantiated RevWalks. When a new merge commit is created
via the create change REST endpoint we have exactly this case. This is
why change I7ec825374 passed the RevWalk to the lower layers so that
they could use it to load the merge commit. However one case was missed.
If MergeCommitStrategy.FILES_WITH_CONFLICT_RESOLUTION was configured
ChangesFiles did the comparison against the AutoMerge which is loaded
via the PatchListCache. PatchListCache opens an own RevWalk and hence
cannot see the newly created merge commit and then fails with a missing
object exception. Passing in the RevWalk into PatchListCache is not
possible. This is why for merge commits we now always do the comparison
against the destination branch (MergeCommitStrategy.ALL_CHANGED_FILES)
to find the files that need to be validated. This way PatchListCache
will never be invoked from CodeOwnerConfigValidator. Hard-coding
MergeCommitStrategy.ALL_CHANGED_FILES here is fine, since the
mergeCommitStrategy config option is only for controlling which files
should require code owner approval, but not for which files should be
validated when a new commit is created.

Signed-off-by: Edwin Kempin <ekempin@google.com>
Change-Id: I72fcb5464eb40a8ae847156ad60225eba64097d6
3 files changed
tree: 69123ebde462e84ef516c4c8cfc3568b05d3ab98
  1. java/
  2. javatests/
  3. proto/
  4. resources/
  5. test/
  6. ui/
  7. .eslintrc.json
  8. .gitignore
  9. .gitreview
  10. bower.json
  11. BUILD
  12. LICENSE
  13. package-lock.json
  14. package.json
  15. README.md
README.md

Gerrit Code Review code-owners plugin

This plugin provides support for defining code owners for files in a repository.

If the code-owners plugin is enabled, changes can only be submitted if all touched files are covered by approvals from code owners.

Also see resources/Documentation/about.md

IMPORTANT: Before installing/enabling the plugin follow the instructions from the setup guide, see resources/Documentation/setup-guide.md