diff mbox series

[bug#58660,v2,2/3] etc: teams: Sort and itemize 'scope' field.

Message ID 20221117202820.2054593-2-zimon.toutoune@gmail.com
State New
Headers show
Series [bug#58660,v2,1/3] etc: teams: Add 'show' subcommand. | expand

Checks

Context Check Description
cbaines/comparison success View comparision
cbaines/git-branch success View Git branch
cbaines/applying patch success
cbaines/issue success View issue

Commit Message

Simon Tournier Nov. 17, 2022, 8:28 p.m. UTC
* etc/teams.scm.in (list-teams): Sort and itemize the 'scope' field.
---
 etc/teams.scm.in | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

Comments

Mathieu Othacehe Nov. 18, 2022, 5:23 p.m. UTC | #1
Hello,

> +               (scope-files
> +                (fold
> +                 (lambda (str fmt)
> +                   (string-append fmt str))
> +                 (format #f "scope:~%")
> +                 (sort
> +                  (map (lambda (scope) (format #f "+ ~a~%" scope)) scope-files)

Why not:

(scope (format #f "scope:~%~{+ ~s ~}~%" scope))

> +                  string<=?)))))

At that point, scope is not always a string:

--8<---------------cut here---------------start------------->8---
ERROR: In procedure string<=?:
In procedure string<=: Wrong type argument in position 1 (expecting string): #<regexp 7fd842030980>
--8<---------------cut here---------------end--------------->8---

Thanks,

Mathieu
Simon Tournier Nov. 21, 2022, 2:11 p.m. UTC | #2
Hi Mathieu,

On Fri, 18 Nov 2022 at 18:23, Mathieu Othacehe <othacehe@gnu.org> wrote:


> Why not:
>
> (scope (format #f "scope:~%~{+ ~s ~}~%" scope))

Because this does not “itemize” correctly.  For instance, it outputs:

--8<---------------cut here---------------start------------->8---
id: python
name: Python team
description: Python, Python packages, the "pypi" importer, and the python-build-system.
scope:
+ "gnu/packages/django.scm" + "gnu/packages/jupyter.scm" + #<regexp 7f408800d500> + "gnu/packages/sphinx.scm" + "gnu/packages/tryton.scm" + "guix/build/pyproject-build-system.scm" + "guix/build-system/pyproject.scm" + "guix/build/python-build-system.scm" + "guix/build-system/python.scm" + "guix/import/pypi.scm" + "guix/scripts/import/pypi.scm" + "tests/pypi.scm" 
members:
+ Lars-Dominik Braun <lars@6xq.net>
+ jgart <jgart@dismail.de>
--8<---------------cut here---------------end--------------->8---

When what we want is:

--8<---------------cut here---------------start------------->8---
scope:
+ "gnu/packages/django.scm"
+ "gnu/packages/jupyter.scm"
+ #<regexp 7f408800d500>
+ "gnu/packages/sphinx.scm"
+ "gnu/packages/tryton.scm"
+ "guix/build/pyproject-build-system.scm"
+ "guix/build-system/pyproject.scm"
+ "guix/build/python-build-system.scm"
+ "guix/build-system/python.scm"
+ "guix/import/pypi.scm"
+ "guix/scripts/import/pypi.scm"
+ "tests/pypi.scm" 
--8<---------------cut here---------------end--------------->8---

Well, the ’~%’ is included:

    (scope (format #f "scope:~%~{+ ~s~% ~}~%" scope))))

then there is one extra:

--8<---------------cut here---------------start------------->8---
id: python
name: Python team
description: Python, Python packages, the "pypi" importer, and the python-build-system.
scope:
+ "gnu/packages/django.scm"
 + "gnu/packages/jupyter.scm"
 + #<regexp 7f40de756500>
 + "gnu/packages/sphinx.scm"
 + "gnu/packages/tryton.scm"
 + "guix/build/pyproject-build-system.scm"
 + "guix/build-system/pyproject.scm"
 + "guix/build/python-build-system.scm"
 + "guix/build-system/python.scm"
 + "guix/import/pypi.scm"
 + "guix/scripts/import/pypi.scm"
 + "tests/pypi.scm"
 
members:
+ Lars-Dominik Braun <lars@6xq.net>
+ jgart <jgart@dismail.de>
--8<---------------cut here---------------end--------------->8---


>> +                  string<=?)))))
>
> At that point, scope is not always a string:
>
> --8<---------------cut here---------------start------------->8---
> ERROR: In procedure string<=?:
> In procedure string<=: Wrong type argument in position 1 (expecting string): #<regexp 7fd842030980>
> --8<---------------cut here---------------end--------------->8---

Hum, I miss how you get that.  This,

    (map (lambda (scope) (format #f "+ ~a~%" scope)) scope-files)

transforms all as string.  For instance, applying this patch on the top
of the introduction of “./etc/teams.scm show”, I get:

--8<---------------cut here---------------start------------->8---
id: python
name: Python team
description: Python, Python packages, the "pypi" importer, and the python-build-system.
scope:
+ #<regexp 7fc05bdd6500>
+ gnu/packages/django.scm
+ gnu/packages/jupyter.scm
+ gnu/packages/sphinx.scm
+ gnu/packages/tryton.scm
+ guix/build-system/pyproject.scm
+ guix/build-system/python.scm
+ guix/build/pyproject-build-system.scm
+ guix/build/python-build-system.scm
+ guix/import/pypi.scm
+ guix/scripts/import/pypi.scm
+ tests/pypi.scm
members:
+ Lars-Dominik Braun <lars@6xq.net>
+ jgart <jgart@dismail.de>
--8<---------------cut here---------------end--------------->8---


Cheers,
simon
Maxim Cournoyer Aug. 29, 2023, 6:58 p.m. UTC | #3
Hi,

zimoun <zimon.toutoune@gmail.com> writes:

> Hi Mathieu,
>
> On Fri, 18 Nov 2022 at 18:23, Mathieu Othacehe <othacehe@gnu.org> wrote:
>
>
>> Why not:
>>
>> (scope (format #f "scope:~%~{+ ~s ~}~%" scope))
>
> Because this does not “itemize” correctly.  For instance, it outputs:
>
> id: python
> name: Python team
> description: Python, Python packages, the "pypi" importer, and the python-build-system.
> scope:
> + "gnu/packages/django.scm" + "gnu/packages/jupyter.scm" + #<regexp 7f408800d500> + "gnu/packages/sphinx.scm" + "gnu/packages/tryton.scm" + "guix/build/pyproject-build-system.scm" + "guix/build-system/pyproject.scm" + "guix/build/python-build-system.scm" + "guix/build-system/python.scm" + "guix/import/pypi.scm" + "guix/scripts/import/pypi.scm" + "tests/pypi.scm" 
> members:
> + Lars-Dominik Braun <lars@6xq.net>
> + jgart <jgart@dismail.de>
>
>
> When what we want is:
>
> scope:
> + "gnu/packages/django.scm"
> + "gnu/packages/jupyter.scm"
> + #<regexp 7f408800d500>
> + "gnu/packages/sphinx.scm"
> + "gnu/packages/tryton.scm"
> + "guix/build/pyproject-build-system.scm"
> + "guix/build-system/pyproject.scm"
> + "guix/build/python-build-system.scm"
> + "guix/build-system/python.scm"
> + "guix/import/pypi.scm"
> + "guix/scripts/import/pypi.scm"
> + "tests/pypi.scm" 
>
>
> Well, the ’~%’ is included:
>
>     (scope (format #f "scope:~%~{+ ~s~% ~}~%" scope))))
>
> then there is one extra:
>
> id: python
> name: Python team
> description: Python, Python packages, the "pypi" importer, and the python-build-system.
> scope:
> + "gnu/packages/django.scm"
>  + "gnu/packages/jupyter.scm"
>  + #<regexp 7f40de756500>
>  + "gnu/packages/sphinx.scm"
>  + "gnu/packages/tryton.scm"
>  + "guix/build/pyproject-build-system.scm"
>  + "guix/build-system/pyproject.scm"
>  + "guix/build/python-build-system.scm"
>  + "guix/build-system/python.scm"
>  + "guix/import/pypi.scm"
>  + "guix/scripts/import/pypi.scm"
>  + "tests/pypi.scm"
>  
> members:
> + Lars-Dominik Braun <lars@6xq.net>
> + jgart <jgart@dismail.de>

That's fixable with the 'escape' escape, ~^:

--8<---------------cut here---------------start------------->8---
(format #f "scope:~%~{+ ~a~^~%~}~%" scope)
--8<---------------cut here---------------end--------------->8---

I've reworked your v2, integrating the comments from Mathieu and
installed it as 4d7b25a0e2abd77625cdc888c60da8e6add02bbd.

Closing!
diff mbox series

Patch

diff --git a/etc/teams.scm.in b/etc/teams.scm.in
index e4e0dc209d..3f90e0e6f2 100644
--- a/etc/teams.scm.in
+++ b/etc/teams.scm.in
@@ -562,7 +562,14 @@  (define width* (%text-width))
                  "<none>")
              (match (team-scope team)
                (() "")
-               (scope (format #f "scope: ~{~s ~}~%" scope))))
+               (scope-files
+                (fold
+                 (lambda (str fmt)
+                   (string-append fmt str))
+                 (format #f "scope:~%")
+                 (sort
+                  (map (lambda (scope) (format #f "+ ~a~%" scope)) scope-files)
+                  string<=?)))))
      (list-members team port* "+ ")
      (newline))
    (if team-names