Search code examples
githttpgitolite

Access file from gitolite-hosted git repository directly using http client


I'm hosting git repositories with gitolite, and have setup both ssh and http access. I can clone repositories over ssh and http using the git cli. Now, I need to be able to load a file from the git repository over http without using the git client. Specifically, I need to provide the URL https://git.example.com/myproject/locale/en/LC_MESSAGES/default.po to the Transifex translation service so it can poll for changes to the .po messages file.

Is there a simple way to access this file directly using a http client?

An option I tried already: we are using Trac, which has a built-in source browser and provides links to raw files, but each URL is bound to a specific revision hash (example), with no option to link to the "latest" file.

I've considered setting up a post-receive hook to export this file (or the whole repo) to a web-accessible location. However, I'd like to know if it is possible to access files directly in a repository via gitolite, not a workaround like this.


Solution

  • Git models revisions as a graph (ie. connected nodes), not like a big stack of pancakes. There is no "latest" commit in Git. There's the newest commit by date, but that's probably not what you want, and it's not trivial to find. What you probably mean is the tip of the master branch.

    Generally, anything in Git that takes a hash (ie. 51e037aedb09735106f2e51520c3ff4430b663e3) will also take a reference (ie. master). That URL can be tweaked to export the master version of that file.

    https://trac.strangecode.com/pulso/export/master/locale/en/LC_MESSAGES/default.po