From patchwork Thu Sep 21 14:12:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Ricardo Wurmus X-Patchwork-Id: 54137 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 60BDD27BBEA; Thu, 21 Sep 2023 15:14:36 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,SPF_HELO_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 04F8E27BBE9 for ; Thu, 21 Sep 2023 15:14:32 +0100 (BST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qjKRU-0007VI-Lu; Thu, 21 Sep 2023 10:14:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qjKRE-0007SA-D6 for guix-patches@gnu.org; Thu, 21 Sep 2023 10:13:56 -0400 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qjKRE-0002Sa-3f for guix-patches@gnu.org; Thu, 21 Sep 2023 10:13:52 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qjKRN-0006Ts-Vq for guix-patches@gnu.org; Thu, 21 Sep 2023 10:14:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#66138] [PATCH 1/4] etc/committer: Do not recompute changes when there are no definitions. Resent-From: Ricardo Wurmus Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Thu, 21 Sep 2023 14:14:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 66138 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 66138@debbugs.gnu.org Cc: Ricardo Wurmus X-Debbugs-Original-To: guix-patches@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.169530560824863 (code B ref -1); Thu, 21 Sep 2023 14:14:01 +0000 Received: (at submit) by debbugs.gnu.org; 21 Sep 2023 14:13:28 +0000 Received: from localhost ([127.0.0.1]:34547 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qjKQm-0006St-FM for submit@debbugs.gnu.org; Thu, 21 Sep 2023 10:13:28 -0400 Received: from lists.gnu.org ([2001:470:142::17]:57040) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qjKQh-0006Sb-5X for submit@debbugs.gnu.org; Thu, 21 Sep 2023 10:13:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qjKQO-00077Z-LL for guix-patches@gnu.org; Thu, 21 Sep 2023 10:13:01 -0400 Received: from sender4-of-o51.zoho.com ([136.143.188.51]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qjKQJ-0002Jo-Pr for guix-patches@gnu.org; Thu, 21 Sep 2023 10:13:00 -0400 Delivered-To: rekado@elephly.net ARC-Seal: i=1; a=rsa-sha256; t=1695305570; cv=none; d=zohomail.com; s=zohoarc; b=cfitnZEUZJvMqBhA5oE7xb8P0aPduxxj5abBvAkTKzmUCCIJF37XOgyvayGwnI3MeAJ3PcKzrT8aJ15+KeolTrwY27jfFnH+voj4Qtp8EbHudbYp9IjYeW8Iw6PZUvUhSr4LMmiKI3IhKPjYpdiRXeoAyP+/Z4o9aqQN6lq4mpM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695305570; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:MIME-Version:Message-ID:Subject:To; bh=gsth8uFPTU29ahGVgl+RULuetXwLlbOExpqxj5Y7MDM=; b=EB7Ye2WB3ZCKk3eAsd1HY8HCh1GKX+KYCmE0Bns+2QmBK2/6vbQZibEZG/2G+LsKdvEPuSSKVf0zEvE3Q15osfNWjVJ5BD+bn8VDsuV0uWz2Gbuhv+mGnNbtdWCcJ1WwEIgcmyGN0sfZOT4ROn8u5m4bNX30eTwUx/Lu0rZEWBo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=elephly.net; spf=pass smtp.mailfrom=rekado@elephly.net; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1695305570; s=zoho; d=elephly.net; i=rekado@elephly.net; h=From:From:To:To:Cc:Cc:Message-ID:Subject:Subject:Date:Date:MIME-Version:Content-Type:Content-Transfer-Encoding:Message-Id:Reply-To; bh=gsth8uFPTU29ahGVgl+RULuetXwLlbOExpqxj5Y7MDM=; b=ECnfYFaZ88iDEDJ25HenVgrPa19xCoYb5JwoWWJcxvM2HaD8qWd7faqgurkLpAD9 WWEC5SVoGVXYS6qMVf39a8495uvMYBJOwia+UHclF29Mf9hbNusuN6rCRS6dkOedkz/ zata8418t7E+CFqXxPqQ66zoJmtRPJlH8OuMmEs8= Received: from localhost (141.80.245.246 [141.80.245.246]) by mx.zohomail.com with SMTPS id 1695305568374675.7386370858161; Thu, 21 Sep 2023 07:12:48 -0700 (PDT) From: Ricardo Wurmus Message-ID: <0ed6325c8784aacd4b46003bbde8542dd95e08aa.1695305549.git.rekado@elephly.net> Date: Thu, 21 Sep 2023 16:12:41 +0200 X-Mailer: git-send-email 2.41.0 MIME-Version: 1.0 X-ZohoMailClient: External Received-SPF: pass client-ip=136.143.188.51; envelope-from=rekado@elephly.net; helo=sender4-of-o51.zoho.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches * etc/committer.scm.in (main): Reuse previously computed changes if there are no changes to the number of definitions. --- etc/committer.scm.in | 75 +++++++++++++++++++++++--------------------- 1 file changed, 40 insertions(+), 35 deletions(-) base-commit: 4bdb8bd2674c2b630626be43a5cd3c2b65401b52 diff --git a/etc/committer.scm.in b/etc/committer.scm.in index e7f1ca8c45..cc3b572710 100755 --- a/etc/committer.scm.in +++ b/etc/committer.scm.in @@ -388,41 +388,46 @@ (define (main . args) (unless (eqv? 0 (status:exit-val (close-pipe port))) (error "Cannot commit")))) (usleep %delay)) - definitions)) + definitions) - ;; Changes. - (for-each - (match-lambda - ((new old . hunks) - (for-each (lambda (hunk) - (let ((port (open-pipe* OPEN_WRITE - "git" "apply" - "--cached" - "--unidiff-zero"))) - (hunk->patch hunk port) - (unless (eqv? 0 (status:exit-val (close-pipe port))) - (error "Cannot apply"))) - (usleep %delay)) - hunks) - (define copyright-line - (any (lambda (line) (and=> (string-prefix? "+;;; Copyright ©" line) - (const line))) - (hunk-diff-lines (first hunks)))) - (cond - (copyright-line - (add-copyright-line copyright-line)) - (else - (let ((port (open-pipe* OPEN_WRITE "git" "commit" "-F" "-"))) - (change-commit-message* (hunk-file-name (first hunks)) - old new) - (change-commit-message* (hunk-file-name (first hunks)) - old new - port) - (usleep %delay) - (unless (eqv? 0 (status:exit-val (close-pipe port))) - (error "Cannot commit"))))))) - ;; XXX: we recompute the hunks here because previous - ;; insertions lead to offsets. - (new+old+hunks (diff-info)))))) + ;; Changes. + (for-each + (match-lambda + ((new old . hunks) + (for-each (lambda (hunk) + (let ((port (open-pipe* OPEN_WRITE + "git" "apply" + "--cached" + "--unidiff-zero"))) + (hunk->patch hunk port) + (unless (eqv? 0 (status:exit-val (close-pipe port))) + (error "Cannot apply"))) + (usleep %delay)) + hunks) + (define copyright-line + (any (lambda (line) (and=> (string-prefix? "+;;; Copyright ©" line) + (const line))) + (hunk-diff-lines (first hunks)))) + (cond + (copyright-line + (add-copyright-line copyright-line)) + (else + (let ((port (open-pipe* OPEN_WRITE "git" "commit" "-F" "-"))) + (change-commit-message* (hunk-file-name (first hunks)) + old new) + (change-commit-message* (hunk-file-name (first hunks)) + old new + port) + (usleep %delay) + (unless (eqv? 0 (status:exit-val (close-pipe port))) + (error "Cannot commit"))))))) + (new+old+hunks (match definitions + ('() changes) ;reuse + (_ + ;; XXX: we recompute the hunks here because previous + ;; insertions lead to offsets. + (let-values (((definitions changes) + (partition hunk-type (diff-info)))) + changes))))))))) (apply main (cdr (command-line)))