From 69eb8659cbbee6735a1ad285fa435e349371ef24 Mon Sep 17 00:00:00 2001 From: Michael Alexander Date: Thu, 7 May 2015 11:11:58 +0800 Subject: [PATCH] Updated README. --- README.md | 38 ++++++++++++++++++++++++++++++++++++-- config.go | 4 ++++ 2 files changed, 40 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 9ce091c..9a0d83f 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,36 @@ -# git-mirror -Mirror Git repositories without effort +# git-mirror - simple Git mirrors + +`git-mirror` is designed to create and serve read-only mirrors of your Git repositories locally or wherever you choose. A recent GitHub outage reinforces the fact that developers shouldn't be relying on a single remote for hosting code. + +A major design goal of `git-mirror` is that it should just work with as little configuration as possible. + +## Get started + +1. Download and extract the latest release from the [releases page](https://github.com/beefsack/git-mirror/releases). +1. Create `config.toml` similar to: +```toml +[[repo]] +Origin = "https://github.com/beefsack/git-mirror.git" +``` +By default it will update the mirror every **15 minutes** and will serve the mirror over HTTP using port **8080**. You can specify as many repos as you want by having multiple `[[repo]]` sections. +1. Run `git-mirror` with the path to the config file: +```bash +$ ./git-mirror config.toml +2015/05/07 11:08:06 starting web server on :8080 +2015/05/07 11:08:06 updating github.com/beefsack/git-mirror.git +2015/05/07 11:08:08 updated github.com/beefsack/git-mirror.git +``` +1. Now you can clone from your mirror on the default port of `8080`: +```bash +$ git clone http://localhost:8080/github.com/beefsack/git-mirror.git +Cloning into 'git-mirror'... +Checking connectivity... done. +``` + +## Advanced configuration + +See [the example config](example-config.toml) for more advanced configurations. + +## Authentication and authorisation + +If you wish to control access to the mirror or specific repositories, consider proxying to `git-mirror` using a web server such as Nginx. diff --git a/config.go b/config.go index 42ab3d4..51b2357 100644 --- a/config.go +++ b/config.go @@ -1,6 +1,7 @@ package main import ( + "path/filepath" "fmt" "io/ioutil" "net/url" @@ -54,6 +55,9 @@ func parseConfig(filename string) (cfg config, repos map[string]repo, err error) if cfg.BasePath == "" { cfg.BasePath = "." } + if cfg.BasePath, err = filepath.Abs(cfg.BasePath); err != nil { + err = fmt.Errorf("unable to get absolute path to base path, %s", err) + } // Fetch repos, injecting default values where needed. if cfg.Repo == nil || len(cfg.Repo) == 0 {