Add a command to generate configs for hound
etsy's hound is a simple source code indexer. The hardest part about
running it is making a config file from our projects.yaml. So that's
done now.
Change-Id: Ie4b6509947f58407c4cc6f5a2c7c2bc84c619ce9
diff --git a/jeepyb/cmd/create_hound_config.py b/jeepyb/cmd/create_hound_config.py
new file mode 100644
index 0000000..2fcc7fe
--- /dev/null
+++ b/jeepyb/cmd/create_hound_config.py
@@ -0,0 +1,59 @@
+#! /usr/bin/env python
+# Copyright (c) 2013 Hewlett-Packard Development Company, L.P.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+#
+# create_hound_config.py reads the project config file called projects.yaml
+# and generates a hound configuration file.
+
+import json
+import os
+
+import jeepyb.utils as u
+
+
+PROJECTS_YAML = os.environ.get('PROJECTS_YAML', '/home/hound/projects.yaml')
+GIT_SERVER = os.environ.get('GIT_BASE', 'git.openstack.org')
+DATA_PATH = os.environ.get('DATA_PATH', 'data')
+
+
+def main():
+ registry = u.ProjectsRegistry(PROJECTS_YAML)
+ projects = [entry['project'] for entry in registry.configs_list]
+ repos = {}
+ for project in projects:
+ repos[os.path.basename(project)] = {
+ 'url': "git://%(gitbase)s/%(project)s" % dict(
+ gitbase=GIT_SERVER, project=project),
+ 'url-pattern': {
+ 'base-url': "http://%(gitbase)s/cgit/%(project)s"
+ "/tree/{path}{anchor}" % dict(gitbase=GIT_SERVER,
+ project=project),
+ 'anchor': '#n{line}',
+ }
+ }
+
+ config = {
+ "dbpath": "data",
+ "repos": repos
+ }
+ with open('config.json', 'w') as config_file:
+ config_file.write(
+ json.dumps(
+ config, indent=2,
+ separators=(',', ': '), sort_keys=False,
+ default=unicode))
+
+
+if __name__ == "__main__":
+ main()
diff --git a/setup.cfg b/setup.cfg
index a2a775d..dd10192 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -20,6 +20,7 @@
console_scripts =
close-pull-requests = jeepyb.cmd.close_pull_requests:main
create-cgitrepos = jeepyb.cmd.create_cgitrepos:main
+ create-hound-config = jeepyb.cmd.create_hound_config:main
expire-old-reviews = jeepyb.cmd.expire_old_reviews:main
manage-projects = jeepyb.cmd.manage_projects:main
notify-impact = jeepyb.cmd.notify_impact:main