Merge pull request #605 from bradrydzewski/master

slightly altered the URL token format
This commit is contained in:
Brad Rydzewski 2014-10-22 00:45:38 -07:00
commit 19384c5e3e
4 changed files with 11 additions and 3 deletions

View file

@ -135,7 +135,7 @@ func (r *Gitlab) Activate(user *model.User, repo *model.Repo, link string) error
// append the repo owner / name to the hook url since gitlab
// doesn't send this detail in the post-commit hook
link += "&owner=" + repo.Owner + "&name=" + repo.Name
link += "?owner=" + repo.Owner + "&name=" + repo.Name
// add the hook
return client.AddProjectHook(path, link, true, false, true)

View file

@ -25,7 +25,7 @@ import (
func PostHook(c web.C, w http.ResponseWriter, r *http.Request) {
var ctx = context.FromC(c)
var host = c.URLParams["host"]
var token = r.FormValue("token")
var token = c.URLParams["token"]
var remote = remote.Lookup(host)
if remote == nil {
w.WriteHeader(http.StatusNotFound)

View file

@ -99,7 +99,7 @@ func PostRepo(c web.C, w http.ResponseWriter, r *http.Request) {
// setup the post-commit hook with the remote system and
// if necessary, register the public key
var hook = fmt.Sprintf("%s/api/hook/%s?token=%s", httputil.GetURL(r), repo.Remote, repo.Token)
var hook = fmt.Sprintf("%s/api/hook/%s/%s", httputil.GetURL(r), repo.Remote, repo.Token)
if err := remote.Activate(user, repo, hook); err != nil {
w.WriteHeader(http.StatusInternalServerError)
return

View file

@ -15,9 +15,17 @@ func New() *web.Mux {
mux.Post("/api/auth/:host", handler.GetLogin)
mux.Get("/api/badge/:host/:owner/:name/status.svg", handler.GetBadge)
mux.Get("/api/badge/:host/:owner/:name/cc.xml", handler.GetCC)
mux.Get("/api/hook/:host/:token", handler.PostHook)
mux.Put("/api/hook/:host/:token", handler.PostHook)
mux.Post("/api/hook/:host/:token", handler.PostHook)
// these routes are here for backward compatibility
// to help people troubleshoot why their upgrade isn't
// working correctly. remove at some point
mux.Get("/api/hook/:host", handler.PostHook)
mux.Put("/api/hook/:host", handler.PostHook)
mux.Post("/api/hook/:host", handler.PostHook)
////
streams := web.New()
streams.Get("/api/stream/stdout/:id", handler.WsConsole)