git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: CGit and repository list

From
Petr Baudis <pasky@suse.cz>
Date
Sep 12, 2008, 22:48 UTC
Message-ID
<20080912224817.GF10360@machine.or.cz>
In-Reply-To
<200809121812.40920.johan@herland.net>
On Fri, Sep 12, 2008 at 06:12:40PM +0200, Johan Herland wrote:
Show 21 quoted lines
> On Friday 12 September 2008, Lars Hjemli wrote:
> > On Fri, Sep 12, 2008 at 4:58 PM, Petr Baudis <pasky@suse.cz> wrote:
> > > it seems that cgit
> > > requires all the repositories explicitly listed in the config file.
> > > Do you plan to remove this limitation in the future?
> >
> > Not really, I'd rather add another command (or a commandline option)
> > to generate an include-file for cgitrc by scanning directory-trees
> > for git repos. I've CC'd Kristian since I believe he's got such a
> > script running for freedesktop.org; if so, maybe it could be
> > included/used as basis for something similar in cgit?
> 
> Here's a script I wrote for locating repos and generating repo 
> lists/configs for cgit, gitweb and hgwebdir (yes, this handles hg repos 
> as well). It works either as a CGI script (producing a list of detected 
> repos in HTML format), or from the command-line. It's only been tested 
> on an experimental DVCS server at $dayjob, so you might have to change 
> things to make it work in your scenario.
> 
> If there is interest in this, I can create a public repo and we can keep 
> improving on it.

Thanks. The script was a bit more scary than I thought, but in the end I managed to generate something. There are trailing dots in project names, but I'm not going to waste time on that anymore - this has long gone over the 20 minutes I originally alotted the project anyway; I hope cgit will gain a builtin capability for this in the future, since this is still quite a pain. Attached is a random patch for your script I had to use, FWIW.

Unfortunately, the recommended RewriteRule is not working - it does not play well together with query parameters cgit is using, so e.g. browsing past commits does not work. What RewriteRule should I use instead?

-- 
				Petr "Pasky" Baudis
The next generation of interesting software will be done
on the Macintosh, not the IBM PC.  -- Bill Gates


--- repofinder-orig.py	2008-09-13 00:44:22.000000000 +0200
+++ repofinder.py	2008-09-13 00:44:47.000000000 +0200
@@ -244,7 +244,7 @@
 			if (self.group):
 				assert name.startswith(self.group.path)
 				name = name[len(self.group.path):]
-			name = name.strip("/")
+			name = name.strip("/srv/git/")
 			self._name = self.nameFromPath(name)
 		return self._name
 	name = property(getName)
@@ -267,7 +267,10 @@
 		"""Return a (name, email) tuple with our best guess as to who
 		   owns this repo
 		"""
-		return (self.ownerName, self.ownerEmail)
+		__o = self.ownerName
+		if (__o is None):
+			__o = ''
+		return (__o, self.ownerEmail)
 	owner = property(getOwner)
 
 	def getDescription (self):
@@ -286,14 +289,15 @@
 
 	@staticmethod
 	def nameFromPath (path):
-		if path.endswith(".git"): path = path[:-4]
+		if path.endswith(".git"): path = path[:-5]
 		path = path.rstrip("/")
 		return path
 
 	@staticmethod
 	def cloneUrlFromPath (path):
 		if path.endswith("/.git"): path = path[:-5]
-		return "ssh://%s%s" % (Settings['ServerName'], path)
+		path = path.strip("/srv/git")
+		return "git://%s/%sgit" % (Settings['ServerName'], path)
 
 	def __init__ (self, path):
 		Repo.__init__(self, path)
@@ -316,6 +320,9 @@
 	def getOwnerEmail (self):
 		if self._ownerEmail is None:
 			self._ownerEmail = self.config.get("user.email")
+		if self._ownerEmail is None:
+			try: self._ownerEmail = open(os.path.join(self.path, "owner")).read().strip()
+			except: pass
 		return Repo.getOwnerEmail(self)
 	ownerEmail = property(getOwnerEmail)
 
@@ -592,12 +599,12 @@
 		for repo in sorted(group.repos):
 			url = repo.path
 			if url.endswith("/.git"): url = url[:-5]
-			url = url.strip("/")
+			url = url.strip("/srv/git/")
 			print >>self.f, "repo.url=%s" % (url)
 			print >>self.f, "repo.path=%s" % (repo.path)
 			print >>self.f, "repo.name=%s" % (repo.name)
 			print >>self.f, "repo.desc=%s" % (repo.description)
-			print >>self.f, "repo.owner=%s <%s>" % repo.owner
+			print >>self.f, "repo.owner=%s%s" % repo.owner
 			print >>self.f, "repo.clone-url=%s" % (repo.clone)
 			print >>self.f, ""
 
Previous: Petr BaudisNext: Lars Hjemli
Message 17 of 26 in “configuring git public repository”
  1. sagi4Sep 12, 2008
  2. Ciprian Dorin CraciunSep 12, 2008
  3. Jakub NarebskiSep 12, 2008
  4. Lars HjemliSep 12, 2008
  5. CGit and repository listPetr Baudis, Sep 12, 2008
  6. Lars HjemliSep 12, 2008
  7. Jakub NarebskiSep 12, 2008
  8. Shawn O. PearceSep 12, 2008
  9. Lars HjemliSep 12, 2008
  10. Petr BaudisSep 12, 2008
  11. Shawn O. PearceSep 12, 2008
  12. Petr BaudisSep 12, 2008
  13. Shawn O. PearceSep 12, 2008
  14. Jakub NarebskiSep 12, 2008
  15. Shawn O. PearceSep 12, 2008
  16. Petr BaudisSep 12, 2008
  17. Petr BaudisSep 12, 2008
  18. Lars HjemliSep 12, 2008
  19. Petr BaudisSep 13, 2008
  20. Lars HjemliSep 13, 2008
  21. parsing.c: handle unexpected commit/tag contentLars Hjemli, Sep 14, 2008
  22. Lars HjemliSep 14, 2008
  23. Lars HjemliSep 15, 2008
  24. Kristian HøgsbergSep 14, 2008
  25. Kristian HøgsbergSep 14, 2008
  26. Lars HjemliSep 14, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.