)]}'
{
  "commit": "038bd71842b98fc46b11cc3e906f4db52256db6f",
  "tree": "f73e1eacf59afdf0b3336eb1b0b36236f46a8e28",
  "parents": [
    "7088891e07d8b4f7c1977ed9c9f5d00338ade31e"
  ],
  "author": {
    "name": "Edwin Kempin",
    "email": "ekempin@google.com",
    "time": "Mon Aug 12 09:08:58 2024 +0000"
  },
  "committer": {
    "name": "Edwin Kempin",
    "email": "ekempin@google.com",
    "time": "Mon Aug 12 13:51:22 2024 +0000"
  },
  "message": "Simplify path code owners computation\n\nGlobal code owners (aka folder code owners) should be ignored if there\nis any matching per-file code owner set (in the code owner config that\nis being resolved or in any imported code owner config) that ignores\nglobal and parent code owners (i.e. that has \"set noparent\" set).\n\nTo achieve this we did 2 things:\n1. For the code owner config that is being evaluated we skipped global\n   imports that only import global code owners (importMode \u003d\n   GLOBAL_CODE_OWNER_SETS_ONLY) if the code owner config contained any\n   matching per-file code owner set that ignores global and parent code\n   owners (as those global code owners would be dropped by 2.).\n2. We droped global code owners sets that we had already collected when\n   we found any matching per-file code owner set that ignores global and\n   parent code owners.\n\nSince we use a builder to collect the result it\u0027s not straight-forward\nto drop global code owner sets that have already been added. For this we\nneed to build the PathCodeOwnerResult and then create a new builder that\ncopies all the fields except global code owner sets. This adds quite\nsome boilerplate code.\n\nWhile we have good test coverage for PathCodeOwners I cannot shake off\nthe feeling that there is also some edge case where dropping global code\nowners is wrongly dropping too much, but I can’t pinpoint this.\n\nIn any case the existing logic is confusing and hard to read, which is\nwhy we want to simplify this.\n\nWith this change the logic is easier to grasp now:\n1. Differentiate between global and per-file code owner sets in\n   PathCodeOwnersResult.\n2. Collect all relevant global code owner sets in PathCodeOwnersResult\n   regardless of whether they are possibly ignored.\n3. Have an ignoreGlobalCodeOwners flag in PathCodeOwnersResult that is\n   set when there is any matching per-file code owner set that ignores\n   global and parent code owners.\n4. When looking at code owner sets in PathCodeOwnerResult we simply\n   ignore global code owner set when ignoreGlobalCodeOwners has been set\n   to true.\n\nThis way we no longer need to recreate the PathCodeOwnersResult.Builder\nto drop already collected global code owner sets and the code gets\neasier to read.\n\nIn addition, since the ignored global code owners are now present in\nPathCodeOwnerResult we may inform about them when code ownership is\nbeing checked via the CheckCodeOwner REST endpoint (possible follow-up\nchange).\n\nBug: Google b/345161989\nChange-Id: I6f7723c0ad49a216c5118ffd047216a9648c438a\nSigned-off-by: Edwin Kempin \u003cekempin@google.com\u003e\n",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "dc6da3e9bff2c7954d1af5d39b0939dc6c4acc7f",
      "old_mode": 33188,
      "old_path": "java/com/google/gerrit/plugins/codeowners/backend/PathCodeOwners.java",
      "new_id": "2083fc2abda54e33ac2695dcc23c65b69dac2b0d",
      "new_mode": 33188,
      "new_path": "java/com/google/gerrit/plugins/codeowners/backend/PathCodeOwners.java"
    },
    {
      "type": "modify",
      "old_id": "6a454251ba7a859987ceaffd57c62897f863cf4e",
      "old_mode": 33188,
      "old_path": "java/com/google/gerrit/plugins/codeowners/backend/PathCodeOwnersResult.java",
      "new_id": "15be56fe57e745fe290fcdbe1131e56a051d6b59",
      "new_mode": 33188,
      "new_path": "java/com/google/gerrit/plugins/codeowners/backend/PathCodeOwnersResult.java"
    },
    {
      "type": "modify",
      "old_id": "932a91b9910c18435c6689418f9aab0fcb41bd7c",
      "old_mode": 33188,
      "old_path": "javatests/com/google/gerrit/plugins/codeowners/backend/PathCodeOwnersResultTest.java",
      "new_id": "4d62da9844d4cb848183613cc9edd19806f07379",
      "new_mode": 33188,
      "new_path": "javatests/com/google/gerrit/plugins/codeowners/backend/PathCodeOwnersResultTest.java"
    }
  ]
}
