Re-instate the ".git" suffix on all repositories, since Peter had a lot
authorMagnus Hagander <magnus@hagander.net>
Thu, 26 Mar 2009 15:09:58 +0000 (16:09 +0100)
committerMagnus Hagander <magnus@hagander.net>
Thu, 26 Mar 2009 15:09:58 +0000 (16:09 +0100)
of thought behind it being there.

gitdump.py
pggit.py
reposync.py

index c7b22ec238e5c01e0a2f3eef809948f6c1a704c5..ff8ff9e70508ba9418aa2fea6bb56fd9584a1101 100644 (file)
@@ -58,13 +58,13 @@ FROM repositories AS r WHERE approved ORDER BY name""")
                        allrepos[name] = 1
                        # If this is a remote repository, don't try to create it if it's not there -
                        # this is handled by the repository importer.
-                       if remoterepo and not os.path.isdir("%s/repos/%s" % (self.conf.get("paths", "githome"), name)):
+                       if remoterepo and not os.path.isdir("%s/repos/%s.git" % (self.conf.get("paths", "githome"), name)):
                                continue
 
                        # Check if this repository exists at all
-                       if not os.path.isdir("%s/repos/%s" % (self.conf.get("paths", "githome"), name)):
+                       if not os.path.isdir("%s/repos/%s.git" % (self.conf.get("paths", "githome"), name)):
                                # Does not exist, let's initialize a new one
-                               os.environ['GIT_DIR'] = "%s/repos/%s"% (self.conf.get("paths", "githome"), name)
+                               os.environ['GIT_DIR'] = "%s/repos/%s.git"% (self.conf.get("paths", "githome"), name)
                                if initialclone:
                                        print "Initializing git into %s (cloned repo %s)" % (name, initialclone)
                                        if initialclone.startswith('git://'):
@@ -72,8 +72,8 @@ FROM repositories AS r WHERE approved ORDER BY name""")
                                                oldrepo = initialclone
                                        else:
                                                # This is a local reference, so rewrite it based on our root
-                                               oldrepo = "%s/repos/%s" % (self.conf.get("paths", "githome"), initialclone)
-                                       os.system("git clone --bare %s %s/repos/%s" % (
+                                               oldrepo = "%s/repos/%s.git" % (self.conf.get("paths", "githome"), initialclone)
+                                       os.system("git clone --bare %s %s/repos/%s.git" % (
                                                # Old repo
                                                oldrepo,
                                                # New repo
@@ -87,12 +87,12 @@ FROM repositories AS r WHERE approved ORDER BY name""")
                        # Check for publishing options here
                        if web:
                                f.write("%s %s\n" % (urllib.quote_plus(name), urllib.quote_plus(owner)))
-                               df = open("%s/repos/%s/description" % (self.conf.get("paths", "githome"), name), "w")
+                               df = open("%s/repos/%s.git/description" % (self.conf.get("paths", "githome"), name), "w")
                                df.write(description)
                                df.close()
 
-                       anonfile = "%s/repos/%s/git-daemon-export-ok" % (self.conf.get("paths", "githome"), name)
-                       htafile = "%s/repos/%s/.htaccess" % (self.conf.get("paths", "githome"), name)
+                       anonfile = "%s/repos/%s.git/git-daemon-export-ok" % (self.conf.get("paths", "githome"), name)
+                       htafile = "%s/repos/%s.git/.htaccess" % (self.conf.get("paths", "githome"), name)
                        if anon:
                                if not os.path.isfile(anonfile):
                                        open(anonfile, "w").close()
@@ -114,10 +114,12 @@ FROM repositories AS r WHERE approved ORDER BY name""")
                for d in os.listdir("%s/repos/" % self.conf.get("paths", "githome")):
                        if d.startswith('.'):
                                continue
+                       if d.endswith('.git'):
+                               d = d[:-4]
                        if not allrepos.has_key(d):
                                print "Removing repository %s" % d
                                try:
-                                       shutil.rmtree("%s/repos/%s" % (self.conf.get("paths", "githome"), d))
+                                       shutil.rmtree("%s/repos/%s.git" % (self.conf.get("paths", "githome"), d))
                                except Exception,e:
                                        print "FAIL: unable to remove directory: %s" % e
 
index 9b27b1e98e4f251c8651ec4f2e5d0b3d9e3d7ffc..beda946928d702ef06917e80dd4e9ee2da55e891 100755 (executable)
--- a/pggit.py
+++ b/pggit.py
@@ -81,9 +81,11 @@ class PgGit(object):
                self.path = os.path.normpath(("%s%s" % (self.repoprefix, args[2:].rstrip("'"))))
                if not self.path.startswith(self.repoprefix):
                        raise InternalException("Escaping the root directory is of course not permitted")
+               if not self.path.endswith('.git'):
+                       raise InternalException("Git repository paths must end in .git")
                if not os.path.exists(self.path):
                        raise InternalException('git repository "%s" does not exist' % args)
-               self.subpath = self.path[len(self.repoprefix):]
+               self.subpath = self.path[len(self.repoprefix):-4]
 
        def check_permissions(self):
                writeperm = False
index 05b450b5d907f87f59403fc684836d45d928d2aa..ece98c82c6512ca3c1c8ecb73a83ec6cf1d88ad1 100755 (executable)
@@ -62,7 +62,7 @@ class SyncMethod(object):
                self.name = name
                self.remoteurl = remoteurl
                self.remotemodule = remotemodule
-               self.repopath = "%s/repos/%s" % (self.conf.get("paths", "githome"), self.name)
+               self.repopath = "%s/repos/%s.git" % (self.conf.get("paths", "githome"), self.name)
                
                os.environ['GIT_DIR'] = self.repopath
        
@@ -129,7 +129,7 @@ class SyncMethodRsyncCvs(SyncMethod):
        def initialsync(self):
                # We really only use this for the main repo, so way too lazy to set
                # this up now. Do it manually ;-)
-               raise NotImplementedError("Sorry, initial sync for rsync-cvs not implemnted")
+               raise NotImplementedError("Sorry, initial sync for rsync-cvs not implemented")
 
        def normalsync(self):
                rsyncpath = "%s/rsyncsrc/%s" % (self.conf.get("paths", "githome"), self.name)