From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 8E2B13858CDB for ; Wed, 20 Mar 2024 13:44:10 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 8E2B13858CDB Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 8E2B13858CDB Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1710942252; cv=none; b=vCOX+eKSw0YL4HPVHJOvwTynbeRRnMuLyBnXkrwvxTK0Q6wTs5W4eMbb7v/CvT4fbqgXKUg7cqEgFTArXwuvjps45h/d/c0pJzNGYif/JlJfJ27GiuXpegeofdOsvvWvSY6DNEyKb5oVU9lMp0O5BE4LVQf+g94zkmwaw8AhShw= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1710942252; c=relaxed/simple; bh=7In6QC0yiwyEqmL2A17847DwAHRrjljvDQ1uOm7yO1w=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=SFRorDWHQRGmY6iPNCOUFGAm7S9n551ZqfP9tRqSsJIXDHULK/0CHCZbDVoOSrPit0YVCZSC9amSwwk7NR3jjvfKEojl/qbS88NAYA40HlAJmwerM4Sq6dKZL/89yfn58j81XW42FmMzhu6JgxxKCSQi6MRDGwU51iZrMAFXR3Y= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1710942250; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=SM0h0Am8MABqtv3uj+OWpn3iJx5kqSO+ZWVBZMnOvVo=; b=B+4UrU1Qrygf93duiQE7gSj4y59kORqtCDrcXLONeIP3fkdfUEk6g0BFUzujaekE/hGo9F ybDWCClok6TYkZAMFDFBYLlUUV4InRsjzmbh9jYnpAV36I0loVS1fub/c4s6sFrCugmLP/ TbkEyTP59yzUoisx7UIseCFBxO2fDG8= Received: from mail-ej1-f70.google.com (mail-ej1-f70.google.com [209.85.218.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-412-agIHKuitMcGs0N2bNb7UmA-1; Wed, 20 Mar 2024 09:44:08 -0400 X-MC-Unique: agIHKuitMcGs0N2bNb7UmA-1 Received: by mail-ej1-f70.google.com with SMTP id a640c23a62f3a-a46d55f5d31so162080066b.1 for ; Wed, 20 Mar 2024 06:44:08 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710942247; x=1711547047; h=content-transfer-encoding:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=SM0h0Am8MABqtv3uj+OWpn3iJx5kqSO+ZWVBZMnOvVo=; b=U12+1Y7hMksJ5HAKAUg0I55PFPm49/ynnPUOvO/Ckx+AueQ1KnFNsrxE+PpoggbXoP 3lbqP2wVVzM2C+Pi4VUvvvYeFM+cZcAx0eNw8WHZnE6NWS9RypZnQGwmPw8EzpfUiW8t WeKNDLvzMMJ0qeSp5w8q/E44hyunk16pLWR4ox0ZDHYiXYZ4CnPtVSKKGXzpW8U0UmIT KZQSwnGAXOFSZoTMkXcwVc8vYxCiTVudnvPX2WlMhpoMLJsPRf2erpcJd7Y/vki6nuYZ bdclWZXbCt5kAQpftJT8eNNmv/rhD0FFRRHhcyT93pNziS2k9Hvm5hxZnjGIA4cUN9kl mHaw== X-Forwarded-Encrypted: i=1; AJvYcCVMBNKoBGdfLfFa5+x7dE/DVtJ4u51/vmg0jVhS10v2yA+LJhNMDsRy3fhuQ/DQgBxIY59uDnnM2rM/5+GlqkcDi4YxX+5GiLRkwQ== X-Gm-Message-State: AOJu0YxS+DWzym/CqCUsXEBRkFAy8cYgNnDfBQotRvnii4j5txWHO2Ck GpqNP5jwz3YS76PYkM7lyoAgUD+uOJ3CzWQVaD8DgwY6SKJOUls8bn8Unft+wxdiFMSkz8IVzKA PlC420ZM9gmq0748R3pBUl0oWJtEDQWZi7vP1eu3k82QFH4al7zu3EzCDXxg= X-Received: by 2002:a17:906:190e:b0:a46:24fa:ea9f with SMTP id a14-20020a170906190e00b00a4624faea9fmr10887352eje.37.1710942247475; Wed, 20 Mar 2024 06:44:07 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH/p+KpFlbPKkHRnoBZRHfGRDs0aqf9puG9O9+a4uI1XrH/CKg1BfRofnrZsCFGZYSPGdaAYQ== X-Received: by 2002:a17:906:190e:b0:a46:24fa:ea9f with SMTP id a14-20020a170906190e00b00a4624faea9fmr10887330eje.37.1710942246898; Wed, 20 Mar 2024 06:44:06 -0700 (PDT) Received: from localhost (185.223.159.143.dyn.plus.net. [143.159.223.185]) by smtp.gmail.com with ESMTPSA id lm9-20020a170906980900b00a46c0191306sm3455067ejb.213.2024.03.20.06.44.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Mar 2024 06:44:06 -0700 (PDT) From: Andrew Burgess To: Simon Marchi , gdb-patches@sourceware.org Cc: binutils@sourceware.org, Simon Marchi Subject: Re: [PATCH] gdb: add .pre-commit-config.yaml In-Reply-To: <20240311150947.71762-1-simon.marchi@efficios.com> References: <20240311150947.71762-1-simon.marchi@efficios.com> Date: Wed, 20 Mar 2024 13:44:05 +0000 Message-ID: <87jzlxt3ve.fsf@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-6.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Simon Marchi writes: > [I'm CCing the binutils list because this patch adds a file at the > top-level, but it only concerns gdb for now. But if you are want to use > pre-commit for some things in binutils too, you are welcome to use that > file for your needs.] > > Add a pre-commit [1] config file, with a single hook to run black > whenever a Python file is modified. We can always add more hooks if we > find some that are useful. > > Using pre-commit to run hooks is opt-in, as in it's not mandatory at all > for development, but it can be useful to run some checks that are easy > to forget (like running black). The hooks run locally on the > developer's machine when doing `git commit` (although they can also be > configured to run at other stages of the git workflow). > > Follow these instructions to install the hooks in your local development > git repository: > > - Install pre-commit the way you prefer. It can be using your OS > package manager if it has a recent enough version, or using `pip > install pre-commit`. > - Go to the binutils-gdb repository and run `pre-commit install`. > > This installs a git hook at `.git/hooks/pre-commit`. > > Now, whenever you modify and try to commit a Python file, pre-commit > will run black on it. For instance, if I try to insert something > misformatted, I get this when doing `git commit`: > > $ git commit > black................................................................= ....Failed > - hook id: black > - files were modified by this hook > > reformatted gdb/python/lib/gdb/dap/breakpoint.py > > All done! =E2=9C=A8 =F0=9F=8D=B0 =E2=9C=A8 > 1 file reformatted. > > At this point, black has already reformatted the files in place, so the > changes that fix the formatting are ready to add and commit. black is > only ran on files modified in the commit. > > The hook defines a black version, which is downloaded at `pre-commit > install` time. pre-commit manages its own env at > `$HOME/.cache/pre-commit/`, so it won't use the version of > black you have installed already. This may help ensure that > contributors use the right black version. This sounds great. I got a recent commit wrong because the version of black was rolled forward and I'd not updated locally, so this would really help. +1 from me for making this a thing. Thanks, Andrew