Message ID | 20241129161707.25292-3-tdevries@suse.de |
---|---|
State | New |
Headers |
Return-Path: <gdb-patches-bounces~patchwork=sourceware.org@sourceware.org> X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 7B58D3858CDB for <patchwork@sourceware.org>; Fri, 29 Nov 2024 16:18:13 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7B58D3858CDB Authentication-Results: sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=u1Jflj/2; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=Rg6PaB9c; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=u1Jflj/2; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=Rg6PaB9c X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2a07:de40:b251:101:10:150:64:1]) by sourceware.org (Postfix) with ESMTPS id 5F54D3858C60 for <gdb-patches@sourceware.org>; Fri, 29 Nov 2024 16:16:03 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 5F54D3858C60 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 5F54D3858C60 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a07:de40:b251:101:10:150:64:1 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1732896963; cv=none; b=hhm64nzV2rDa9muAcDbVsMCioj2TE6GA9KYeWo9rOq353zMXY9LaWfTvWAw/KaCP14pHrTU2NJpkwYIV7KNvqVTEbennGCmEvCnvNUqf75u3TANTGvUL2dluDCgvmtsZq9coptNjlOikFkQOEyArqDSBzO7x3R5znopOy9rzIo8= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1732896963; c=relaxed/simple; bh=5oO48pkP0u47seqddnkF/BPNweO9KnEsztQT7H4tx5s=; h=DKIM-Signature:DKIM-Signature:DKIM-Signature:DKIM-Signature:From: To:Subject:Date:Message-Id:MIME-Version; b=S7k96jpG+JTKHkitJHStzp1SE9labvd7KJwikrrqz1TSETTVzgt6VgOrjNGAdKFSwfnrchvOxZkQlLRA1SnJpM3BqZ/AQBbcLdB14sgnbXgyY53jT3Sh7ppHSh/2omcPNNyGwPt0nSa5JWCPSPA2DNl5OU22sHnArw7KFrgRp2w= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5F54D3858C60 Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 6151A21125 for <gdb-patches@sourceware.org>; Fri, 29 Nov 2024 16:16:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1732896962; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=aSA9B8YFPjbZ1zpBz5RkUdtVHskAFbg5d+SyHmkZDhc=; b=u1Jflj/2Ab4mqR8InNj9u8PojAtYH/xhEmWUVTwhpvO+o2YynrfkRGwo6u+nQu83SgG7Pv k3JxkEdnQlTY2qD6AGPmCDgYaewv+1sb8+JH77K9cKtzQWwEXIUrrA/8f6BpX32ydKxlbU rcBUKjR+Wbgb4RkNdt46sE81WDtaiuU= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1732896962; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=aSA9B8YFPjbZ1zpBz5RkUdtVHskAFbg5d+SyHmkZDhc=; b=Rg6PaB9ckals5b7By0wBM2WM9I+ZfjcZbmzOUH0ManLc/07I/55Pu0WFtSwSi/dL7LMNtA yhrZY0h7nyN+XpBQ== Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1732896962; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=aSA9B8YFPjbZ1zpBz5RkUdtVHskAFbg5d+SyHmkZDhc=; b=u1Jflj/2Ab4mqR8InNj9u8PojAtYH/xhEmWUVTwhpvO+o2YynrfkRGwo6u+nQu83SgG7Pv k3JxkEdnQlTY2qD6AGPmCDgYaewv+1sb8+JH77K9cKtzQWwEXIUrrA/8f6BpX32ydKxlbU rcBUKjR+Wbgb4RkNdt46sE81WDtaiuU= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1732896962; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=aSA9B8YFPjbZ1zpBz5RkUdtVHskAFbg5d+SyHmkZDhc=; b=Rg6PaB9ckals5b7By0wBM2WM9I+ZfjcZbmzOUH0ManLc/07I/55Pu0WFtSwSi/dL7LMNtA yhrZY0h7nyN+XpBQ== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 49A2F13AA5 for <gdb-patches@sourceware.org>; Fri, 29 Nov 2024 16:16:02 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id AGudEMLoSWe9VgAAD6G6ig (envelope-from <tdevries@suse.de>) for <gdb-patches@sourceware.org>; Fri, 29 Nov 2024 16:16:02 +0000 From: Tom de Vries <tdevries@suse.de> To: gdb-patches@sourceware.org Subject: [RFC 2/2] [precommit] Add codespell Date: Fri, 29 Nov 2024 17:17:07 +0100 Message-Id: <20241129161707.25292-3-tdevries@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20241129161707.25292-1-tdevries@suse.de> References: <20241129161707.25292-1-tdevries@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.80 X-Spamd-Result: default: False [-2.80 / 50.00]; BAYES_HAM(-3.00)[99.99%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; FUZZY_BLOCKED(0.00)[rspamd.com]; RCVD_VIA_SMTP_AUTH(0.00)[]; RCPT_COUNT_ONE(0.00)[1]; ARC_NA(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:mid,imap1.dmz-prg2.suse.org:helo]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; TO_DN_NONE(0.00)[]; PREVIOUSLY_DELIVERED(0.00)[gdb-patches@sourceware.org]; RCVD_TLS_ALL(0.00)[] X-Spam-Level: X-Spam-Status: No, score=-12.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list <gdb-patches.sourceware.org> List-Unsubscribe: <https://sourceware.org/mailman/options/gdb-patches>, <mailto:gdb-patches-request@sourceware.org?subject=unsubscribe> List-Archive: <https://sourceware.org/pipermail/gdb-patches/> List-Post: <mailto:gdb-patches@sourceware.org> List-Help: <mailto:gdb-patches-request@sourceware.org?subject=help> List-Subscribe: <https://sourceware.org/mailman/listinfo/gdb-patches>, <mailto:gdb-patches-request@sourceware.org?subject=subscribe> Errors-To: gdb-patches-bounces~patchwork=sourceware.org@sourceware.org |
Series |
Add codespell hook
|
|
Checks
Context | Check | Description |
---|---|---|
linaro-tcwg-bot/tcwg_gdb_build--master-aarch64 | warning | Skipped upon request |
linaro-tcwg-bot/tcwg_gdb_build--master-arm | warning | Skipped upon request |
Commit Message
Tom de Vries
Nov. 29, 2024, 4:17 p.m. UTC
Add a pre-commit codespell hook. We use a custom one (gdb/contrib/codespell.sh) rather than the regular one because: - it allows us downgrade detected spelling mistakes from errors aborting a commit, to warnings that can be inspected after the commit has finished, and - it allows us to check only the staged part of a file rather than the entire file, greatly reducing noise. Both of these items are intended to avoid disrupting developer workflow as much as possible, while giving useful information. To demonstrate usage, consider gdb/ada-lang.c, which is not codespell clean: ... $ ./gdb/contrib/codespell.sh gdb/ada-lang.c gdb/ada-lang.c:847: Olt ==> Old gdb/ada-lang.c:858: Onot ==> Note, Not gdb/ada-lang.c:1533: alpha-numeric ==> alphanumeric gdb/ada-lang.c:3047: arithmetics ==> arithmetic gdb/ada-lang.c:5440: re-use ==> reuse gdb/ada-lang.c:9353: swith ==> switch gdb/ada-lang.c:9771: separatly ==> separately gdb/ada-lang.c:11749: suport ==> support gdb/ada-lang.c:11756: suport ==> support gdb/ada-lang.c:13655: statics ==> statistics ... Now let's introduce a typo: ... $ echo "This is the wrong adres" >> gdb/ada-lang.c ... and commit it: ... $ git commit -a -m typo black................................................(no files to check)Skipped flake8...............................................(no files to check)Skipped isort................................................(no files to check)Skipped gdb/scripts/codespell.sh --always-pass --staged..........................Passed - hook id: codespell - duration: 0.29s > This is the wrong adres gdb/ada-lang.c: adres ==> address [precommit/codespell-2 47baee9867b] typo 1 file changed, 1 insertion(+) ... As we can see: - the commit succeeded, - the introduced typo was noticed, and - only the introduced typo was noticed. The current implementation of gdb/contrib/codespell.sh --staged fails to print the line number, so I've added -C0 to make the context clear, which get us the first line here: ... > This is the wrong adres gdb/ada-lang.c: adres ==> address ... --- .pre-commit-config.yaml | 9 +++++++++ 1 file changed, 9 insertions(+)
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 070631c0f16..b1b4c2677b3 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -59,3 +59,12 @@ repos: - id: isort types_or: [file] files: 'gdb/.*\.py(\.in)?$' + - repo: local + hooks: + - id: codespell + name: gdb/scripts/codespell.sh --always-pass --staged + language: script + entry: ./gdb/contrib/codespell.sh + args: [ "--always-pass", "--staged", "--", "-C0", "--" ] + files: '^(gdb|gdbsupport|gdbserver)/' + verbose: true