An http/connect/stack layer to serve the contents of a 'git' repository over HTTP.
This module offers the ability to serve the contents of a 'git' repo over HTTP, with the option to retreive files from specific commits or tags if desired.
If a working directory exists in the repo, then it's contents will be served if no commit is explicitly specified. If it's a bare repo, then the HEAD commit will be served when no commit is specified.
The only required argument is the path to a git repository that you would like to serve.
var http = require('http'); var gitProvider = require('gitProvider'); var server = http.createServer( gitProvider(process.env.HOME + '/someRepo') );
The barebones example above will create a git provider with the default options and will serve the git repo located a "~/someRepo".
So let's assume that "someRepo" simply contains an
index.html file and a few commits
that modify that file. With the example server above running, we can send simple HTTP
requests to retreive the contents of that file, in a few different ways:
The above command gets
index.html from the current HEAD commit of the repo (if it's
a bare repo), or the file from the git working directory if it's a regular repo.
Now the above command gets
index.html from the specified commit: f62de2f138dd241256d1cd0be10d52f671e68d2f.
git tags can also be specified in place of specific commit revisions. Here v1.1.2 would be
a git tag to reference
gitProvider(repoPath [, options]) -> handler
gitProvider function only requires a path to a git repo. Optionally, you may
pass an options object that recognizes the following properties:
mountPoint: The request URL in which this handler will kick in. If the request URL does not begin with the value set here, the the request will be
/, i.e. will always take effect).
indexFile: The name of the index file to serve if a directory name is specified. (Default