(address . guix-patches@gnu.org)
Hi Guix,
I snarfed these from my cc-for-target branch.
Examples of generated commit messages, without any massaging:
<start snip>
gnu: ufoai-data: Use 'cc-for-target' and friends.
* gnu/packages/games.scm (ufoai-data)
[arguments]<#:configure-flags>: Use the C cross-compiler, instead of hardcoding "gcc". Use the C++ cross-compiler, instead of hardcoding "g++".
gnu: mlt: Use 'cc-for-target' and friends.
* gnu/packages/video.scm (mlt)
[arguments]<#:make-flags>: Use the C cross-compiler, instead of hardcoding "gcc". Use the C++ cross-compiler, instead of hardcoding "g++".
gnu: theorafile: Use the C cross-compiler.
* gnu/packages/video.scm (theorafile)
[arguments]<#:make-flags>: Use the C cross-compiler, instead of hardcoding "gcc".
[arguments]<#:phases>{check}: Only run tests when not requested.
<end snip>
etc/comitter.scm.in should probably do some line wrapping as well.
WDYT?
Greetings,
Maxime.
From ae06b43db712697f7080cc8e5f4d3eecd9350211 Mon Sep 17 00:00:00 2001
From: Maxime Devos <maximedevos@telenet.be>
Date: Fri, 30 Apr 2021 13:32:41 +0200
Subject: [PATCH 2/6] etc: Teach committer.scm about checking tests? in the
'check' phase.
* etc/committer.scm.in
(has-explicit-argument?): New procedure.
(change-commit-message)[explain-argument]<#:phases>: New case,
try explaining changes in #:phases.
(explain-phases/change): New procedure, explain the patch makes
sure 'tests?' is respected in the 'check' phase.
---
etc/committer.scm.in | 46 ++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 46 insertions(+)
Toggle diff (73 lines)
diff --git a/etc/committer.scm.in b/etc/committer.scm.in
index 75c82c9019..3fa70a81d0 100755
--- a/etc/committer.scm.in
+++ b/etc/committer.scm.in
@@ -229,6 +229,26 @@ Return false if all changes could be explained and truth otherwise."
(or (bitvector-position old-explained? #f)
(bitvector-position new-explained? #f))))
+(define (has-explicit-argument? argument-to-search-for argument-list)
+ "Test whether ARGUMENT-TO-SEARCH-FOR occurs in ARGUMENT-LIST."
+ (let loop ((argument-list argument-list))
+ ;; (lambda () exp)
+ (cond ((null? argument-list) #f)
+ ;; (lambda (x . rest) exp)
+ ((pair? argument-list)
+ (let ((argument-in-list (car argument-list))
+ (rest (cdr argument-list)))
+ (cond ((eq? argument-in-list argument-to-search-for)
+ #t)
+ ;; (lambda* (#:key (x . default) . rest) #f)
+ ((and (pair? argument-in-list)
+ (eq? (car argument-in-list) argument-to-search-for))
+ #t)
+ (#t (loop rest)))))
+ ;; (lambda _ exp)
+ ((symbol? argument-list) #f)
+ (#t (error "the argument list seems to be incorrect!")))))
+
(define* (change-commit-message file-name old new #:optional (port (current-output-port)))
"Print ChangeLog commit message for changes between OLD and NEW."
(define (get-values expr field)
@@ -292,6 +312,21 @@ Return false if all changes could be explained and truth otherwise."
" Use the C++ cross-compiler, instead of hardcoding \"g++\".")
#t)
(_ #f)))
+ (define (explain-phases/change x y)
+ (match (cons x y)
+ ;; "guix build" supports a --without-tests=PACKAGE option,
+ ;; for building a package without running tests. Also, tests
+ ;; can often not be run when cross-compiling. The 'check'
+ ;; phase needs to respect this, though. Maybe this patch is
+ ;; for ensuring the phase respects this.
+ ((('replace ''check ((or 'lambda* 'lambda) args/x . exps/x))
+ . ('replace ''check ((or 'lambda* 'lambda) args/y . exps/y)))
+ (when (and (not (has-explicit-argument? 'tests? args/x))
+ (has-explicit-argument? 'tests? args/y))
+ (format port
+ "[arguments]<#:phases>{check}: Only run tests when not requested.~%")
+ #t))
+ (_ #f)))
(define (explain-argument keyword old new)
(unless (equal? old new)
(case keyword
@@ -303,6 +338,17 @@ Return false if all changes could be explained and truth otherwise."
;; There were some unexplained changes.
(format port " Update.~%")
(format port "~%")))
+ ((#:phases)
+ ;; For each phase, a separate line will be printed.
+ (match (cons old new)
+ ;; _ can be %standard-phases, for example
+ ((('modify-phases _ . rest/old) . ('modify-phases _ . rest/new))
+ (if (explain-list-delta rest/old rest/new
+ #:pairwise/change explain-phases/change)
+ ;; There were some unexplained changes.
+ (format port "[arguments]<#:phases>: Update.~%")))
+ ;; There were some unexplained changes.
+ (_ (format port "[arguments]<#:phases>: Update.~%"))))
;; There were some unexplained changes.
(else (format port "[arguments]<~a>: Update.~%" keyword)))))
(let ((old-arguments (or (get-values/list old 'arguments) '()))
--
2.31.1
From 31c36574e73ba448b0a883f046dbb5021882273e Mon Sep 17 00:00:00 2001
From: Maxime Devos <maximedevos@telenet.be>
Date: Fri, 30 Apr 2021 13:56:17 +0200
Subject: [PATCH 3/6] etc: committer: Only claim to be updating a package when
it's true.
* etc/committer.scm.in (change-commit-message): If the patch does not
change the version, do not falsely say the package is updated, and
instead output a placeholder to be filled in by the user.
---
etc/committer.scm.in | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)
Toggle diff (29 lines)
diff --git a/etc/committer.scm.in b/etc/committer.scm.in
index 3fa70a81d0..8027d9d0f1 100755
--- a/etc/committer.scm.in
+++ b/etc/committer.scm.in
@@ -274,12 +274,17 @@ Return false if all changes could be explained and truth otherwise."
", and " (first (take-right items 1))))))
(define variable-name
(second old))
- (define version
- (and=> ((sxpath '(// version *any*)) new)
+ (define (version exp)
+ (and=> ((sxpath '(// version *any*)) exp)
first))
- (format port
- "gnu: ~a: Update to ~a.~%~%* ~a (~a): Update to ~a.~%"
- variable-name version file-name variable-name version)
+ (define old-version (version old))
+ (define new-version (version new))
+ (cond ((not (equal? old-version new-version))
+ (format port "gnu: ~a: Update to ~a.~%~%* ~a (~a): Update to ~a.~%"
+ variable-name new-version file-name variable-name new-version))
+ (#t
+ (format port "gnu: ~a: <FIXME you need to write something here>~%~%* ~a (~a): FIXME!.~%"
+ variable-name file-name variable-name)))
(for-each (lambda (field)
(let ((old-values (get-values old field))
(new-values (get-values new field)))
--
2.31.1
From 061175155983d73f1488f2cf22d6d52bd5ed3054 Mon Sep 17 00:00:00 2001
From: Maxime Devos <maximedevos@telenet.be>
Date: Fri, 30 Apr 2021 15:32:08 +0200
Subject: [PATCH 5/6] etc: committer: Support (list exp ...) in #:make-flags.
* etc/committer.scm.in
(unwrap-list): New procedure, supporting 'quasiquote', 'quote'
and 'list'.
(change-commit-message/one-pass)[unwrap-list]: Use new procedure.
---
etc/committer.scm.in | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
Toggle diff (32 lines)
diff --git a/etc/committer.scm.in b/etc/committer.scm.in
index be23367f49..fc3c929f17 100755
--- a/etc/committer.scm.in
+++ b/etc/committer.scm.in
@@ -264,6 +264,15 @@ Return false if all changes could be explained and truth otherwise."
(define (make-patch-summary)
(%make-patch-summary #f #f #f))
+;; '(x ...) -> (x ...)
+;; `(x ...) -> (x ...)
+;; (list x ...) -> (x ...)
+(define (unwrap-list list)
+ (case (car list)
+ ((quasiquote quote) (second list))
+ ((list) (cdr list))
+ (else (error "I can't interpret that as a list!"))))
+
(define* (change-commit-message/one-pass
file-name old new summary
#:optional (port (current-output-port)))
@@ -374,8 +383,7 @@ SUMMARY: first using a ‘void port’, then with the ‘real’ output port."
(case keyword
((#:make-flags)
(format port "[arguments]<#:make-flags>:")
- ;; second: skip ' and `
- (if (explain-list-delta (second old) (second new)
+ (if (explain-list-delta (unwrap-list old) (unwrap-list new)
#:pairwise/change explain-make-flags/change)
;; There were some unexplained changes.
(format port " Update.~%")
--
2.31.1
From 295cca1e1745acfea49b54681d566dd3d0c1dd19 Mon Sep 17 00:00:00 2001
From: Maxime Devos <maximedevos@telenet.be>
Date: Fri, 30 Apr 2021 15:45:02 +0200
Subject: [PATCH 6/6] etc: committer: Explain changes in #:configure-flags.
* etc/committer.scm.in
(change-commit-message/one-pass)[explain-argument]: Handle
#:configure-flags the same way as #:make-flags for now.
---
etc/committer.scm.in | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
Toggle diff (21 lines)
diff --git a/etc/committer.scm.in b/etc/committer.scm.in
index fc3c929f17..0fd383533d 100755
--- a/etc/committer.scm.in
+++ b/etc/committer.scm.in
@@ -381,8 +381,12 @@ SUMMARY: first using a ‘void port’, then with the ‘real’ output port."
(define (explain-argument keyword old new)
(unless (equal? old new)
(case keyword
- ((#:make-flags)
- (format port "[arguments]<#:make-flags>:")
+ ;; Sometimes, arguments like "CC=TARGET-gcc" are passed to the
+ ;; configure script. Their interpretation is sometimes the same
+ ;; as in makefiles. Hence, for now we unify the handling of
+ ;; #:make-flags and #:configure-flags.
+ ((#:make-flags #:configure-flags)
+ (format port "[arguments]<~a>:" keyword)
(if (explain-list-delta (unwrap-list old) (unwrap-list new)
#:pairwise/change explain-make-flags/change)
;; There were some unexplained changes.
--
2.31.1
-----BEGIN PGP SIGNATURE-----
iI0EABYKADUWIQTB8z7iDFKP233XAR9J4+4iGRcl7gUCYIwV1RccbWF4aW1lZGV2
b3NAdGVsZW5ldC5iZQAKCRBJ4+4iGRcl7sYQAP9swBcYjO7Hv2u6z5OjN+HbU1bi
xwc26EIrPg9AVaXIjwEAvu0G0glNyWFDawNqb0xORZXdsDD3N1jn9Q2Xf6JJ8gc=
=R2cu
-----END PGP SIGNATURE-----