[sysadmin-bin: 98/168] Create a fallback GIT_DIR/gnome_doap from MAINTAINERS
- From: Andrea Veri <av src gnome org>
- To: gnome-sysadmin gnome org,commits-list gnome org
- Subject: [sysadmin-bin: 98/168] Create a fallback GIT_DIR/gnome_doap from MAINTAINERS
- Date: Thu, 24 May 2012 19:59:41 +0000 (UTC)
commit 375c5d611cdba91b1c394e31bd0e68cf64986a8e
Author: Owen W. Taylor <otaylor fishsoup net>
Date: Fri Apr 24 18:45:50 2009 -0400
Create a fallback GIT_DIR/gnome_doap from MAINTAINERS
Turn the MAINTAINERS information into DOAP form so that we can
include non-doapified modules in repositories.doap
doap-from-maintainers | 57 +++++++++++++++++++++++++++++++++++++++
post-receive-update-description | 33 ++++++++++++++++++----
2 files changed, 84 insertions(+), 6 deletions(-)
---
diff --git a/doap-from-maintainers b/doap-from-maintainers
new file mode 100755
index 0000000..a175287
--- /dev/null
+++ b/doap-from-maintainers
@@ -0,0 +1,57 @@
+#!/usr/bin/python
+import os
+import re
+import sys
+
+import semi_rdf
+
+DOAP = "http://usefulinc.com/ns/doap#"
+FOAF = "http://xmlns.com/foaf/0.1/"
+GNOME = "http://api.gnome.org/doap-extensions#"
+
+projectnode = semi_rdf.Node((DOAP, "Project"), )
+
+nodes = [projectnode]
+
+data = sys.stdin.read()
+
+nr, name, email, uid = 0, None, None, None
+for l in data.splitlines():
+ if l.startswith('#'): continue
+
+ nr += 1
+
+ if l == "":
+ if name is not None and uid is not None:
+ maintainernode = semi_rdf.Node((FOAF, "Person"))
+ maintainernode.add_property((FOAF, "name"), None, name)
+ maintainernode.add_property((GNOME, "userid"), None, uid)
+ if email is not None:
+ # Some people have obscurified their emails by replacing
+ # @ and . with ' '. Changing ' ' to . won't unobscurify
+ # but makes the mailto: URL valid.
+ email = re.sub('\s+', '.', email)
+
+ maintainernode.add_property((FOAF, "mbox"),
+ None,
+ "mailto:" + semi_rdf.UrlResource(email))
+ projectnode.add_property((DOAP, "maintainer"), None, maintainernode)
+ nodes.append(maintainernode)
+
+ nr, name, email, uid = 0, None, None, None
+ continue
+
+ if nr == 1:
+ name = l
+ elif ":" in l:
+ field, value = l.split(": ", 1)
+ field = field.rstrip()
+ value = value.strip().lower()
+ if field == 'E-mail' or field == 'E-Mail' or field == 'Email' or field == 'EMail':
+ email = value
+ elif field == 'Userid':
+ uid = value
+ else:
+ print "ERROR: Strange field: %s (module: %s)" % (field, modname)
+
+semi_rdf.dump_rdf(nodes, sys.stdout)
diff --git a/post-receive-update-description b/post-receive-update-description
index 9e57d52..658b6f0 100755
--- a/post-receive-update-description
+++ b/post-receive-update-description
@@ -8,7 +8,7 @@ GIT_DIR=$(git rev-parse --git-dir 2>/dev/null)
absdir=$(cd $GIT_DIR && pwd)
projectshort=$(basename ${absdir%.git})
-update_description_from_file() {
+update_info_from_doap() {
rev=$1
path=$2
mode=$3
@@ -21,7 +21,20 @@ update_description_from_file() {
$BINDIR/update-cgit
}
-update_description() {
+update_info_from_maintainers() {
+ rev=$1
+ path=$2
+ mode=$3
+
+ if [ "$path" != "MAINTAINERS" ] ; then
+ return
+ fi
+
+ git cat-file blob "$newrev:$path" | $BINDIR/doap-from-maintainers > $GIT_DIR/gnome_doap
+ $BINDIR/update-cgit
+}
+
+update_info() {
oldrev=$1
newrev=$2
refname=$3
@@ -42,12 +55,20 @@ update_description() {
return 0
fi
+ # If there is no .doap file, we fall back to the MAINTAINERS
+ # file for compability
+ if git cat-file -e $newrev:$projectshort.doap 2>/dev/null ; then
+ update=update_info_from_doap
+ else
+ update=update_info_from_maintainers
+ fi
+
if expr $oldrev : "^0\+$" > /dev/null 2>&1; then
# Branch creation
git ls-tree $newrev | (
while read mode objtype sha path ; do
if [ $objtype = blob ] ; then
- update_description_from_file $newrev $path $mode
+ $update $newrev $path $mode
fi
done
)
@@ -67,16 +88,16 @@ update_description() {
# Strip colon from the source mode
srcmode=${srcmode#:}
- update_description_from_file $newrev $destpath $destmode
+ $update $newrev $destpath $destmode
done
)
fi
}
if [ $# = 3 ] ; then
- update_description $@ || exit 1
+ update_info $@ || exit 1
else
while read oldrev newrev refname; do
- update_description $oldrev $newrev $refname || exit 1
+ update_info $oldrev $newrev $refname || exit 1
done
fi
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]