From: zimoun <zimon.toutoune@gmail.com>
To: Leo Famulari <leo@famulari.name>
Cc: 46182@debbugs.gnu.org
Subject: [bug#46182] [PATCH] lint: Add 'check-git-protocol' checker.
Date: Thu, 11 Mar 2021 01:14:33 +0100 [thread overview]
Message-ID: <86a6rabl7a.fsf@gmail.com> (raw)
In-Reply-To: <f9137838eca39b768e49f4ee7852dd32edce7e8c.1611968623.git.leo@famulari.name> (Leo Famulari's message of "Fri, 29 Jan 2021 20:04:06 -0500")
[-- Attachment #1: Type: text/plain, Size: 1192 bytes --]
Hi Leo,
Giving a look to the bug tracker for the next release, I see this
bug. :-)
On Fri, 29 Jan 2021 at 20:04, Leo Famulari <leo@famulari.name> wrote:
> We could also make it warn about use of the HTTP protocol (as opposed to
> HTTPS). Your thoughts?
>
> * guix/lint.scm (check-git-protocol): New procedure.
> (%local-checkers): Add 'git-protocol' checker.
> * doc/guix.texi (Invoking guix lint): Document it.
The doc/ does not apply anymore.
Instead of these ’eqv?’
> +(define (check-git-protocol package)
> + "Emit a warning if PACKAGE's source URI protocol is 'git://'."
> + (define (check-source-uri-scheme uri)
> + (if (eqv? (uri-scheme uri) 'git)
[...]
> + (let ((origin (package-source package)))
> + (if (and (origin? origin)
> + (eqv? (origin-method origin) git-fetch))
> + (check-source-uri-scheme
> + (string->uri (git-reference-url (origin-uri origin))))
> + '())))
I propose ’match’ which is more coherent with the Guix style. Well,
from my understanding. :-)
Patch attached. Well, it could be nice to add a test in
tests/guix-lint.sh for that. WDYT?
Cheers,
simon
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: lint-git-protocol.patch --]
[-- Type: text/x-diff, Size: 2155 bytes --]
diff --git a/guix/lint.scm b/guix/lint.scm
index 311bc94cc3..980f77c736 100644
--- a/guix/lint.scm
+++ b/guix/lint.scm
@@ -51,7 +51,7 @@
#:use-module (guix gnu-maintenance)
#:use-module (guix cve)
#:use-module ((guix swh) #:hide (origin?))
- #:autoload (guix git-download) (git-reference?
+ #:autoload (guix git-download) (git-reference? git-fetch
git-reference-url git-reference-commit)
#:use-module (guix import stackage)
#:use-module (ice-9 match)
@@ -84,6 +84,7 @@
check-source
check-source-file-name
check-source-unstable-tarball
+ check-git-protocol
check-mirror-url
check-github-url
check-license
@@ -918,6 +919,26 @@ descriptions maintained upstream."
(origin-uris origin))
'())))
+(define (check-git-protocol package)
+ "Emit a warning if PACKAGE's source URI protocol is 'git://'."
+ (define (check-source-uri-scheme uri)
+ (match (uri-scheme uri)
+ ('git
+ (list
+ (make-warning package
+ (G_ "the source URI should not use the git:// protocol")
+ #:field 'source)))
+ (_ '())))
+
+ (match (package-source package)
+ ((? origin? origin)
+ (match (origin-method origin)
+ (git-fetch
+ (check-source-uri-scheme
+ (string->uri (git-reference-url (origin-uri origin)))))
+ (_ '())))
+ (_ '())))
+
(define (check-mirror-url package)
"Check whether PACKAGE uses source URLs that should be 'mirror://'."
(define (check-mirror-uri uri) ;XXX: could be optimized
@@ -1476,6 +1497,10 @@ or a list thereof")
(name 'source-unstable-tarball)
(description "Check for autogenerated tarballs")
(check check-source-unstable-tarball))
+ (lint-checker
+ (name 'git-protocol)
+ (description "Check for use of the git:// protocol")
+ (check check-git-protocol))
(lint-checker
(name 'derivation)
(description "Report failure to compile a package to a derivation")
next prev parent reply other threads:[~2021-03-11 0:18 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-30 1:04 [bug#46182] [PATCH] lint: Add 'check-git-protocol' checker Leo Famulari
2021-03-11 0:14 ` zimoun [this message]
2021-03-11 1:46 ` Leo Famulari
2021-03-11 9:44 ` zimoun
2023-10-20 2:22 ` Maxim Cournoyer
2023-10-20 12:45 ` Simon Tournier
2023-10-20 15:37 ` Maxim Cournoyer
2021-03-11 22:29 ` Ludovic Courtès
2022-05-22 4:15 ` Maxim Cournoyer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=86a6rabl7a.fsf@gmail.com \
--to=zimon.toutoune@gmail.com \
--cc=46182@debbugs.gnu.org \
--cc=leo@famulari.name \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/guix.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.