From aa8e0347d0f29cda09739b69ace1dd1930f13b2d Mon Sep 17 00:00:00 2001 From: Brad Rydzewski Date: Tue, 6 Oct 2015 18:31:01 -0700 Subject: [PATCH] github author fallback for old GitHub enterprise --- controller/hook.go | 15 +++++++++++++++ engine/engine.go | 1 + remote/github/github.go | 7 ++++++- static/scripts/build.js | 3 +++ template/amber/docs.amber | 9 +++++---- 5 files changed, 30 insertions(+), 5 deletions(-) diff --git a/controller/hook.go b/controller/hook.go index 5d4e45b66..05b4f02b4 100644 --- a/controller/hook.go +++ b/controller/hook.go @@ -94,6 +94,21 @@ func PostHook(c *gin.Context) { return } + // if there is no email address associated with the pull request, + // we lookup the email address based on the authors github login. + // + // my initial hesitation with this code is that it has the ability + // to expose your email address. At the same time, your email address + // is already exposed in the public .git log. So while some people will + // a small number of people will probably be upset by this, I'm not sure + // it is actually that big of a deal. + if len(build.Email) == 0 { + author, err := model.GetUserLogin(db, build.Author) + if err == nil { + build.Email = author.Email + } + } + // if the remote has a refresh token, the current access token // may be stale. Therefore, we should refresh prior to dispatching // the job. diff --git a/engine/engine.go b/engine/engine.go index 63b85e3d0..133cdfbb4 100644 --- a/engine/engine.go +++ b/engine/engine.go @@ -304,6 +304,7 @@ func (e *engine) runJob(r *Task, updater *updater, client dockerclient.Client) e }, } + log.Infof("preparing container %s", name) client.PullImage(conf.Image, nil) _, err = docker.RunDaemon(client, conf, name) diff --git a/remote/github/github.go b/remote/github/github.go index 97d1d66d0..fd90996aa 100644 --- a/remote/github/github.go +++ b/remote/github/github.go @@ -331,11 +331,16 @@ func (g *Github) push(r *http.Request) (*model.Repo, *model.Build, error) { build.Branch = strings.Replace(build.Ref, "refs/heads/", "", -1) build.Message = hook.Head.Message // build.Timestamp = hook.Head.Timestamp - // build.Email = hook.Head.Author.Email + build.Email = hook.Head.Author.Email build.Avatar = hook.Sender.Avatar build.Author = hook.Sender.Login build.Remote = hook.Repo.CloneURL + if len(build.Author) == 0 { + build.Author = hook.Head.Author.Username + // default gravatar? + } + // we should ignore github pages if build.Ref == "refs/heads/gh-pages" { return nil, nil, nil diff --git a/static/scripts/build.js b/static/scripts/build.js index 08a5c5a1b..98615810d 100644 --- a/static/scripts/build.js +++ b/static/scripts/build.js @@ -74,6 +74,9 @@ function JobViewModel(repo, build, job, status) { if (!data.jobs) { return; } + if (data.number !== build) { + return; + } var before = self.status; self.status = data.jobs[job-1].status; diff --git a/template/amber/docs.amber b/template/amber/docs.amber index 09f3485c9..a8aff4960 100644 --- a/template/amber/docs.amber +++ b/template/amber/docs.amber @@ -17,8 +17,9 @@ block header a.nav-link[href="#"] API Reference block content - div.container-fluid.docs.docs-api + div.container-fluid.docs.docs-usage div.row - #{Site.Nav.HTML} - div.row - #{Page.HTML} \ No newline at end of file + div.content-nav + #{Site.Nav.HTML} + div.content-main + #{Page.HTML} \ No newline at end of file