From fc02d38b4a5674660a0c38b0294921bcc2e16678 Mon Sep 17 00:00:00 2001 From: Brad Rydzewski Date: Tue, 27 Oct 2015 14:53:55 -0700 Subject: [PATCH] updates the github deployment hook parser to work with older payloads --- remote/bitbucket/helper.go | 4 ++++ remote/github/github.go | 10 ++++++++++ remote/github/types.go | 11 +++++++++++ static/styles_gen/style.css | 2 +- 4 files changed, 26 insertions(+), 1 deletion(-) diff --git a/remote/bitbucket/helper.go b/remote/bitbucket/helper.go index 65605d8a4..cb9a9062f 100644 --- a/remote/bitbucket/helper.go +++ b/remote/bitbucket/helper.go @@ -21,6 +21,10 @@ func convertRepo(from *Repo) *model.Repo { Branch: "master", } + if repo.Kind == model.RepoHg { + repo.Branch = "default" + } + // in some cases, the owner of the repository is not // provided, however, we do have the full name. if len(repo.Owner) == 0 { diff --git a/remote/github/github.go b/remote/github/github.go index 303f9db50..d1e23fe5b 100644 --- a/remote/github/github.go +++ b/remote/github/github.go @@ -417,6 +417,16 @@ func (g *Github) deployment(r *http.Request) (*model.Repo, *model.Build, error) return nil, nil, err } + // for older versions of GitHub. Remove. + if hook.Deployment.ID == 0 { + hook.Deployment.ID = hook.ID + hook.Deployment.Sha = hook.Sha + hook.Deployment.Ref = hook.Ref + hook.Deployment.Task = hook.Name + hook.Deployment.Env = hook.Env + hook.Deployment.Desc = hook.Desc + } + repo := &model.Repo{} repo.Owner = hook.Repo.Owner.Login if len(repo.Owner) == 0 { diff --git a/remote/github/types.go b/remote/github/types.go index 2f0bac4fc..7671d7023 100644 --- a/remote/github/types.go +++ b/remote/github/types.go @@ -77,4 +77,15 @@ type deployHook struct { CloneURL string `json:"clone_url"` DefaultBranch string `json:"default_branch"` } `json:"repository"` + + // these are legacy fields that have been moded + // to the deployment section. They are here for + // older versions of GitHub and will be removed + + ID int64 `json:"id"` + Sha string `json:"sha"` + Ref string `json:"ref"` + Name string `json:"name"` + Env string `json:"environment"` + Desc string `json:"description"` } diff --git a/static/styles_gen/style.css b/static/styles_gen/style.css index a96f11fd1..483f766ef 100644 --- a/static/styles_gen/style.css +++ b/static/styles_gen/style.css @@ -339,7 +339,7 @@ body.login.login-form > div input[type="submit"] { position: relative; width: 10 .toc [data-method="PATCH"]:before { color: #E67E22; border-color: #E67E22; } -.toc [data-method="DELETE"]:before { color: E74C3C; border-color: #E74C3C; } +.toc [data-method="DELETE"]:before { color: #E74C3C; border-color: #E74C3C; } .operation [data-method]:before { content: attr(data-method); padding: 0px 10px; line-height: 18px; min-width: 70px; font-size: 11px; text-transform: uppercase; display: inline-block; text-align: center; color: #FFF; border-radius: 2px; margin-right: 20px; background: #FFF; border: 1px solid #FFF; line-height: 20px; vertical-align: top; }