Commits

ejucovy committed 273910d

better error message in case there's an error reading from the repository

  • Participants
  • Parent commits 88aa0e6

Comments (0)

Files changed (5)

trac_gitolite/perm_manager.py

                                         default="trac")
 
     def get_users(self):
-        repo = self.env.get_repository(reponame=self.gitolite_admin_reponame)
-        node = repo.get_node("keydir")
+        node = utils.get_repo_node(self.env, self.gitolite_admin_reponame, 
+                                   "keydir")
         assert node.isdir, "Node %s at /keydir/ is not a directory" % node
         for child in node.get_entries():
             name = child.get_name()
             yield name
 
     def read_config(self):
-        repo = self.env.get_repository(reponame=self.gitolite_admin_reponame)
-        node = repo.get_node("conf/gitolite.conf")
+        node = utils.get_repo_node(self.env, self.gitolite_admin_reponame,
+                                   "conf/gitolite.conf")
         fp = node.get_content()
         return utils.read_config(fp)
     

trac_gitolite/perm_policy.py

             resource = resource.parent
 
     def read_config(self):
-        repo = self.env.get_repository(reponame=self.gitolite_admin_reponame)
-        node = repo.get_node("conf/gitolite.conf")
+        node = utils.get_repo_node(self.env, self.gitolite_admin_reponame,
+                                   "conf/gitolite.conf")
         fp = node.get_content()
         return utils.read_config(fp)
 

trac_gitolite/repo_manager.py

                                      default="git@localhost:gitolite-admin.git")
 
     def read_config(self):
-        repo = self.env.get_repository(reponame=self.gitolite_admin_reponame)
-        node = repo.get_node("conf/gitolite.conf")
+        node = utils.get_repo_node(self.env, self.gitolite_admin_reponame,
+                                   "conf/gitolite.conf")
         fp = node.get_content()
         return utils.read_config(fp)
     

trac_gitolite/user_manager.py

                                      default="git@localhost:gitolite-admin.git")
 
     def get_users(self):
-        repo = self.env.get_repository(reponame=self.gitolite_admin_reponame)
-        node = repo.get_node("keydir")
+        node = utils.get_repo_node(self.env, self.gitolite_admin_reponame, 
+                                   "keydir")
         assert node.isdir, "Node %s at /keydir/ is not a directory" % node
         for child in node.get_entries():
             name = child.get_name()

trac_gitolite/utils.py

 from StringIO import StringIO
 from tempfile import mkdtemp
 
+def get_repo_node(env, repo_name, node):
+    try:
+        from tracopt.versioncontrol.git.PyGIT import GitError
+    except ImportError: ## Pre-1.0 Trac
+        from tracext.git.PyGIT import GitError
+    from trac.core import TracError
+    try:
+        repo = env.get_repository(reponame=repo_name)
+        return repo.get_node(node)
+    except GitError:
+        raise TracError("Error reading Git files at %s; check your repository path (for repo %s) and file permissions" % (node, repo_name))
+
+
 def read_config(fp):
     repos = dict()
     this_repo = None