https://github.com/krgn/suavegit
Routes for serving git repositories via Suave
https://github.com/krgn/suavegit
Last synced: about 1 year ago
JSON representation
Routes for serving git repositories via Suave
- Host: GitHub
- URL: https://github.com/krgn/suavegit
- Owner: krgn
- License: other
- Created: 2017-06-09T17:39:56.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2017-06-12T09:49:06.000Z (about 9 years ago)
- Last Synced: 2025-06-24T14:49:45.523Z (about 1 year ago)
- Language: F#
- Size: 113 KB
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: COPYING
Awesome Lists containing this project
README
# Suave.Git
Serve git repositories (bare & non-bare) via HTTP from
[Suave](http://suave.io). These routes implement the [Smart HTTP
Protocol](https://github.com/git/git/blob/master/Documentation/technical/http-protocol.txt).
The following operations are known to work:
- `git pull`
- `git push`
- `git clone`
- `git ls-remote`
## Build Status
| Platform | Status |
| -------- | -------------- |
| Windows | [](https://travis-ci.org/SuaveIO/suave) |
| Mono/Linux | [](https://travis-ci.org/SuaveIO/suave) |
## Example
A short example how this API is used:
```fsharp
let dir = "/home/k/projects"
let name = "myproject" // the directory containing .git (non-bare) or a bare repository
let createServer () =
let cts = new CancellationTokenSource()
let config =
{ defaultConfig with
cancellationToken = cts.Token
bindings = [ HttpBinding.create HTTP IPAddress.Loopback 7000us ] }
// This will create the following routes:
//
// - GET "/myproject/info/refs"
// - POST "/myproject/git-upload-pack"
// - POST "/myproject/git-receive-pack"
//
// If the first parmeter is `None`, the path will be in the root.
Path.Combine(dir,name)
|> gitServer (Some name)
|> startWebServerAsync config
|> (fun (_, server) -> Async.Start(server, cts.Token))
// On very slow machines (AppVeyor) it sometimes takes
// around 100ms, so we wait a little to make sure the server is up
Thread.Sleep(150)
{ new IDisposable with
member self.Dispose() =
try
cts.Cancel()
cts.Dispose()
with | _ -> () }
use server = createServer()
```
Once running, you can use the regular commands to add remotes and clone.
```shell
git clone http://localhost:7000/myproject myclone
```
## Repository Configuration
If you intend to serve _non-bare_ repositories, make sure you set this
option on the repository to ensure `git push` will also update your
currently checked out branch.
```shell
git config --local receive.denyCurrentBranch updateInstead
```