etc: teams: Refactor list-teams.
* etc/teams.scm.in (print-team, sort-teams): New procedures. (list-teams): Use them.
parent
c0dad02e9f
commit
ee4a429d49
|
@ -672,13 +672,9 @@ TEAMS when a patch is received by Debbugs."
|
||||||
(format #t "~a~a~%" prefix (member->string member)))
|
(format #t "~a~a~%" prefix (member->string member)))
|
||||||
(sort-members (team-members team))))
|
(sort-members (team-members team))))
|
||||||
|
|
||||||
(define (list-teams)
|
(define (print-team team)
|
||||||
"Print all teams, their scope and their members."
|
"Print TEAM, a <team> record object."
|
||||||
(define port* (current-output-port))
|
(format #t
|
||||||
(define width* (%text-width))
|
|
||||||
(for-each
|
|
||||||
(lambda (team)
|
|
||||||
(format port*
|
|
||||||
"\
|
"\
|
||||||
id: ~a
|
id: ~a
|
||||||
name: ~a
|
name: ~a
|
||||||
|
@ -690,19 +686,27 @@ description: ~a
|
||||||
(or (and=> (team-description team)
|
(or (and=> (team-description team)
|
||||||
(lambda (text)
|
(lambda (text)
|
||||||
(string->recutils
|
(string->recutils
|
||||||
(fill-paragraph text width*
|
(fill-paragraph text (%text-width)
|
||||||
(string-length "description: ")))))
|
(string-length "description: ")))))
|
||||||
"<none>")
|
"<none>")
|
||||||
(match (team-scope team)
|
(match (team-scope team)
|
||||||
(() "")
|
(() "")
|
||||||
(scope (format #f "scope: ~{~s ~}~%" scope))))
|
(scope (format #f "scope: ~{~s ~}~%" scope))))
|
||||||
(list-members team #:prefix "+ ")
|
(list-members team #:prefix "+ ")
|
||||||
(newline))
|
(newline)))
|
||||||
(sort
|
|
||||||
(hash-map->list (lambda (key value) value) %teams)
|
(define (sort-teams teams)
|
||||||
|
"Sort TEAMS, a list of <team> record objects."
|
||||||
|
(sort teams
|
||||||
(lambda (team1 team2)
|
(lambda (team1 team2)
|
||||||
(string<? (symbol->string (team-id team1))
|
(string<? (symbol->string (team-id team1))
|
||||||
(symbol->string (team-id team2)))))))
|
(symbol->string (team-id team2))))))
|
||||||
|
|
||||||
|
(define* (list-teams)
|
||||||
|
"Print all teams, their scope and their members."
|
||||||
|
(for-each print-team
|
||||||
|
(sort-teams (hash-map->list
|
||||||
|
(lambda (_ value) value) %teams))))
|
||||||
|
|
||||||
|
|
||||||
(define (diff-revisions rev-start rev-end)
|
(define (diff-revisions rev-start rev-end)
|
||||||
|
|
Reference in New Issue