anonymous = models.BooleanField(blank=False,verbose_name='Enable anonymous access')
web = models.BooleanField(blank=False,verbose_name='Enable gitweb access')
approved = models.BooleanField(blank=False)
+ tabwidth = models.IntegerField(default=8, null=False)
initialclone = models.CharField(max_length=256, blank=True, null=True)
remoterepository = models.ForeignKey(RemoteRepository, null=True, blank=True,
verbose_name='Remote repository')
import urllib
from util.LockFile import LockFile
+class TabRemover(object):
+ """
+ Trivial class that removes leading tabs from each row of a file
+ being read.
+ """
+ def __init__(self, filename):
+ self.f = open(filename)
+
+ def readline(self):
+ return self.f.readline().lstrip("\t")
+
+
class AuthorizedKeysDumper(object):
def __init__(self, db, conf):
self.db = db
allrepos = {}
curs = self.db.cursor()
curs.execute("""
-SELECT name,anonymous,web,description,initialclone,
+SELECT name,anonymous,web,description,initialclone,tabwidth,
COALESCE(
(SELECT min(first_name) FROM repository_permissions AS rp
LEFT JOIN auth_user AS au ON au.username=rp.userid
THEN 1 ELSE 0 END
FROM repositories AS r WHERE approved ORDER BY name""")
f = open("%s.tmp" % self.conf.get("paths", "gitweblist"), "w")
- for name, anon, web, description, initialclone, owner, remoterepo in curs:
+ for name, anon, web, description, initialclone, tabwidth, owner, remoterepo in curs:
allrepos[name] = 1
repopath = "%s/repos/%s.git" % (self.conf.get("paths", "githome"), name)
df = open("%s/description" % repopath, "w")
df.write(description)
df.close()
+ # Check if we need to change the tab width (default is 8)
+ repoconf = ConfigParser.ConfigParser()
+ repoconf.readfp(TabRemover("%s/config" % repopath))
+ tabwidth_mod = False
+ if repoconf.has_option('gitweb', 'tabwidth'):
+ if tabwidth != int(repoconf.get('gitweb', 'tabwidth')):
+ tabwidth_mod = True
+ else:
+ # Not specified, so it's 8...
+ if tabwidth != 8:
+ tabwidth_mod = True
+ if tabwidth_mod:
+ if not repoconf.has_section('gitweb'):
+ repoconf.add_section('gitweb')
+ repoconf.set('gitweb', 'tabwidth', tabwidth)
+ with open("%s/config" % repopath, "wb") as cf:
+ repoconf.write(cf)
anonfile = "%s/git-daemon-export-ok" % repopath
htafile = "%s/.htaccess" % repopath