From unknown Sat Sep 06 02:03:36 2025 X-Loop: help-debbugs@gnu.org Subject: [bug#44591] [PATCH 0/1] Add 'patch-headers' lint checker Resent-From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Thu, 12 Nov 2020 12:01:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 44591 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 44591@debbugs.gnu.org Cc: Ludovic =?UTF-8?Q?Court=C3=A8s?= X-Debbugs-Original-To: guix-patches@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.160518244510952 (code B ref -1); Thu, 12 Nov 2020 12:01:01 +0000 Received: (at submit) by debbugs.gnu.org; 12 Nov 2020 12:00:45 +0000 Received: from localhost ([127.0.0.1]:43832 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kdBHN-0002qW-Fw for submit@debbugs.gnu.org; Thu, 12 Nov 2020 07:00:45 -0500 Received: from lists.gnu.org ([209.51.188.17]:55754) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kdBHH-0002qK-JM for submit@debbugs.gnu.org; Thu, 12 Nov 2020 07:00:39 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:56466) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kdBHD-0008MC-NE for guix-patches@gnu.org; Thu, 12 Nov 2020 07:00:35 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]:50616) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kdBHC-0004wK-Ti; Thu, 12 Nov 2020 07:00:30 -0500 Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=55826 helo=gnu.org) by fencepost.gnu.org with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1kdBHB-0004Re-P7; Thu, 12 Nov 2020 07:00:30 -0500 From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Date: Thu, 12 Nov 2020 13:00:17 +0100 Message-Id: <20201112120017.7145-1-ludo@gnu.org> X-Mailer: git-send-email 2.29.2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Hi! There’s the unwritten (?) guideline that patches should start with a short comment indicating what they do, where they come from, and what their upstream status is. The ‘patch-headers’ checker that this patch adds check for the presence of a comment at the start of each referenced patch. It currently reports 59 issues. WDYT? Ludo’. Ludovic Courtès (1): lint: Add 'patch-headers' checker. guix/lint.scm | 55 +++++++++++++++++++++++++++++++++++++++++++++++++ tests/lint.scm | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 111 insertions(+) -- 2.29.2 From unknown Sat Sep 06 02:03:36 2025 X-Loop: help-debbugs@gnu.org Subject: [bug#44591] [PATCH 1/1] lint: Add 'patch-headers' checker. References: <20201112120017.7145-1-ludo@gnu.org> In-Reply-To: <20201112120017.7145-1-ludo@gnu.org> Resent-From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Thu, 12 Nov 2020 12:05:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 44591 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 44591@debbugs.gnu.org Cc: Ludovic =?UTF-8?Q?Court=C3=A8s?= Received: via spool by 44591-submit@debbugs.gnu.org id=B44591.160518265511307 (code B ref 44591); Thu, 12 Nov 2020 12:05:02 +0000 Received: (at 44591) by debbugs.gnu.org; 12 Nov 2020 12:04:15 +0000 Received: from localhost ([127.0.0.1]:43843 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kdBKp-0002wJ-19 for submit@debbugs.gnu.org; Thu, 12 Nov 2020 07:04:15 -0500 Received: from eggs.gnu.org ([209.51.188.92]:57258) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kdBKn-0002w6-09 for 44591@debbugs.gnu.org; Thu, 12 Nov 2020 07:04:13 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]:50677) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kdBKh-0006Dq-G8; Thu, 12 Nov 2020 07:04:07 -0500 Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=55840 helo=gnu.org) by fencepost.gnu.org with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1kdBKh-0000PF-2h; Thu, 12 Nov 2020 07:04:07 -0500 From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Date: Thu, 12 Nov 2020 13:03:59 +0100 Message-Id: <20201112120359.8763-1-ludo@gnu.org> X-Mailer: git-send-email 2.29.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) * guix/lint.scm (check-patch-headers): New procedure. (%local-checkers): Add 'patch-headers' checker. * tests/lint.scm ("patch headers: no warnings") ("patch headers: missing comment", "patch headers: empty") ("patch headers: patch not found"): New tests. --- guix/lint.scm | 55 +++++++++++++++++++++++++++++++++++++++++++++++++ tests/lint.scm | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 111 insertions(+) diff --git a/guix/lint.scm b/guix/lint.scm index 91dbc806dc..0b38ca0d33 100644 --- a/guix/lint.scm +++ b/guix/lint.scm @@ -35,6 +35,8 @@ #:use-module (guix http-client) #:use-module (guix packages) #:use-module (guix i18n) + #:use-module ((guix gexp) + #:select (local-file? local-file-absolute-file-name)) #:use-module (guix licenses) #:use-module (guix records) #:use-module (guix grafts) @@ -73,6 +75,7 @@ check-inputs-should-be-native check-inputs-should-not-be-an-input-at-all check-patch-file-names + check-patch-headers check-synopsis-style check-derivation check-home-page @@ -712,6 +715,54 @@ patch could not be found." (_ #f)) patches))))) +(define (check-patch-headers package) + "Check that PACKAGE's patches start with a comment. Return a list of +warnings." + (define (blank? str) + (string-every char-set:blank str)) + + (define (patch-header-warnings patch) + (call-with-input-file patch + (lambda (port) + ;; Read from PORT until a non-blank line is found or EOF is reached. + (let loop () + (let ((line (read-line port))) + (cond ((eof-object? line) + (list (make-warning package + (G_ "~a: empty patch") + (list (basename patch)) + #:field 'source))) + ((blank? line) + (loop)) + ((or (string-prefix? "--- " line) + (string-prefix? "+++ " line)) + (list (make-warning package + (G_ "~a: patch lacks comment and \ +upstream status") + (list (basename patch)) + #:field 'source))) + (else + '()))))))) + + (guard (c ((formatted-message? c) ;raised by 'search-patch' + (list (%make-warning package + (formatted-message-string c) + (formatted-message-arguments c) + #:field 'source)))) + (let ((patches (if (origin? (package-source package)) + (origin-patches (package-source package)) + '()))) + (append-map (lambda (patch) + ;; Dismiss PATCH if it's an origin or similar. + (cond ((string? patch) + (patch-header-warnings patch)) + ((local-file? patch) + (patch-header-warnings + (local-file-absolute-file-name patch))) + (else + '()))) + patches)))) + (define (escape-quotes str) "Replace any quote character in STR by an escaped quote character." (list->string @@ -1417,6 +1468,10 @@ or a list thereof") (name 'patch-file-names) (description "Validate file names and availability of patches") (check check-patch-file-names)) + (lint-checker + (name 'patch-headers) + (description "Validate patch headers") + (check check-patch-headers)) (lint-checker (name 'formatting) (description "Look for formatting issues in the source") diff --git a/tests/lint.scm b/tests/lint.scm index 95abd71378..bd052842f3 100644 --- a/tests/lint.scm +++ b/tests/lint.scm @@ -36,6 +36,8 @@ #:use-module (guix lint) #:use-module (guix ui) #:use-module (guix swh) + #:use-module ((guix gexp) #:select (local-file)) + #:use-module ((guix utils) #:select (call-with-temporary-directory)) #:use-module (gnu packages) #:use-module (gnu packages glib) #:use-module (gnu packages pkg-config) @@ -344,6 +346,60 @@ (list (search-patch "this-patch-does-not-exist!")))))))) (check-patch-file-names pkg)))) +(test-assert "patch headers: no warnings" + (call-with-temporary-directory + (lambda (directory) + (call-with-output-file (string-append directory "/t.patch") + (lambda (port) + (display "This is a patch.\n\n--- a\n+++ b\n" + port))) + + (parameterize ((%patch-path (list directory))) + (let ((pkg (dummy-package "x" + (source (dummy-origin + (patches (search-patches "t.patch"))))))) + (null? (check-patch-headers pkg))))))) + +(test-equal "patch headers: missing comment" + "t.patch: patch lacks comment and upstream status" + (call-with-temporary-directory + (lambda (directory) + (call-with-output-file (string-append directory "/t.patch") + (lambda (port) + (display "\n--- a\n+++ b\n" + port))) + + (parameterize ((%patch-path (list directory))) + (let ((pkg (dummy-package "x" + (source (dummy-origin + (patches (search-patches "t.patch"))))))) + (single-lint-warning-message (check-patch-headers pkg))))))) + +(test-equal "patch headers: empty" + "t.patch: empty patch" + (call-with-temporary-directory + (lambda (directory) + (call-with-output-file (string-append directory "/t.patch") + (const #t)) + + (parameterize ((%patch-path '())) + (let ((pkg (dummy-package "x" + (source (dummy-origin + (patches + (list (local-file + (string-append directory + "/t.patch"))))))))) + (single-lint-warning-message (check-patch-headers pkg))))))) + +(test-equal "patch headers: patch not found" + "does-not-exist.patch: patch not found\n" + (parameterize ((%patch-path '())) + (let ((pkg (dummy-package "x" + (source (dummy-origin + (patches + (search-patches "does-not-exist.patch"))))))) + (single-lint-warning-message (check-patch-headers pkg))))) + (test-equal "derivation: invalid arguments" "failed to create x86_64-linux derivation: (wrong-type-arg \"map\" \"Wrong type argument: ~S\" (invalid-module) ())" (match (let ((pkg (dummy-package "x" -- 2.29.2 From unknown Sat Sep 06 02:03:36 2025 MIME-Version: 1.0 X-Mailer: MIME-tools 5.505 (Entity 5.505) X-Loop: help-debbugs@gnu.org From: help-debbugs@gnu.org (GNU bug Tracking System) To: Ludovic =?UTF-8?Q?Court=C3=A8s?= Subject: bug#44591: closed (Re: [bug#44591] [PATCH 0/1] Add 'patch-headers' lint checker) Message-ID: References: <877dqfc4xg.fsf@gnu.org> <20201112120017.7145-1-ludo@gnu.org> X-Gnu-PR-Message: they-closed 44591 X-Gnu-PR-Package: guix-patches X-Gnu-PR-Keywords: patch Reply-To: 44591@debbugs.gnu.org Date: Sat, 21 Nov 2020 11:43:01 +0000 Content-Type: multipart/mixed; boundary="----------=_1605958981-18047-1" This is a multi-part message in MIME format... ------------=_1605958981-18047-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Your bug report #44591: [PATCH 0/1] Add 'patch-headers' lint checker which was filed against the guix-patches package, has been closed. The explanation is attached below, along with your original report. If you require more details, please reply to 44591@debbugs.gnu.org. --=20 44591: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D44591 GNU Bug Tracking System Contact help-debbugs@gnu.org with problems ------------=_1605958981-18047-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at 44591-done) by debbugs.gnu.org; 21 Nov 2020 11:42:15 +0000 Received: from localhost ([127.0.0.1]:45015 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kgRHS-0004g4-RQ for submit@debbugs.gnu.org; Sat, 21 Nov 2020 06:42:15 -0500 Received: from eggs.gnu.org ([209.51.188.92]:60412) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kgRHQ-0004fr-SB for 44591-done@debbugs.gnu.org; Sat, 21 Nov 2020 06:42:13 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]:56500) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kgRHL-0004vy-L5 for 44591-done@debbugs.gnu.org; Sat, 21 Nov 2020 06:42:07 -0500 Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=42286 helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1kgRHI-0000DU-Tl for 44591-done@debbugs.gnu.org; Sat, 21 Nov 2020 06:42:07 -0500 From: =?utf-8?Q?Ludovic_Court=C3=A8s?= To: 44591-done@debbugs.gnu.org Subject: Re: [bug#44591] [PATCH 0/1] Add 'patch-headers' lint checker References: <20201112120017.7145-1-ludo@gnu.org> Date: Sat, 21 Nov 2020 12:42:03 +0100 In-Reply-To: <20201112120017.7145-1-ludo@gnu.org> ("Ludovic =?utf-8?Q?Cour?= =?utf-8?Q?t=C3=A8s=22's?= message of "Thu, 12 Nov 2020 13:00:17 +0100") Message-ID: <877dqfc4xg.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 44591-done X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Ludovic Court=C3=A8s skribis: > There=E2=80=99s the unwritten (?) guideline that patches should start wit= h a > short comment indicating what they do, where they come from, and what > their upstream status is. > > The =E2=80=98patch-headers=E2=80=99 checker that this patch adds check fo= r the > presence of a comment at the start of each referenced patch. It > currently reports 59 issues. > > WDYT? > > Ludo=E2=80=99. > > Ludovic Court=C3=A8s (1): > lint: Add 'patch-headers' checker. Pushed as 4f156c259f984f4f5a3692364746446294ee102c. Ludo=E2=80=99. ------------=_1605958981-18047-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at submit) by debbugs.gnu.org; 12 Nov 2020 12:00:45 +0000 Received: from localhost ([127.0.0.1]:43832 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kdBHN-0002qW-Fw for submit@debbugs.gnu.org; Thu, 12 Nov 2020 07:00:45 -0500 Received: from lists.gnu.org ([209.51.188.17]:55754) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kdBHH-0002qK-JM for submit@debbugs.gnu.org; Thu, 12 Nov 2020 07:00:39 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:56466) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kdBHD-0008MC-NE for guix-patches@gnu.org; Thu, 12 Nov 2020 07:00:35 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]:50616) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kdBHC-0004wK-Ti; Thu, 12 Nov 2020 07:00:30 -0500 Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=55826 helo=gnu.org) by fencepost.gnu.org with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1kdBHB-0004Re-P7; Thu, 12 Nov 2020 07:00:30 -0500 From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= To: guix-patches@gnu.org Subject: [PATCH 0/1] Add 'patch-headers' lint checker Date: Thu, 12 Nov 2020 13:00:17 +0100 Message-Id: <20201112120017.7145-1-ludo@gnu.org> X-Mailer: git-send-email 2.29.2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: submit Cc: =?UTF-8?q?Ludovic=20Court=C3=A8s?= X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Hi! There’s the unwritten (?) guideline that patches should start with a short comment indicating what they do, where they come from, and what their upstream status is. The ‘patch-headers’ checker that this patch adds check for the presence of a comment at the start of each referenced patch. It currently reports 59 issues. WDYT? Ludo’. Ludovic Courtès (1): lint: Add 'patch-headers' checker. guix/lint.scm | 55 +++++++++++++++++++++++++++++++++++++++++++++++++ tests/lint.scm | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 111 insertions(+) -- 2.29.2 ------------=_1605958981-18047-1--