strip out newlines when writing repo.desc
If newlines end up in the description this breaks cgit hard, strip
those out.
Change-Id: I0f77c36503c522b50e6ae690acd5ff9c6caa7bec
diff --git a/jeepyb/cmd/create_cgitrepos.py b/jeepyb/cmd/create_cgitrepos.py
index 8294f09..70cf9aa 100644
--- a/jeepyb/cmd/create_cgitrepos.py
+++ b/jeepyb/cmd/create_cgitrepos.py
@@ -37,6 +37,16 @@
DEFAULT_ORG = os.environ.get('DEFAULT_ORG', None)
+def clean_string(string):
+ """Scrub out characters that with break cgit.
+
+ cgit can't handle newlines in many of it's fields, so strip them
+ out.
+
+ """
+ return string.replace('\n', ' ').replace('\r', '')
+
+
def main():
registry = u.ProjectsRegistry(PROJECTS_YAML)
gitorgs = {}
@@ -84,7 +94,7 @@
cgit_file.write('\n')
cgit_file.write('repo.url=%s/%s\n' % (org, name))
cgit_file.write('repo.path=%s/\n' % (project_repo))
- cgit_file.write('repo.desc=%s\n' % (description))
+ cgit_file.write('repo.desc=%s\n' % (clean_string(description)))
if not os.path.exists(project_repo):
subprocess.call(['git', 'init', '--bare', project_repo])
subprocess.call(['chown', '-R', '%s:%s'