unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
From: "Clément Lassieur" <clement@lassieur.org>
To: Oleg Pykhalov <go.wigust@gmail.com>
Cc: 29820@debbugs.gnu.org
Subject: [bug#29820] [PATCH] services: cgit: Add more configuration fields.
Date: Fri, 29 Dec 2017 19:40:05 +0100	[thread overview]
Message-ID: <871sjdz8ca.fsf@lassieur.org> (raw)
In-Reply-To: <87po6yu7h9.fsf@gmail.com>

Oleg Pykhalov <go.wigust@gmail.com> writes:

>> 'url' needs to be the first setting specified for each repo.  I think
>> you could use something like this to make sure it is:
>>
>> (define (serialize-repository-cgit-configuration x)
>>   (define (rest? field)
>>     (not (eq? (configuration-field-name field) 'url)))
>>   (let ((url (repository-cgit-configuration-url x))
>>         (rest (filter rest? repository-cgit-configuration-fields)))
>>     (serialize-repo-string 'url url)
>>     (serialize-configuration x rest)))
>
> Output doesn't change.

[...]

> However, simple reordering fields in (define-configuration …) works.
> I reordered in attached patch.  Is it good enough?

It didn't work because you didn't call the
'serialize-repository-cgit-configuration' function.  With this snippet,
it will be called:

--8<---------------cut here---------------start------------->8---
(serialize-configuration
 (cgit-configuration
  (repositories
   (list
    (repository-cgit-configuration
     (url "http://cgit.magnolia.local")
     (source-filter "la")))))
 cgit-configuration-fields)
--8<---------------cut here---------------end--------------->8---

I'm not sure which way is the best.  I tend to prefer a hard coded logic
because it will prevent bugs if later people forget about the order and
add fields at the wrong place.  If you stick with depending on the
fields order, then could you add very clear comments so that people
don't add fields at the wrong place?  WDYT?

>> I think the official project uses 'cgit' instead of 'Cgit' (there are
>> other occurrences where you use 'Cgit').
>
> Ludovic asked to capitalize cgit in
> https://debbugs.gnu.org/cgi/bugreport.cgi?bug=28283#14

But he was only talking about titles wasn't he?

>>> +  (repository-directory
>>> +   (repository-directory "/srv/git")
>>> +   "Name of the directory to scan for repositories.")
>>
>> I believe it would be clearer if it was named the same way cgit names
>> it: scan-path.
>
> Ludovic asked to rename it in
> https://debbugs.gnu.org/cgi/bugreport.cgi?bug=28283#14
>
> I don't know should we stay close to cgit naming conventions or not.
> Thoughts?

At least it should be possible to grep 'scan_path' in the documentation,
so that users can easily find what to use instead of 'scan-path'.  Could
you say 'scan_path' is the original name in the docstring?

>>> +  (project-list
>>> +   (list '())
>>> +   "A list of subdirectories inside of @code{repository-directory}, relative
>>> +to it, that should loaded as Git repositories.")
>>
>> I forgot one thing: 'project-list' is a file, not a list of strings.  I
>> agree it's weird that cgit's documentation doesn't say it's a file.  I
>> see two solutions:
>
> Sorry, it's not clear for me.  As I understand from CGITRC(5) it's a
> list like:
>
>     project-list=/share/cgit/cgit.png /share/cgit/cgit.jpg
>
> relative to /srv/git (in our case).

CGITRC isn't clear.  It's really a file containing the list of git
directories.  For example:

/etc/cgit/project-list:
--8<---------------cut here---------------start------------->8---
a/b/foo.git
c/bar.git
baz.git
--8<---------------cut here---------------end--------------->8---

And

project-list=/etc/cgit/project-list

>> 1. Change the type to 'string', so that people can set a file name.
>>
>> 2. Use a list type that would transparently transform its values into a
>>    file in the store, with the generated cgitrc file pointing to it.
>>
>> The second solution is better because the user won't need to create the
>> file.
>
> I choose 1st for now, because 2nd I don't understand what need to be
> produced at the end.  Could you give me an example?

With 2nd, users would write a configuration like

(project-list '("a/b/foo.git"
                "c/bar.git"
                "baz.git"))

And 'guix system reconfigure' would create the file
/gnu/store/xxxxxxx-project-list containing those three lines.  The
generated cgitrc file would contain:

project-list=/gnu/store/xxxxxxx-project-list

You could use a type whose serializer would call the 'plain-file'
procedure.

>> Also, could you add a way to use an opaque configuration file?  It would
>> be helpful for users who don't have time to update their configuration,
>> or in case there are new cgit configurations that are not yet
>> implemented by the Scheme service.
>
> Sure.
>
> Is the following order is OK?
>
>     (serialize-configuration
>      (cgit-configuration
>       (extra-options (list "soo=do"))
>       (repositories (list
>                      (repository-cgit-configuration
>                       (module-link-path '("/super/cow" "moo"))
>                       (extra-options (list "goo=foo"))))))
>      cgit-configuration-fields)
>
>     …
>     repo.extra-options=goo=foo
>     extra-options=soo=do
>     # END OF FILE

I was more thinking about something like in the Dovecot service where
you can pass the whole file as a string.

> Also I need to mention that this patch probably will broke system
> reconfigure and require update /etc/config.scm.

Yes, of course :-)

  reply	other threads:[~2017-12-29 18:41 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-22 22:33 [bug#29820] [PATCH] services: cgit: Add more configuration fields Oleg Pykhalov
2017-12-25 17:00 ` Clément Lassieur
2017-12-26 13:54 ` Clément Lassieur
2017-12-26 19:59 ` Clément Lassieur
2017-12-28 16:45   ` Oleg Pykhalov
2017-12-29 18:40     ` Clément Lassieur [this message]
2018-01-31  3:26       ` Oleg Pykhalov
2018-02-24 23:03         ` Clément Lassieur
2018-02-24 23:09           ` Clément Lassieur
2018-02-25  5:25           ` Oleg Pykhalov
2018-02-25  9:34             ` Clément Lassieur
2018-02-27 17:25               ` Ludovic Courtès
2018-02-28  1:50                 ` bug#29820: " Oleg Pykhalov

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

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=871sjdz8ca.fsf@lassieur.org \
    --to=clement@lassieur.org \
    --cc=29820@debbugs.gnu.org \
    --cc=go.wigust@gmail.com \
    /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 public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).