From 0d2ed0784f2c6280c7073a6b30c64c2b2f7ebbc7 Mon Sep 17 00:00:00 2001 From: Abiola Ibrahim Date: Fri, 1 May 2015 17:18:58 +0100 Subject: [PATCH] Modified repository path to be relative to root path. --- middleware/git/doc.go | 7 ++++--- middleware/git/git.go | 5 +++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/middleware/git/doc.go b/middleware/git/doc.go index ae416c4db..f28a04a1d 100644 --- a/middleware/git/doc.go +++ b/middleware/git/doc.go @@ -13,8 +13,9 @@ // and https(e.g. https://github.com/user/project) are supported. // Can be specified in either config block or top level // -// path - directory to pull into +// path - directory to pull into, relative to site root // optional. Defaults to site root. +// If set, must be a subdirectory to site root to be valid. // // branch - git branch or tag // optional. Defaults to master @@ -30,10 +31,10 @@ // public repo pulled into site root // git github.com/user/myproject // -// public repo pulled into mysite +// public repo pulled into /mysite // git https://github.com/user/myproject mysite // -// private repo pulled into mysite with tag v1.0 and interval of 1 day +// private repo pulled into /mysite with tag v1.0 and interval of 1 day // git { // repo git@github.com:user/myproject // branch v1.0 diff --git a/middleware/git/git.go b/middleware/git/git.go index 2823d6e0f..3a5fda59c 100644 --- a/middleware/git/git.go +++ b/middleware/git/git.go @@ -5,6 +5,7 @@ import ( "github.com/mholt/caddy/middleware" "net/http" "net/url" + "path/filepath" "runtime" "strconv" "strings" @@ -45,7 +46,7 @@ func parse(c middleware.Controller) (*Repo, error) { switch len(args) { case 2: - repo.Path = args[1] + repo.Path = filepath.Join(c.Root(), args[1]) fallthrough case 1: repo.Url = args[0] @@ -62,7 +63,7 @@ func parse(c middleware.Controller) (*Repo, error) { if !c.NextArg() { return nil, c.ArgErr() } - repo.Path = c.Val() + repo.Path = filepath.Join(c.Root(), c.Val()) case "branch": if !c.NextArg() { return nil, c.ArgErr()