)]}'
{
  "commit": "004bac3c1183ef2f47f7d0c90fafafdc7aefcf52",
  "tree": "6a8d544798040b619d074d68d009d47541073908",
  "parents": [
    "a7f6a238d73568d5bb1cbd1f6f4a22668b0da5cc"
  ],
  "author": {
    "name": "Edwin Kempin",
    "email": "ekempin@google.com",
    "time": "Thu Sep 05 08:26:09 2024 +0000"
  },
  "committer": {
    "name": "Edwin Kempin",
    "email": "ekempin@google.com",
    "time": "Thu Sep 05 10:35:30 2024 +0000"
  },
  "message": "Fix transitive import of global owners via per-file rule that ignores global owners\n\nExample:\n\nOWNERS:\nper-file *.md\u003dset noparent\nper-file *.md\u003dfile:/foo/OWNERS\n\n/foo/OWNERS:\nfile:/bar/OWNERS\n\n/bar/OWNERS:\ncode-owner@example.com\n\nFor a file that matches the per-file rule in \u0027OWNERS\u0027 we would expect\nthat \u0027code-owner@example.com\u0027 is a code owner. \u0027code-owner@example.com\u0027\nis a global code owner in \u0027/bar/OWNERS\u0027 but since it\u0027s imported for a\nper-file rule it becomes a per-file code owner. However what happens is\nthat we wrongly treat \u0027code-owner@example.com\u0027 as a global code owner\nand then it gets ignored due to the \"set noparent\" on the matching\nper-file rule.\n\nIn PathCodeOwners.resolveImports we already had logic to treat global\ncode owners that are imported via a per-file rule as per-file code\nowners, however this worked only for global code owners that were\ndirectly imported by a per-file rule, but not for global code owners\nthat were transitively imported by a per-file rule.\n\nThis got broken by the refactoring that was done in change I6f7723c0a,\nbut we didn\u0027t notice the breakage because we only tested this case\nwithout transitive imports (see\nPathCodeOwnersTest.perFileRuleThatIgnoresGlobalCodeOwnersCanImportGlobalCodeOwnersFromOtherFile).\n\nTo fix this we need to know for an import if any previous import in the\nimport chain was a per-file import. If yes, we should treat the imported\nglobal code owners as per-file code owners.\n\nThe check whether an import imports code owners as global code owners or\nas per-file code owners is done by\nPathCodeOwners.CodeOwnerImport#isGlobal. So far it was only looking at\nthe current import but not at the previous imports. By passing in the\nprevious import (if there is one) we can fix this.\n\nBug: Google b/363000012\nChange-Id: I7c872175fb198603f24a95819877ee1ff98651ec\nSigned-off-by: Edwin Kempin \u003cekempin@google.com\u003e\n",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "585c3e7b22df8a0298ac0e6dc1f97f75e56c7f48",
      "old_mode": 33188,
      "old_path": "java/com/google/gerrit/plugins/codeowners/backend/PathCodeOwners.java",
      "new_id": "3a3180889ae12206ff6f240ec2561af93b816064",
      "new_mode": 33188,
      "new_path": "java/com/google/gerrit/plugins/codeowners/backend/PathCodeOwners.java"
    },
    {
      "type": "modify",
      "old_id": "f0f53c3a171849fe5a9e1edd2ac1141db95a3598",
      "old_mode": 33188,
      "old_path": "javatests/com/google/gerrit/plugins/codeowners/backend/PathCodeOwnersTest.java",
      "new_id": "b9defba8776fcf77d54cbf9a4376970913dcca9d",
      "new_mode": 33188,
      "new_path": "javatests/com/google/gerrit/plugins/codeowners/backend/PathCodeOwnersTest.java"
    }
  ]
}
