)]}'
{
  "commit": "fcf7221c1e079307ff13d32239b7782d2f1dc48c",
  "tree": "52640b123deaf3240e94e4ff2e54b5f0a225001a",
  "parents": [
    "fa882817a7a69ae1e6bc3a63530ce158b64d2efd"
  ],
  "author": {
    "name": "Jimmy Tanner",
    "email": "jimmyt857@gmail.com",
    "time": "Tue Feb 25 10:34:27 2025 -0800"
  },
  "committer": {
    "name": "GitHub",
    "email": "noreply@github.com",
    "time": "Tue Feb 25 18:34:27 2025 +0000"
  },
  "message": "fix: Gazelle bug with merging py_binary targets in per-file mode and partial update (#2619)\n\nThis PR adds a new unit test. Currently, this is just a failing test\nwithout a fix, and I am still trying to understand the code well enough\nto find the root cause of the issue.\n\nOur team uses Python+Gazelle in a monorepo, and we have a handful of\ndirectories with multiple `.py` files containing `if __name__ \u003d\u003d\n\"__main__\"`. Most of the time these are present for convenience or\nad-hoc invocation. We\u0027re aware of the [recommendation to split these\ninto separate\nfiles](https://github.com/bazelbuild/rules_python/tree/main/gazelle#binaries),\nbut that can cause clutter, and it is non-obvious to most engineers what\nto do when encountering this issue, which presents either as a\nmisleading error message or a no-op without creating the appropriate\ntargets.\n\n**Update**\nThis bug occurs when ALL of the following are true:\n* `python_generation_mode` is set to `file`.\n* Multiple python binary files (files with `if __name__ \u003d\u003d \"__main__\"`)\nexist in the same directory.\n* The directory has no `__main__.py` file.\n* The `BUILD` file in the directory is partially complete, i.e. it\ncontains `py_binary` targets for some of the python files, but not\nothers.\n\nIn this situation, previously absent `py_binary` targets are merged into\nexisting `py_binary` targets instead of being created as new targets.\n\n---------\n\nCo-authored-by: Jimmy Tanner \u003cjimmy@physicalintelligence.company\u003e",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "8a62ab7840bd9f2f13341f82c36ddddb356a3a0a",
      "old_mode": 33188,
      "old_path": "CHANGELOG.md",
      "new_id": "1c075af80bc32af3d142e5f2211a4ccd54ab9172",
      "new_mode": 33188,
      "new_path": "CHANGELOG.md"
    },
    {
      "type": "modify",
      "old_id": "a9483372e252f778b173107ac61bd84d11aa8c52",
      "old_mode": 33188,
      "old_path": "gazelle/python/kinds.go",
      "new_id": "7a0639abd3180c71eb2b650ba133707ddd9e6517",
      "new_mode": 33188,
      "new_path": "gazelle/python/kinds.go"
    },
    {
      "type": "add",
      "old_id": "0000000000000000000000000000000000000000",
      "old_mode": 0,
      "old_path": "/dev/null",
      "new_id": "63b547f0b3ec1a9c643236f55d4b7253f91abfc2",
      "new_mode": 33188,
      "new_path": "gazelle/python/testdata/binary_without_entrypoint_per_file_generation_partial_update/BUILD.in"
    },
    {
      "type": "add",
      "old_id": "0000000000000000000000000000000000000000",
      "old_mode": 0,
      "old_path": "/dev/null",
      "new_id": "8f49cccd9fe597918e7c7a449da174bb80773306",
      "new_mode": 33188,
      "new_path": "gazelle/python/testdata/binary_without_entrypoint_per_file_generation_partial_update/BUILD.out"
    },
    {
      "type": "add",
      "old_id": "0000000000000000000000000000000000000000",
      "old_mode": 0,
      "old_path": "/dev/null",
      "new_id": "5aa499f4ad65b16933779e68adf3871a305db8a8",
      "new_mode": 33188,
      "new_path": "gazelle/python/testdata/binary_without_entrypoint_per_file_generation_partial_update/README.md"
    },
    {
      "type": "add",
      "old_id": "0000000000000000000000000000000000000000",
      "old_mode": 0,
      "old_path": "/dev/null",
      "new_id": "faff6af87ac0ef60c3f9dacae80ca00b08118b58",
      "new_mode": 33188,
      "new_path": "gazelle/python/testdata/binary_without_entrypoint_per_file_generation_partial_update/WORKSPACE"
    },
    {
      "type": "add",
      "old_id": "0000000000000000000000000000000000000000",
      "old_mode": 0,
      "old_path": "/dev/null",
      "new_id": "9c97da4809b107daa359e34622fcac49d92d42b0",
      "new_mode": 33188,
      "new_path": "gazelle/python/testdata/binary_without_entrypoint_per_file_generation_partial_update/a.py"
    },
    {
      "type": "add",
      "old_id": "0000000000000000000000000000000000000000",
      "old_mode": 0,
      "old_path": "/dev/null",
      "new_id": "9c97da4809b107daa359e34622fcac49d92d42b0",
      "new_mode": 33188,
      "new_path": "gazelle/python/testdata/binary_without_entrypoint_per_file_generation_partial_update/b.py"
    },
    {
      "type": "add",
      "old_id": "0000000000000000000000000000000000000000",
      "old_mode": 0,
      "old_path": "/dev/null",
      "new_id": "346ecd7ae8e70a2fba44933e144d08daae73c269",
      "new_mode": 33188,
      "new_path": "gazelle/python/testdata/binary_without_entrypoint_per_file_generation_partial_update/test.yaml"
    }
  ]
}
