From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id iJOnLaO+OGFm2wAAgWs5BA (envelope-from ) for ; Wed, 08 Sep 2021 15:46:11 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id sPI4KaO+OGF5PAAA1q6Kng (envelope-from ) for ; Wed, 08 Sep 2021 13:46:11 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id BDB8426078 for ; Wed, 8 Sep 2021 15:46:10 +0200 (CEST) Received: from localhost ([::1]:59384 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mNxtx-0003Qx-QB for larch@yhetil.org; Wed, 08 Sep 2021 09:46:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34742) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mNxtq-0003QW-IB for guix-patches@gnu.org; Wed, 08 Sep 2021 09:46:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:47499) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mNxtq-00034R-AA for guix-patches@gnu.org; Wed, 08 Sep 2021 09:46:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mNxtq-0005ZB-63 for guix-patches@gnu.org; Wed, 08 Sep 2021 09:46:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#50475] [PATCH] etc: committer: Amend previous commit if a copyright line was added. Resent-From: Xinglu Chen Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Wed, 08 Sep 2021 13:46:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 50475 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 50475@debbugs.gnu.org X-Debbugs-Original-To: guix-patches@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.163110875621381 (code B ref -1); Wed, 08 Sep 2021 13:46:02 +0000 Received: (at submit) by debbugs.gnu.org; 8 Sep 2021 13:45:56 +0000 Received: from localhost ([127.0.0.1]:59045 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mNxtk-0005Yn-5J for submit@debbugs.gnu.org; Wed, 08 Sep 2021 09:45:56 -0400 Received: from lists.gnu.org ([209.51.188.17]:34548) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mNxtg-0005Yb-Mb for submit@debbugs.gnu.org; Wed, 08 Sep 2021 09:45:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34630) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mNxtg-0003Pq-9V for guix-patches@gnu.org; Wed, 08 Sep 2021 09:45:52 -0400 Received: from h87-96-130-155.cust.a3fiber.se ([87.96.130.155]:40894 helo=mail.yoctocell.xyz) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mNxta-0002mB-Fo for guix-patches@gnu.org; Wed, 08 Sep 2021 09:45:52 -0400 From: Xinglu Chen DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=yoctocell.xyz; s=mail; t=1631108740; bh=uFvCbM53TSFbCIEe/a96YcYsd8EsLsi52rNBd7A3+rc=; h=From:To:Subject:Date; b=gvkb0tIFX6pO8OZ8VZTH0ZtwJnw6jrKPTqHFUepjqQ2AmdaBXCXDS62Uwya5IMJw/ PSOHoij+q1pIuTxtnQPy6vltdFe67E+idVkBjrn+8p8/QT/Ii1vLxxk6gwbpJNT/vg LN2R1a2ahrfuiJ7+SB/Vcdgc7v2RuTBOZ3srlY2U= Message-Id: <2e705537217d97d7fdc5070a3897dd68d68f0807.1631108277.git.public@yoctocell.xyz> Date: Wed, 08 Sep 2021 15:45:39 +0200 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Received-SPF: pass client-ip=87.96.130.155; envelope-from=public@yoctocell.xyz; helo=mail.yoctocell.xyz X-Spam_score_int: 28 X-Spam_score: 2.8 X-Spam_bar: ++ X-Spam_report: (2.8 / 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, FROM_SUSPICIOUS_NTLD=0.499, FROM_SUSPICIOUS_NTLD_FP=1.423, PDS_OTHER_BAD_TLD=1.999, RDNS_DYNAMIC=0.982, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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+larch=yhetil.org@gnu.org Sender: "Guix-patches" X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1631108771; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:list-id:list-help: list-unsubscribe:list-subscribe:list-post:dkim-signature; bh=72xphooby4e/vXT9y5P5IwdUoM5aYQiVVvwqNiTdWKk=; b=upCwfBVDqShKiMsMFEdBeeqFNaBW/srZ5Y34Ijj1wsz3W4dRIABK/Cx0IH5ZQLgXx3RWHj y+Y+i+/3rF58ylcCuAReNaK0xMk0TQ2HxzzVwB9wG+0t77fH5Zh2daNfNOQHklLw6G9RBv C9gNEtyeJsxNh1HPTnp//0TEpbuyfZPenbiL4do120i9p5Z/D9uHfJxmlA6dB7sqrn5rBU 5kWtwn8MsUtE0tZhJZTOAUE5JI30YkEG8p6dfg9Vdd0ZgabJeqeZP3iJ99mF1cgTjKn3Yk BcvJtuxUGOg18OBc6iI5NuXvGBBUTvYFKv0U+HbJsoAb9TIu0qfRC+jKomapVw== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1631108771; a=rsa-sha256; cv=none; b=eaVWLDVKNSeyuodmWl7BSuP8msoNV65meyQRxFURDQkMWAFnD1rS1TBzhU1+w5GiRJA8si 1aIz84ZDleV9iC+KsKVuSK2T4F4fPX3u5e318NpazQHyFU6kVuMh7FbRAh+KnXfKBmr67p K+N/dIytcx3uiDIQZ0f0gHy5OyHFwt7YAtVIB/lIVL0yk0l5I6grLArlOCQVkpUqerMrVo QeznqBFBQfggHMA2g4T60vnyNs2VTRuc0tf8fv9aobob060Rmku+bmurqYKP8rnsJjxBQX TMwXr/tTLzupcA1yP9AsrtOADoIxlvKxcSnTJ9DBKM+W7JVbUyryuHy7xQB29A== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=yoctocell.xyz header.s=mail header.b=gvkb0tIF; spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Migadu-Spam-Score: -0.31 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=yoctocell.xyz header.s=mail header.b=gvkb0tIF; dmarc=fail reason="SPF not aligned (relaxed)" header.from=yoctocell.xyz (policy=none); spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Migadu-Queue-Id: BDB8426078 X-Spam-Score: -0.31 X-Migadu-Scanner: scn1.migadu.com X-TUID: 5M09QibjoeAE Previously, the script would raise an error if a copyright line was added t= o a file in gnu/packages/. With this change, it will amend the previous commit whenever a copyright line is added, and add the copyright line to the commi= t. * etc/committer.scm.in (add-copyright-line): New procedure. (main): Check if a copyright line was added and call =E2=80=98add-copyright= -line=E2=80=99 if necessary. --- Before, you would get an error when a copyright line was added. This might also make people think that the previous commits were not successful, at least I did the first time this happened. --8<---------------cut here---------------start------------->8--- $ ./etc/committer.scm gnu: Add emacs-nasm-mode. * gnu/packages/emacs-xyz.scm (emacs-nasm-mode): New variable. [master bbe52033d7] gnu: Add emacs-nasm-mode. 1 file changed, 23 insertions(+) Backtrace: 5 (primitive-load "/home/yoctocell/src/guix-local/./etc/committe= r.scm") In srfi/srfi-1.scm: 634:9 4 (for-each # ((#f #f #< fi=E2=80=A6>))) In ice-9/eval.scm: 619:8 3 (_ #(#(#(#(#(#(#(#(#(# #)= (=E2=80=A6)) #) #) =E2=80=A6) #) =E2=80=A6) #) #)) 619:8 2 (_ #(#(#(#) "gnu/packages= /emacs-xyz.scm" #f #f =E2=80=A6) =E2=80=A6)) 626:19 1 (_ #(#(#(#) "gnu/packages= /emacs-xyz.scm" #f #f =E2=80=A6) =E2=80=A6)) In unknown file: 0 (cadr #f) ERROR: In procedure cadr: In procedure cadr: Wrong type (expecting pair): #f --8<---------------cut here---------------end--------------->8--- With the patch, you get --8<---------------cut here---------------start------------->8--- $ ./etc/committer.scm gnu: Add emacs-nasm-mode. * gnu/packages/emacs-xyz.scm (emacs-nasm-mode): New variable. [master d662741368] gnu: Add emacs-nasm-mode. 1 file changed, 23 insertions(+) Amend and add copyright line for Xinglu Chen [master 024095ccd6] gnu: Add emacs-nasm-mode. Date: Wed Sep 8 15:39:12 2021 +0200 1 file changed, 24 insertions(+) --8<---------------cut here---------------end--------------->8--- etc/committer.scm.in | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/etc/committer.scm.in b/etc/committer.scm.in index e81ce16611..1ad83e37d7 100755 --- a/etc/committer.scm.in +++ b/etc/committer.scm.in @@ -5,6 +5,7 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright =C2=A9 2020, 2021 Ricardo Wurmus ;;; Copyright =C2=A9 2021 Sarah Morgensen +;;; Copyright =C2=A9 2021 Xinglu Chen ;;; ;;; This file is part of GNU Guix. ;;; @@ -288,6 +289,15 @@ ChangeLog entry." (break-string-with-newlines message/f 72) (break-string-with-newlines changelog/f 72)))) =20 +(define (add-copyright-line line) + "Add the copyright line on LINE to the previous commit." + (let ((author (match:substring + (string-match "^\\+;;; Copyright =C2=A9[^[:alpha:]]+(.*)$= " line) + 1))) + (format + (current-output-port) "Amend and add copyright line for ~a~%" author) + (system* "git" "commit" "--amend" "--no-edit"))) + (define (group-hunks-by-sexp hunks) "Return a list of pairs associating all hunks with the S-expression they= are modifying." @@ -370,15 +380,23 @@ modifying." (error "Cannot apply"))) (usleep %delay)) hunks) - (change-commit-message* (hunk-file-name (first hunks)) - old new) - (let ((port (open-pipe* OPEN_WRITE "git" "commit" "-F"= "-"))) + (define copyright-line + (any (lambda (line) (and=3D> (string-prefix? "+;;; C= opyright =C2=A9" 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 hun= ks)) + 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"))))) + (error "Cannot commit"))))))) ;; XXX: we recompute the hunks here because previous ;; insertions lead to offsets. (new+old+hunks (diff-info))))))) base-commit: 5c5e9d4e50af20042947b6b55e462a25b9d8cfc7 --=20 2.33.0