lint: Rewrite 'check-patch-file-names'.

* guix/scripts/lint.scm (check-patch-file-names): Improve clarity by
reversing the logic.
This commit is contained in:
Mathieu Lirzin 2016-01-24 15:15:54 +01:00
parent 90ca918668
commit f3044a4b7b

View File

@ -413,24 +413,21 @@ warning for PACKAGE mentionning the FIELD."
(define (check-patch-file-names package) (define (check-patch-file-names package)
"Emit a warning if the patches requires by PACKAGE are badly named or if the "Emit a warning if the patches requires by PACKAGE are badly named or if the
patch could not be found." patch could not be found."
(guard (c ((message-condition? c) ;raised by 'search-patch' (guard (c ((message-condition? c) ;raised by 'search-patch'
(emit-warning package (condition-message c) (emit-warning package (condition-message c)
'patch-file-names))) 'patch-file-names)))
(let ((patches (and=> (package-source package) origin-patches)) (unless (every (match-lambda ;patch starts with package name?
(name (package-name package))) ((? string? patch)
(when (and patches (and=> (string-contains (basename patch)
(any (match-lambda (package-name package))
((? string? patch) zero?))
(let ((file (basename patch))) (_ #f)) ;must be an <origin> or something like that.
(not (eq? (string-contains file name) 0)))) (or (and=> (package-source package) origin-patches)
(_ '()))
;; This must be an <origin> or something like that. (emit-warning
#f)) package
patches)) (_ "file names of patches should start with the package name")
(emit-warning package 'patch-file-names))))
(_ "file names of patches should start with \
the package name")
'patch-file-names)))))
(define (escape-quotes str) (define (escape-quotes str)
"Replace any quote character in STR by an escaped quote character." "Replace any quote character in STR by an escaped quote character."