[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
04/08: etc: committer: Amend previous commit if a copyright line was add
From: |
guix-commits |
Subject: |
04/08: etc: committer: Amend previous commit if a copyright line was added. |
Date: |
Tue, 21 Sep 2021 09:16:53 -0400 (EDT) |
civodul pushed a commit to branch master
in repository guix.
commit 3d15a19874f63dfc15eb6625558f279ccbc71d5d
Author: Xinglu Chen <public@yoctocell.xyz>
AuthorDate: Wed Sep 8 15:45:39 2021 +0200
etc: committer: Amend previous commit if a copyright line was added.
Previously, the script would raise an error if a copyright line was added
to 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
commit.
* etc/committer.scm.in (add-copyright-line): New procedure.
(main): Check if a copyright line was added and call ‘add-copyright-line’ if
necessary.
Signed-off-by: Ludovic Courtès <ludo@gnu.org>
---
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 e81ce16..1ad83e3 100755
--- a/etc/committer.scm.in
+++ b/etc/committer.scm.in
@@ -5,6 +5,7 @@
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2020, 2021 Ricardo Wurmus <rekado@elephly.net>
;;; Copyright © 2021 Sarah Morgensen <iskarian@mgsn.dev>
+;;; Copyright © 2021 Xinglu Chen <public@yoctocell.xyz>
;;;
;;; 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))))
+(define (add-copyright-line line)
+ "Add the copyright line on LINE to the previous commit."
+ (let ((author (match:substring
+ (string-match "^\\+;;; Copyright ©[^[: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=> (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")))))
+ (error "Cannot commit")))))))
;; XXX: we recompute the hunks here because previous
;; insertions lead to offsets.
(new+old+hunks (diff-info)))))))
- branch master updated (39414b7 -> 9102512), guix-commits, 2021/09/21
- 02/08: gnu: erlang: Update to 24.0.5., guix-commits, 2021/09/21
- 06/08: gnu: imv: Update to 4.1.0 and adjust arguments+inputs., guix-commits, 2021/09/21
- 04/08: etc: committer: Amend previous commit if a copyright line was added.,
guix-commits <=
- 08/08: news: Add entry for "guix graph -M"., guix-commits, 2021/09/21
- 05/08: gnu: patchutils: Update to 0.4.2., guix-commits, 2021/09/21
- 07/08: graph: Add '--max-depth'., guix-commits, 2021/09/21
- 01/08: base32: Work around (ash x N) miscompilation at '-O1' and below., guix-commits, 2021/09/21
- 03/08: gnu: elixir: Update to 1.12.2., guix-commits, 2021/09/21