added scm and deploy fields. plan to support hg, github deploys

This commit is contained in:
Brad Rydzewski 2015-10-27 13:03:37 -07:00
parent bd59e67e3d
commit 25fa705511
9 changed files with 48 additions and 0 deletions

View file

@ -10,6 +10,7 @@ type Build struct {
Created int64 `json:"created_at" meddler:"build_created"`
Started int64 `json:"started_at" meddler:"build_started"`
Finished int64 `json:"finished_at" meddler:"build_finished"`
Deploy string `json:"deploy_to" meddler:"build_deploy"`
Commit string `json:"commit" meddler:"build_commit"`
Branch string `json:"branch" meddler:"build_branch"`
Ref string `json:"ref" meddler:"build_ref"`

View file

@ -16,3 +16,10 @@ const (
StatusKilled = "killed"
StatusError = "error"
)
const (
RepoGit = "git"
RepoHg = "hg"
RepoFossil = "fossil"
RepoPerforce = "perforce"
)

View file

@ -15,6 +15,7 @@ type Repo struct {
FullName string `json:"full_name" meddler:"repo_full_name"`
Avatar string `json:"avatar_url" meddler:"repo_avatar"`
Link string `json:"link_url" meddler:"repo_link"`
Kind string `json:"scm" meddler:"repo_scm"`
Clone string `json:"clone_url" meddler:"repo_clone"`
Branch string `json:"default_branch" meddler:"repo_branch"`
Timeout int64 `json:"timeout" meddler:"repo_timeout"`

View file

@ -17,6 +17,7 @@ func convertRepo(from *Repo) *model.Repo {
Link: from.Links.Html.Href,
IsPrivate: from.IsPrivate,
Avatar: from.Owner.Links.Avatar.Href,
Kind: from.Scm,
Branch: "master",
}

View file

@ -147,6 +147,7 @@ func (g *Github) Repo(u *model.User, owner, name string) (*model.Repo, error) {
repo.Clone = *repo_.CloneURL
repo.Branch = "master"
repo.Avatar = *repo_.Owner.AvatarURL
repo.Kind = model.RepoGit
if repo_.DefaultBranch != nil {
repo.Branch = *repo_.DefaultBranch
@ -324,6 +325,7 @@ func (g *Github) push(r *http.Request) (*model.Repo, *model.Build, error) {
repo.IsPrivate = hook.Repo.Private
repo.Clone = hook.Repo.CloneURL
repo.Branch = hook.Repo.DefaultBranch
repo.Kind = model.RepoGit
build := &model.Build{}
build.Event = model.EventPush
@ -384,6 +386,7 @@ func (g *Github) pullRequest(r *http.Request) (*model.Repo, *model.Build, error)
repo.Link = *hook.Repo.HTMLURL
repo.IsPrivate = *hook.Repo.Private
repo.Clone = *hook.Repo.CloneURL
repo.Kind = model.RepoGit
repo.Branch = "master"
if hook.Repo.DefaultBranch != nil {
repo.Branch = *hook.Repo.DefaultBranch
@ -425,6 +428,7 @@ func (g *Github) deployment(r *http.Request) (*model.Repo, *model.Build, error)
repo.IsPrivate = hook.Repo.Private
repo.Clone = hook.Repo.CloneURL
repo.Branch = hook.Repo.DefaultBranch
repo.Kind = model.RepoGit
// ref can be
// branch, tag, or sha

View file

@ -37,6 +37,7 @@ func toRepo(from *gogs.Repository) *model.Repo {
from.Owner.AvatarUrl,
)
return &model.Repo{
Kind: model.RepoGit,
Name: name,
Owner: from.Owner.UserName,
FullName: from.FullName,

View file

@ -0,0 +1,11 @@
-- +migrate Up
ALTER TABLE repos ADD COLUMN repo_scm VARCHAR(25);
ALTER TABLE builds ADD COLUMN build_deploy VARCHAR(500);
UPDATE repos SET repo_scm = 'git';
-- +migrate Down
ALTER TABLE repos DROP COLUMN repo_scm;
ALTER TABLE builds DROP COLUMN build_deploy;

View file

@ -0,0 +1,11 @@
-- +migrate Up
ALTER TABLE repos ADD COLUMN repo_scm VARCHAR(25);
ALTER TABLE builds ADD COLUMN build_deploy VARCHAR(500);
UPDATE repos SET repo_scm = 'git';
-- +migrate Down
ALTER TABLE repos DROP COLUMN repo_scm;
ALTER TABLE builds DROP COLUMN build_deploy;

View file

@ -0,0 +1,11 @@
-- +migrate Up
ALTER TABLE repos ADD COLUMN repo_scm TEXT;
ALTER TABLE builds ADD COLUMN build_deploy TEXT;
UPDATE repos SET repo_scm = 'git';
-- +migrate Down
ALTER TABLE repos DROP COLUMN repo_scm;
ALTER TABLE builds DROP COLUMN build_deploy;