[Xfce4-commits] <moka:nick/maintainer-improvements> Add gitolite helper and module.

Nick Schermer noreply at xfce.org
Sun Oct 16 19:52:01 CEST 2011


Updating branch refs/heads/nick/maintainer-improvements
         to ba8062fd395acd4de10c47e34c7cc4d93eef2bf1 (commit)
       from fea43e98d539549c7a6102b4421dcb819f088330 (commit)

commit ba8062fd395acd4de10c47e34c7cc4d93eef2bf1
Author: Nick Schermer <nick at xfce.org>
Date:   Sun Oct 16 19:50:44 2011 +0200

    Add gitolite helper and module.

 bin/xfce-gitolite.rb          |   93 -------
 examples/gitolite/dmp         |  532 +++++++++++++++++++++++++++++++++++++++++
 examples/gitolite/gitolite.rb |   19 ++
 lib/helpers/general.rb        |    8 +-
 lib/helpers/gitolite.rb       |   97 ++++++++
 lib/moka.rb                   |    2 +-
 6 files changed, 653 insertions(+), 98 deletions(-)

diff --git a/bin/xfce-gitolite.rb b/bin/xfce-gitolite.rb
deleted file mode 100755
index 58e0c7c..0000000
--- a/bin/xfce-gitolite.rb
+++ /dev/null
@@ -1,93 +0,0 @@
-#!/usr/bin/env ruby
-
-require 'rubygems'
-require 'dm-core'
-require 'dm-migrations'
-require 'moka'
-
-# global configuration
-Moka::Models::Configuration.load do |conf|
-  conf.set :moka_url, 'http://localhost:9292'
-  conf.set :archive_dir, '/home/nick/websites/archive.xfce.org/'
-  conf.set :mirror, 'http://archive.xfce.org/'
-  conf.set :collection_release_pattern, /^([0-9]).([0-9]+)(pre[0-9])?$/
-  conf.set :noreply, 'noreply at xfce.org'
-end
-
-# Connect to the database
-directory = File.expand_path(File.dirname(__FILE__))
-db = File.join(directory, '../examples/xfce/example.db')
-
-#DataMapper::Logger.new($stdout, :debug)
-DataMapper.setup(:default, 'sqlite://' + db)
-
-gitolitedir = '/tmp/gitolitetest'
-
-keydir = File.join(gitolitedir, "keydir")
-File.makedirs(keydir) unless File.directory?(keydir)
-
-confdir = File.join(gitolitedir, "conf")
-File.makedirs(confdir) unless File.directory?(confdir)
-
-# project array
-projects = Hash.new
-
-for maintainer in Moka::Models::Maintainer.all(:active => true).sort
-
-  # update ssh key of this user
-  if maintainer.pubkeys and not maintainer.pubkeys.empty?
-    filename = File.join(keydir, maintainer.username + ".pub")
-    file = File.new(filename, "w+")
-
-    if file
-      begin
-        file.flock(File::LOCK_SH)
-        file.puts maintainer.pubkeys
-      ensure
-        file.flock(File::LOCK_UN)
-      end
-      file.close
-    else
-      puts "Unable to open file " + filename
-    end
-  end
-
-  # store the projects this maintainer handles
-  for project in maintainer.projects
-    if not projects[project.name]
-      projects[project.name ] = Array.new
-    end
-    projects[project.name] << maintainer.username
-  end
-end
-
-
-repo_rules = ""
-
-# build the gitolite config file
-for classification in Moka::Models::Classification.find_all.sort
-
-  for project in classification.project_names.sort
-
-    repo_rules << "repo " + classification.name + "/" + project + "\n"
-
-    if projects[project]
-      repo_rules << "\tRW ="
-      for username in projects[project].sort
-        repo_rules << " " + username
-      end
-      repo_rules << "\n"
-    end
-  repo_rules << "\n"
-  end
-end
-
-# write config file
-cfile = File.new(File.join(confdir, "gitolite.conf"), "w+")
-begin
-  cfile.flock(File::LOCK_SH)
-  cfile.puts repo_rules
-ensure
-  cfile.flock(File::LOCK_UN)
-end
-cfile.close
diff --git a/examples/gitolite/dmp b/examples/gitolite/dmp
new file mode 100644
index 0000000..fd62c95
--- /dev/null
+++ b/examples/gitolite/dmp
@@ -0,0 +1,532 @@
+[#<Moka::Models::Project @name="eatmonkey" @website="http://goodies.xfce.org/projects/applications/eatmonkey" @description=<not loaded>>,
+ ["mmassonnet"]]
+
+
+
+[#<Moka::Models::Project @name="exo" @website="http://xfce.org/projects/exo" @description=<not loaded>>,
+ ["benny", "jannis", "nick"]]
+
+
+
+[#<Moka::Models::Project @name="garcon" @website="http://xfce.org/" @description=<not loaded>>,
+ ["jannis"]]
+
+
+
+[#<Moka::Models::Project @name="ghal" @website="" @description=<not loaded>>,
+ ["kelnos"]]
+
+
+
+[#<Moka::Models::Project @name="gigolo" @website="http://www.uvena.de/gigolo" @description=<not loaded>>,
+ ["enrico"]]
+
+
+
+[#<Moka::Models::Project @name="gsynaptics-mcs-plugin" @website="" @description=<not loaded>>,
+ ["pollux"]]
+
+
+
+[#<Moka::Models::Project @name="gtk-xfce-engine" @website="http://www.xfce.org" @description=<not loaded>>,
+ ["benny",
+  "jannis",
+  "jeromeg",
+  "kelnos",
+  "nick",
+  "olivier",
+  "peter",
+  "stephan"]]
+
+
+
+[#<Moka::Models::Project @name="installit" @website="" @description=<not loaded>>,
+ ["benny", "jannis"]]
+
+
+
+[#<Moka::Models::Project @name="libxfce4menu" @website="http://www.xfce.org/" @description=<not loaded>>,
+ ["jannis"]]
+
+
+
+[#<Moka::Models::Project @name="libxfce4ui" @website="http://www.xfce.org/" @description=<not loaded>>,
+ ["kelnos", "nick"]]
+
+
+
+[#<Moka::Models::Project @name="libxfce4util" @website="http://www.xfce.org/" @description=<not loaded>>,
+ ["benny", "jannis", "kelnos", "nick", "olivier", "stephan"]]
+
+
+
+[#<Moka::Models::Project @name="libxfcegui4" @website="http://www.xfce.org" @description=<not loaded>>,
+ ["benny", "jannis", "kelnos", "nick", "olivier", "stephan"]]
+
+
+
+[#<Moka::Models::Project @name="midori" @website="http://www.twotoasts.de/index.php?/pages/midori_summary.html" @description=<not loaded>>,
+ ["kalikiana"]]
+
+
+
+[#<Moka::Models::Project @name="mousepad" @website="http://goodies.xfce.org/projects/applications/mousepad" @description=<not loaded>>,
+ ["erikharrison", "nick"]]
+
+
+
+[#<Moka::Models::Project @name="notification-daemon-xfce" @website="http://goodies.xfce.org/projects/applications/mousepad" @description=<not loaded>>,
+ ["jannis", "nick"]]
+
+
+
+[#<Moka::Models::Project @name="orage" @website="http://www.xfce.org/projects/orage/" @description=<not loaded>>,
+ ["juha"]]
+
+
+
+[#<Moka::Models::Project @name="parole" @website="http://goodies.xfce.org/projects/applications/parole" @description=<not loaded>>,
+ ["aliov"]]
+
+
+
+[#<Moka::Models::Project @name="postler" @website="https://launchpad.net/postler" @description=<not loaded>>,
+ ["kalikiana"]]
+
+
+
+[#<Moka::Models::Project @name="pyxfce" @website="" @description=<not loaded>>,
+ ["dannym"]]
+
+
+
+[#<Moka::Models::Project @name="ristretto" @website="http://goodies.xfce.org/projects/applications/ristretto" @description=<not loaded>>,
+ ["stephan"]]
+
+
+
+[#<Moka::Models::Project @name="squeeze" @website="http://squeeze.xfce.org/" @description=<not loaded>>,
+ ["peter", "stephan"]]
+
+
+
+[#<Moka::Models::Project @name="terminal" @website="http://goodies.xfce.org/projects/applications/terminal" @description=<not loaded>>,
+ ["benny", "nick"]]
+
+
+
+[#<Moka::Models::Project @name="thunar" @website="http://thunar.xfce.org/" @description=<not loaded>>,
+ ["benny", "jannis"]]
+
+
+
+[#<Moka::Models::Project @name="thunar-actions-plugin" @website="" @description=<not loaded>>,
+ ["noik", "tuxcrafter"]]
+
+
+
+[#<Moka::Models::Project @name="thunar-archive-plugin" @website="http://goodies.xfce.org/projects/thunar-plugins/thunar-archive-plugin" @description=<not loaded>>,
+ ["benny", "jannis"]]
+
+
+
+[#<Moka::Models::Project @name="thunar-media-tags-plugin" @website="" @description=<not loaded>>,
+ ["jannis"]]
+
+
+
+[#<Moka::Models::Project @name="thunar-shares-plugin" @website="" @description=<not loaded>>,
+ ["danielm"]]
+
+
+
+[#<Moka::Models::Project @name="thunar-svn-plugin" @website="http://goodies.xfce.org/projects/thunar-plugins/thunar-svn-plugin" @description=<not loaded>>,
+ ["peter"]]
+
+
+
+[#<Moka::Models::Project @name="thunar-thumbnailers" @website="http://goodies.xfce.org/projects/thunar-plugins/thunar-thumbnailers" @description=<not loaded>>,
+ ["erland"]]
+
+
+
+[#<Moka::Models::Project @name="thunar-vcs-plugin" @website="http://goodies.xfce.org/projects/thunar-plugins/thunar-vcs-plugin" @description=<not loaded>>,
+ ["peter"]]
+
+
+
+[#<Moka::Models::Project @name="thunar-vfs" @website="http://thunar.xfce.org" @description=<not loaded>>,
+ ["benny", "jannis", "nick"]]
+
+
+
+[#<Moka::Models::Project @name="thunar-volman" @website="http://goodies.xfce.org/projects/thunar-plugins/thunar-volman" @description=<not loaded>>,
+ ["benny", "jannis"]]
+
+
+
+[#<Moka::Models::Project @name="thunarx-python" @website="http://goodies.xfce.org/projects/bindings/thunarx-python" @description=<not loaded>>,
+ ["adamplumb"]]
+
+
+
+[#<Moka::Models::Project @name="transd" @website="http://spuriousinterrupt.org/projects/transd" @description=<not loaded>>,
+ ["kelnos"]]
+
+
+
+[#<Moka::Models::Project @name="tumbler" @website="http://git.xfce.org/apps/tumbler" @description=<not loaded>>,
+ ["jannis"]]
+
+
+
+[#<Moka::Models::Project @name="verve-plugin" @website="http://goodies.xfce.org/projects/panel-plugins/verve-plugin?&#recent_releases" @description=<not loaded>>,
+ ["jannis"]]
+
+
+
+[#<Moka::Models::Project @name="xarchiver" @website="http://xarchiver.xfce.org" @description=<not loaded>>,
+ ["colossus"]]
+
+
+
+[#<Moka::Models::Project @name="xfbib" @website="http://goodies.xfce.org/projects/applications/xfbib" @description=<not loaded>>,
+ ["tssj", "zarper"]]
+
+
+
+[#<Moka::Models::Project @name="xfburn" @website="http://goodies.xfce.org/projects/applications/xfburn" @description=<not loaded>>,
+ ["mario", "pollux", "squisher"]]
+
+
+
+[#<Moka::Models::Project @name="xfc" @website="" @description=<not loaded>>,
+ ["bl", "jcfranks"]]
+
+
+
+[#<Moka::Models::Project @name="xfce-installers" @website="" @description=<not loaded>>,
+ ["benny", "jannis", "kelnos", "nick", "olivier", "stephan"]]
+
+
+
+[#<Moka::Models::Project @name="xfce-utils" @website="http://www.xfce.org" @description=<not loaded>>,
+ ["benny", "jannis", "kelnos", "nick", "olivier", "stephan"]]
+
+
+
+[#<Moka::Models::Project @name="xfce4-appfinder" @website="http://www.xfce.org" @description=<not loaded>>,
+ ["jannis", "jasper", "stephan"]]
+
+
+
+[#<Moka::Models::Project @name="xfce4-artwork" @website="" @description=<not loaded>>,
+ ["sas"]]
+
+
+
+[#<Moka::Models::Project @name="xfce4-battery-plugin" @website="http://goodies.xfce.org/projects/panel-plugins/xfce4-battery-plugin" @description=<not loaded>>,
+ ["frivoal", "nick", "sofar"]]
+
+
+
+[#<Moka::Models::Project @name="xfce4-cddrive-plugin" @website="" @description=<not loaded>>,
+ ["frivoal", "syl"]]
+
+
+
+[#<Moka::Models::Project @name="xfce4-cellmodem-plugin" @website="" @description=<not loaded>>,
+ ["alvieboy", "frivoal", "nick"]]
+
+
+
+[#<Moka::Models::Project @name="xfce4-clipman-plugin" @website="http://goodies.xfce.org/projects/panel-plugins/xfce4-clipman-plugin" @description=<not loaded>>,
+ ["mmassonnet", "nick"]]
+
+
+
+[#<Moka::Models::Project @name="xfce4-cpufreq-plugin" @website="http://goodies.xfce.org/projects/panel-plugins/xfce4-cpufreq-plugin" @description=<not loaded>>,
+ ["frivoal", "shrek"]]
+
+
+
+[#<Moka::Models::Project @name="xfce4-cpugraph-plugin" @website="http://goodies.xfce.org/projects/panel-plugins/xfce4-cpugraph-plugin" @description=<not loaded>>,
+ ["frivoal", "lidiriel"]]
+
+
+
+[#<Moka::Models::Project @name="xfce4-datetime-plugin" @website="" @description=<not loaded>>,
+ ["frivoal", "ongardie", "stacium"]]
+
+
+
+[#<Moka::Models::Project @name="xfce4-dev-tools" @website="http://xfce.org/" @description=<not loaded>>,
+ ["benny", "jannis", "kelnos", "nick", "olivier", "stephan"]]
+
+
+
+[#<Moka::Models::Project @name="xfce4-dict" @website="http://goodies.xfce.org/projects/applications/xfce4-dict" @description=<not loaded>>,
+ ["enrico"]]
+
+
+
+[#<Moka::Models::Project @name="xfce4-diskperf-plugin" @website="http://goodies.xfce.org/projects/panel-plugins/xfce4-diskperf-plugin" @description=<not loaded>>,
+ ["cockroach", "frivoal", "landry", "nick"]]
+
+
+
+[#<Moka::Models::Project @name="xfce4-eyes-plugin" @website="http://goodies.xfce.org/projects/panel-plugins/xfce4-eyes-plugin" @description=<not loaded>>,
+ ["frivoal", "nick"]]
+
+
+
+[#<Moka::Models::Project @name="xfce4-fsguard-plugin" @website="http://goodies.xfce.org/projects/panel-plugins/xfce4-fsguard-plugin?&#recet_releases" @description=<not loaded>>,
+ ["cockroach", "frivoal", "mmassonnet"]]
+
+
+
+[#<Moka::Models::Project @name="xfce4-genmon-plugin" @website="http://goodies.xfce.org/projects/panel-plugins/xfce4-genmon-plugin" @description=<not loaded>>,
+ ["frivoal", "jujucece"]]
+
+
+
+[#<Moka::Models::Project @name="xfce4-icon-theme" @website="" @description=<not loaded>>,
+ ["stephan"]]
+
+
+
+[#<Moka::Models::Project @name="xfce4-indicator-plugin" @website="http://goodies.xfce.org/projects/panel-plugins/xfce4-indicator-plugin" @description=<not loaded>>,
+ ["markt"]]
+
+
+
+[#<Moka::Models::Project @name="xfce4-mailwatch-plugin" @website="" @description=<not loaded>>,
+ ["frivoal", "kelnos"]]
+
+
+
+[#<Moka::Models::Project @name="xfce4-mixer" @website="http://www.xfce.org/projects/xfce4-mixer" @description=<not loaded>>,
+ ["jannis"]]
+
+
+
+[#<Moka::Models::Project @name="xfce4-mm" @website="" @description=<not loaded>>,
+ ["perldude"]]
+
+
+
+[#<Moka::Models::Project @name="xfce4-modemlights-plugin" @website="" @description=<not loaded>>,
+ ["mmassonnet"]]
+
+
+
+[#<Moka::Models::Project @name="xfce4-mount-plugin" @website="" @description=<not loaded>>,
+ ["timystery"]]
+
+
+
+[#<Moka::Models::Project @name="xfce4-mpc-plugin" @website="http://goodies.xfce.org/projects/panel-plugins/xfce4-mpc-plugin" @description=<not loaded>>,
+ ["landry"]]
+
+
+
+[#<Moka::Models::Project @name="xfce4-netload-plugin" @website="http://goodies.xfce.org/projects/panel-plugins/xfce4-netload-plugin" @description=<not loaded>>,
+ ["frivoal"]]
+
+
+
+[#<Moka::Models::Project @name="xfce4-notes-plugin" @website="http://goodies.xfce.org/projects/panel-plugins/xfce4-notes-plugin" @description=<not loaded>>,
+ ["mmassonnet"]]
+
+
+
+[#<Moka::Models::Project @name="xfce4-notifyd" @website="http://goodies.xfce.org/projects/applications/xfce4-notifyd" @description=<not loaded>>,
+ ["jeromeg", "kelnos"]]
+
+
+
+[#<Moka::Models::Project @name="xfce4-panel" @website="http://www.xfce.org/projects/xfce4-panel" @description=<not loaded>>,
+ ["jasper", "nick"]]
+
+
+
+[#<Moka::Models::Project @name="xfce4-perl" @website="" @description=<not loaded>>,
+ ["kelnos"]]
+
+
+
+[#<Moka::Models::Project @name="xfce4-places-plugin" @website="http://goodies.xfce.org/projects/panel-plugins/xfce4-places-plugin" @description=<not loaded>>,
+ ["frivoal", "ongardie"]]
+
+
+
+[#<Moka::Models::Project @name="xfce4-power-manager" @website="http://goodies.xfce.org/projects/applications/xfce4-power-manager" @description=<not loaded>>,
+ ["aliov"]]
+
+
+
+[#<Moka::Models::Project @name="xfce4-quicklauncher-plugin" @website="" @description=<not loaded>>,
+ ["frivoal"]]
+
+
+
+[#<Moka::Models::Project @name="xfce4-radio-plugin" @website="http://goodies.xfce.org/projects/panel-plugins/xfce4-radio-plugin" @description=<not loaded>>,
+ ["cockroach"]]
+
+
+
+[#<Moka::Models::Project @name="xfce4-sample-plugin" @website="" @description=<not loaded>>,
+ ["jasper", "nick"]]
+
+
+
+[#<Moka::Models::Project @name="xfce4-screenshooter" @website="http://goodies.xfce.org/projects/applications/xfce4-screenshooter" @description=<not loaded>>,
+ ["jeromeg"]]
+
+
+
+[#<Moka::Models::Project @name="xfce4-sensors-plugin" @website="http://goodies.xfce.org/projects/panel-plugins/xfce4-sensors-plugin" @description=<not loaded>>,
+ ["cockroach", "timystery"]]
+
+
+
+[#<Moka::Models::Project @name="xfce4-session" @website="http://www.xfce.org" @description=<not loaded>>,
+ ["aliov", "benny", "jeromeg", "kelnos"]]
+
+
+
+[#<Moka::Models::Project @name="xfce4-settings" @website="http://www.xfce.org/" @description=<not loaded>>,
+ ["jannis", "kelnos", "nick", "olivier", "stephan"]]
+
+
+
+[#<Moka::Models::Project @name="xfce4-smartbookmark-plugin" @website="" @description=<not loaded>>,
+ ["frivoal"]]
+
+
+
+[#<Moka::Models::Project @name="xfce4-smartpm-plugin" @website="" @description=<not loaded>>,
+ ["afb"]]
+
+
+
+[#<Moka::Models::Project @name="xfce4-stopwatch-plugin" @website="http://goodies.xfce.org/projects/panel-plugins/xfce4-stopwatch-plugin" @description=<not loaded>>,
+ ["ongardie"]]
+
+
+
+[#<Moka::Models::Project @name="xfce4-systemload-plugin" @website="http://goodies.xfce.org/projects/panel-plugins/xfce4-systemload-plugin" @description=<not loaded>>,
+ ["frivoal", "nick"]]
+
+
+
+[#<Moka::Models::Project @name="xfce4-taskmanager" @website="http://goodies.xfce.org/projects/applications/xfce4-taskmanager" @description=<not loaded>>,
+ ["mmassonnet", "timystery"]]
+
+
+
+[#<Moka::Models::Project @name="xfce4-time-out-plugin" @website="http://goodies.xfce.org/projects/panel-plugins/xfce4-time-out-plugin" @description=<not loaded>>,
+ ["frivoal", "jannis"]]
+
+
+
+[#<Moka::Models::Project @name="xfce4-timer-plugin" @website="http://goodies.xfce.org/projects/panel-plugins/xfce4-timer-plugin" @description=<not loaded>>,
+ ["frivoal", "ilgar"]]
+
+
+
+[#<Moka::Models::Project @name="xfce4-vala" @website="http://goodies.xfce.org/projects/bindings/start" @description=<not loaded>>,
+ ["mmassonnet"]]
+
+
+
+[#<Moka::Models::Project @name="xfce4-verve-plugin" @website="http://goodies.xfce.org/projects/panel-plugins/verve-plugin" @description=<not loaded>>,
+ ["frivoal", "jannis"]]
+
+
+
+[#<Moka::Models::Project @name="xfce4-volstatus-icon" @website="" @description=<not loaded>>,
+ ["kelnos"]]
+
+
+
+[#<Moka::Models::Project @name="xfce4-volumed" @website="https://launchpad.net/xfce4-volumed" @description=<not loaded>>,
+ ["sidi"]]
+
+
+
+[#<Moka::Models::Project @name="xfce4-wavelan-plugin" @website="http://goodies.xfce.org/projects/panel-plugins/xfce4-wavelan-plugin" @description=<not loaded>>,
+ ["frivoal", "jamesw", "landry"]]
+
+
+
+[#<Moka::Models::Project @name="xfce4-weather-plugin" @website="http://goodies.xfce.org/projects/panel-plugins/xfce4-weather-plugin" @description=<not loaded>>,
+ ["colin", "frivoal", "nick"]]
+
+
+
+[#<Moka::Models::Project @name="xfce4-wmdock-plugin" @website="" @description=<not loaded>>,
+ ["ellguth"]]
+
+
+
+[#<Moka::Models::Project @name="xfce4-xfapplet-plugin" @website="" @description=<not loaded>>,
+ ["adriano", "frivoal"]]
+
+
+
+[#<Moka::Models::Project @name="xfce4-xkb-plugin" @website="http://goodies.xfce.org/projects/panel-plugins/xfce4-xkb-plugin" @description=<not loaded>>,
+ ["frivoal", "nick", "sasoiliev", "winterheart"]]
+
+
+
+[#<Moka::Models::Project @name="xfce4-xmms-plugin" @website="http://goodies.xfce.org/projects/panel-plugins/xfce4-xmms-plugin" @description=<not loaded>>,
+ ["gaso", "ilgar"]]
+
+
+
+[#<Moka::Models::Project @name="xfconf" @website="http://www.xfce.org" @description=<not loaded>>,
+ ["kelnos", "nick", "stephan"]]
+
+
+
+[#<Moka::Models::Project @name="xfdesktop" @website="http://www.xfce.org" @description=<not loaded>>,
+ ["kelnos"]]
+
+
+
+[#<Moka::Models::Project @name="xfmedia" @website="" @description=<not loaded>>,
+ ["kelnos"]]
+
+
+
+[#<Moka::Models::Project @name="xfmedia-remote-plugin" @website="" @description=<not loaded>>,
+ ["pasi"]]
+
+
+
+[#<Moka::Models::Project @name="xfmpc" @website="http://goodies.xfce.org/projects/applications/xfmpc" @description=<not loaded>>,
+ ["mmassonnet", "vincent"]]
+
+
+
+[#<Moka::Models::Project @name="xfswitch-plugin" @website="" @description=<not loaded>>,
+ ["jeromeg"]]
+
+
+
+[#<Moka::Models::Project @name="xfvnc" @website="" @description=<not loaded>>,
+ ["kelnos"]]
+
+
+
+[#<Moka::Models::Project @name="xfwm4" @website="http://www.xfce.org" @description=<not loaded>>,
+ ["olivier"]]
+
+
+
+[#<Moka::Models::Project @name="xfwm4-themes" @website="" @description=<not loaded>>,
+ ["olivier"]]
+
+
+
diff --git a/examples/gitolite/gitolite.rb b/examples/gitolite/gitolite.rb
new file mode 100755
index 0000000..fc1b5d6
--- /dev/null
+++ b/examples/gitolite/gitolite.rb
@@ -0,0 +1,19 @@
+#!/usr/bin/env ruby
+
+require 'rubygems'
+require 'dm-core'
+require 'dm-migrations'
+require 'digest/sha1'
+
+require '../../lib/moka'
+
+#DataMapper::Logger.new($stdout, :debug)
+DataMapper.setup(:default, 'sqlite:../xfce/example.db')
+DataMapper.finalize
+
+Moka::Models::Configuration.load do |conf|
+  conf.set :archive_dir, '/home/nick/websites/archive.xfce.org/'
+end
+
+generator = Moka::Gitolite.new
+generator.run('/tmp/gitolitetest')
diff --git a/lib/helpers/general.rb b/lib/helpers/general.rb
index d012e93..428fdab 100755
--- a/lib/helpers/general.rb
+++ b/lib/helpers/general.rb
@@ -4,10 +4,10 @@ module Moka
   module Helpers
     module General
       def self.registered(app)
