From b71c7cc8dc2b80cbb13888e8793c058c03fbe0e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= Date: Sun, 26 Jan 2020 22:53:10 +0100 Subject: Add supporting code: (email) and (maintainers). * code/modules/email.scm, code/modules/maintainers.scm: New files. --- code/modules/maintainers.scm | 68 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 code/modules/maintainers.scm (limited to 'code/modules/maintainers.scm') diff --git a/code/modules/maintainers.scm b/code/modules/maintainers.scm new file mode 100644 index 0000000..a0ea81d --- /dev/null +++ b/code/modules/maintainers.scm @@ -0,0 +1,68 @@ +;;; Copyright © 2020 Ludovic Courtès +;;; +;;; This program is free software; you can redistribute it and/or modify it +;;; under the terms of the GNU General Public License as published by +;;; the Free Software Foundation; either version 3 of the License, or (at +;;; your option) any later version. +;;; +;;; This program is distributed in the hope that it will be useful, but +;;; WITHOUT ANY WARRANTY; without even the implied warranty of +;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;;; GNU General Public License for more details. +;;; +;;; You should have received a copy of the GNU General Public License +;;; along with this program. If not, see . + +(define-module (maintainers) + #:use-module (guix records) + #:use-module (ssh popen) + #:use-module ((ssh session) #:select (disconnect!)) + #:use-module (guix ssh) + #:use-module (srfi srfi-9) + #:export (maintainer? + maintainer-name + maintainer-address + maintainer-packages + + maintainer-collective? + read-maintainers + read-maintainers-from-fencepost)) + +(define-record-type + (maintainer name address packages) + maintainer? + (name maintainer-name) + (address maintainer-address) + (packages maintainer-packages)) + +(define (maintainer-collective? maintainer) + (or (string-suffix? "maintainers@gnu.org" (maintainer-address maintainer)) + (string-suffix? " maintainers" (maintainer-name maintainer)) + (string-suffix? " committee" (maintainer-name maintainer)))) + +(define (read-maintainers port) + "Read from PORT recutils-formatted info about GNU maintainers, and return a +list of records." + (define (read-one port) + (alist->record (recutils->alist port) + maintainer + '("name" "email" "package") + '("package"))) + + (let loop ((result '())) + (if (eof-object? (peek-char port)) + (reverse result) + (let ((maintainer (read-one port))) + (loop (if (and (maintainer-name maintainer) + (maintainer-address maintainer)) + (cons maintainer result) + result)))))) + +(define (read-maintainers-from-fencepost) + (let* ((session (open-ssh-session "fencepost.gnu.org")) + (pipe (open-remote-pipe* session OPEN_READ + "cat" "/gd/gnuorg/maintainers")) + (maintainers (read-maintainers pipe))) + (close-port pipe) + (disconnect! session) + maintainers)) -- cgit v1.2.1