From 859ad7e349227f844c05ce89d110ba352ac00a92 Mon Sep 17 00:00:00 2001 From: Magnus Hagander Date: Mon, 4 Jan 2021 15:25:32 +0100 Subject: [PATCH] Write a per-repository cgitrc file if required Initially, load a special stylesheet if a tab width of 4 is chosen (like the main pg repo) --- gitdump.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/gitdump.py b/gitdump.py index 26e1f1b..f0a830d 100644 --- a/gitdump.py +++ b/gitdump.py @@ -119,6 +119,8 @@ FROM repositories AS r WHERE approved ORDER BY name""") # Check for publishing options here if web: + cgitrc = io.StringIO() + s.write("%s.git %s\n" % (urllib.parse.quote_plus(name), urllib.parse.quote_plus(owner))) replace_file_from_string( "%s/description" % repopath, @@ -131,6 +133,12 @@ FROM repositories AS r WHERE approved ORDER BY name""") if repoconf.has_option('gitweb', 'tabwidth'): if tabwidth != int(repoconf.get('gitweb', 'tabwidth')): tabwidth_mod = True + + # Write to cgitrc, we check the contents for this one later + # For now, we only support 4 space tabs (or the default 8) in cgit + if int(repoconf.get('gitweb', 'tabwidth')) == 4: + cgitrc.write('extra-head-content=') + cgitrc.write("\n") else: # Not specified, so it's 8... if tabwidth != 8: @@ -143,6 +151,16 @@ FROM repositories AS r WHERE approved ORDER BY name""") cf = open("%s/config" % repopath, "w") repoconf.write(cf) cf.close() + + # If one or more options are in the cgirtc file, create it + if cgitrc.tell(): + replace_file_from_string( + "{}/cgitrc".format(repopath), + cgitrc.getvalue(), + ) + else: + if os.path.isfile("{}/cgitrc".format(repopath)): + os.remove("{}/cgitrc".format(repopath)) else: # If repo should not be exposed on the web, remove the description file. We use this # as a trigger of whether to show it... -- 2.39.5