)]}'
{
  "commit": "e8f6050cfb990452fcfc685bc9ccbae79113fa36",
  "tree": "93af43437401210085544c1da53fcd883a4674a3",
  "parents": [
    "105470cd79f6d8c62b9156ce45e992895b01b13b"
  ],
  "author": {
    "name": "Simon Marchi",
    "email": "simon.marchi@efficios.com",
    "time": "Mon Mar 11 11:09:43 2024 -0400"
  },
  "committer": {
    "name": "Simon Marchi",
    "email": "simon.marchi@efficios.com",
    "time": "Wed Mar 20 11:54:06 2024 -0400"
  },
  "message": "Add .pre-commit-config.yaml\n\nAdd a pre-commit [1] config file, with a single hook to run black on the\ngdb directory whenever a Python file is modified.  We can always add\nmore hooks if we find some that are useful.\n\nUsing pre-commit to run hooks is opt-in, as in it\u0027s not mandatory at all\nfor development, but it can be useful to run some checks that are easy\nto forget (like running black).  The hooks run locally on the\ndeveloper\u0027s machine when doing `git commit` (although they can also be\nconfigured to run at other stages of the git workflow).\n\nFollow these instructions to install the hooks in your local development\ngit repository:\n\n - Install pre-commit the way you prefer.  It can be using your OS\n   package manager if it has a recent enough version, or using `pip\n   install pre-commit`.\n - Go to the binutils-gdb repository and run `pre-commit install`.\n\nThis installs a git hook at `.git/hooks/pre-commit`.\n\nNow, whenever you modify and try to commit a Python file, pre-commit\nwill run black on it.  For instance, if I try to insert something\nmisformatted, I get this when doing `git commit`:\n\n    $ git commit\n    black....................................................................Failed\n    - hook id: black\n    - files were modified by this hook\n\n    reformatted gdb/python/lib/gdb/dap/breakpoint.py\n\n    All done! ✨ 🍰 ✨\n    1 file reformatted.\n\nAt this point, black has already reformatted the files in place, so the\nchanges that fix the formatting are ready to add and commit.  black is\nonly ran on files modified in the commit.\n\nThe hook defines a black version, which is downloaded at `pre-commit\ninstall` time.  pre-commit manages its own env at\n`$HOME/.cache/pre-commit/\u003csome-hash\u003e`, so it won\u0027t use the version of\nblack you have installed already.  This may help ensure that\ncontributors use the right black version.\n\nThe procedure when there is a new version of black (or a new version of\nany hook we might be using in the future) is:\n\n - Modify .pre-commit-config.yaml to change the version number, push to\n   the upstream repo.\n - Have contributors run `pre-commit autoupdate` to make their local\n   pre-commit installation update the hooks.\n\nIt is possible to have pre-commit skip some hooks if needed [2].\n\nI will add these instructions to the wiki if this patch gets merged, so\nthey are easy to find.  We could perhaps think of having a\ngdb/CONTRIBUTING document of some sort checked in the repo with that\nkind of information.\n\nI have not used pre-commit in a real project before, but have heard good\nthings from it.  If we want to give it a try before pushing it to the\nrepo, some volunteers can copy the .pre-commit-config.yaml file locally\nand try it for some time.  However, pushing the file upstream is not\ngoing to impact anybody who doesn\u0027t care about it, so I\u0027d say it\u0027s\nrelatively low-risk to push it right now.\n\n[1] https://pre-commit.com\n[2] https://pre-commit.com/#temporarily-disabling-hooks\n\nChange-Id: Id00cda882f5140914a670c87e574fa7f2f972099\nAcked-By: Tom Tromey \u003ctromey@adacore.com\u003e\nAcked-By: Guinevere Larsen \u003cblarsen@redhat.com\u003e\nAcked-By: Andrew Burgess \u003caburgess@redhat.com\u003e\n",
  "tree_diff": [
    {
      "type": "add",
      "old_id": "0000000000000000000000000000000000000000",
      "old_mode": 0,
      "old_path": "/dev/null",
      "new_id": "b8d1ef7dc74d6c30232e56a710624ab49bbb46da",
      "new_mode": 33188,
      "new_path": ".pre-commit-config.yaml"
    },
    {
      "type": "modify",
      "old_id": "91b9f774ada4902df920252c2027f1b7762f696f",
      "old_mode": 33188,
      "old_path": "ChangeLog",
      "new_id": "e1b17767d47f893f3e691db7f9aeaa85b8fb147c",
      "new_mode": 33188,
      "new_path": "ChangeLog"
    }
  ]
}
