updates the github deployment hook parser to work with older payloads

This commit is contained in:
Brad Rydzewski 2015-10-27 14:53:55 -07:00
parent 284c99175f
commit fc02d38b4a
4 changed files with 26 additions and 1 deletions

View file

@ -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 {

View file

@ -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 {

View file

@ -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"`
}

View file

@ -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; }