-        app.before do 
+        app.before do
           env[:error] = {}
         end
-      
+
         app.helpers Helpers
       end
 
@@ -24,7 +24,7 @@ module Moka
         end
 
         def view(template, custom_binding = nil)
-          render_layout(custom_binding) do 
+          render_layout(custom_binding) do
             directory = File.expand_path(File.dirname(__FILE__))
             filename = File.join(directory, '..', 'views', "#{template}.haml")
             engine = open(filename) do |file| Haml::Engine.new(file.read) end
@@ -55,7 +55,7 @@ module Moka
           end
           names.join(', ')
         end
-        
+
         def validate_password(password1, password2)
           if password1.empty? or password1.length < 6
               error_set(:newpassword, 'The password must be at least 6 characters long.')
diff --git a/lib/helpers/gitolite.rb b/lib/helpers/gitolite.rb
new file mode 100644
index 0000000..d16230b
--- /dev/null
+++ b/lib/helpers/gitolite.rb
@@ -0,0 +1,97 @@
+require 'rubygems'
+require 'sinatra'
+require 'pp'
+
+module Moka
+  class Gitolite
+    include Moka::Models
+
+    def run(gitolitedir)
+      keydir = File.join(gitolitedir, "keydir")
+      File.makedirs(keydir) unless File.directory?(keydir)
+
+      confdir = File.join(gitolitedir, "conf")
+      File.makedirs(confdir) unless File.directory?(confdir)
+
+      # project array
+      projects = Hash.new
+
+      for maintainer in Moka::Models::Maintainer.all(:active => true).sort
+        if pubkeys(keydir, maintainer)
+          # store the projects this maintainer handles
+          for project in maintainer.projects
+            projects[project.name] = Array.new if not projects[project.name]
+            projects[project.name] << maintainer.username
+          end
+        end
+      end
+
+      conf = "# This file is generated by Moka\n\n"
+
+      for classification in Moka::Models::Classification.find_all.sort
+        for project in classification.project_names.sort
+          conf << "repo " + classification.name + "/" + project + "\n"
+          conf << "\tRW = @repo-admin"
+
+          maintainers = projects[project]
+          if maintainers
+            conf << "\n\tRW ="
+            maintainers.sort.each { |name| conf << " " + name }
+          end
+          conf << "\n\n"
+        end
+      end
+
+      #projects.sort.each do |project, maintainers|
+      #  classification = project.classification
+      #  if classification
+      #    conf << "repo " + classification.name + "/" + project.name + "\n"
+      #    conf << "\tRW ="
+      #    maintainers.sort.each { |name| conf << " " + name }
+      #    conf << "\n\n"
+      #  else
+      #    puts "ERROR: #{project.name} has no classification"
+      #  end
+      #end
+
+      cfile = File.new(File.join(confdir, "gitolite.conf"), "w+")
+      begin
+        cfile.flock(File::LOCK_SH)
+        cfile.puts conf
+      ensure
+        cfile.flock(File::LOCK_UN)
+      end
+      cfile.close
+    end
+
+    def pubkeys(keydir, maintainer)
+      haskeys = false
+
+      if maintainer.pubkeys and not maintainer.pubkeys.empty?
+        keys = maintainer.pubkeys.split("\n").sort
+        n = 1
+        keys.each do |key|
+          filename = File.join(keydir, maintainer.username + "@" + n.to_s + ".pub")
+          file = File.new(filename, "w+")
+
+          if file
+            begin
+              file.flock(File::LOCK_SH)
+              file.puts key
+            ensure
+              file.flock(File::LOCK_UN)
+            end
+            file.close
+            n += 1
+          else
+            puts "Unable to open file " + filename
+          end
+        end
+
+        haskeys = true if n > 1
+      end
+
+      return haskeys
+    end
+  end
+end
diff --git a/lib/moka.rb b/lib/moka.rb
index a569e8c..818f9f3 100755
--- a/lib/moka.rb
+++ b/lib/moka.rb
@@ -10,6 +10,7 @@ for model in models
 end
 
 require File.join(directory, 'helpers', 'general')
+require File.join(directory, 'helpers', 'gitolite')
 
 helpers = ['announcements', 'authentication', 'collections', 'projects', 'maintainers']
 for helper in helpers
@@ -53,6 +54,5 @@ module Moka
         view :index
       end
     end
-  
   end
 end


More information about the Xfce4-commits mailing list