summaryrefslogtreecommitdiffstats
path: root/code/modules/maintainers.scm
blob: a0ea81da164bdd3cb8d54ce33c15b5552a20b06b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
;;; Copyright © 2020 Ludovic Courtès <ludo@gnu.org>
;;;
;;; 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 <http://www.gnu.org/licenses/>.

(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>
  (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 <maintainer> 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))