Re: Groups in cgit



On Sat, 2009-04-18 at 15:12 -0500, Shaun McCance wrote:
> Owen and I discussed doing repository groups in cgit using
> the category property in each module's doap file.  Attached
> is a patch to make this happen on the server.
> 
> Categories in doap are resources, which means they're given
> using URLs.  To have a simple controlled vocabulary, this
> uses resources defined in our doap-extensionsd file.
> 
> If we do this we should:
> 
> 1) Update doap-extensiosn on api.gnome.org.  Attached.
> (Aside: Should we have a git repo for the contents of
> api.gnome.org?)
> 
> 2) Have Pulse put the category in the template files.  It
> should be reasonably reliable for our "core" modules.

Looking through the changes:

                 elif attrname == (RDF, "resource"):
-                    resource = attrname
+                    resource = attrname + (attributes.getValue(attrname),)

I'm pretty sure that the original use of attrname is just a bug/typo and
can be replaced attributes.getValue(attrname).

Which would make:

+    group = node.find_property((DOAP, "category"))
+    if isinstance(group, tuple) and len(group) == 3:
+        group = group[2]
+        group = groups.get(group, 'Other')

Simpler.

+               if test -f $r/gnome_group; then
+                   group=$(cat $r/gnome_group)
+               fi;
                test -z "$group" || echo repo.group=$group

Unfortunately, I don't think cgit isn't going to handle this right; I don't
see any code in cgit to sort the repos by group - it just inserts a header
between adjacent repos in different groups.

Of course, having to sort isn't fun in shell. Something along the untested lines of:

===
for $r in $dirs ; do
    if test -f $r/gnome_group; then
        echo $r $(cat $r/gnome_group) 
    else
        echo $r "Other" 
    fi
done | sort -k 2 -k 1,1 |
while read r group ; do
    # Output information for $r and $group
done
===

Probably works. (And gets you into the "just because you *can* do it in
shell, should you do it in shell?" land.)

- Owen




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]