diff --git a/model/build.go b/model/build.go index d72d0218..fa794931 100644 --- a/model/build.go +++ b/model/build.go @@ -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"` diff --git a/model/const.go b/model/const.go index 8c5f48a6..efac6b3b 100644 --- a/model/const.go +++ b/model/const.go @@ -16,3 +16,10 @@ const ( StatusKilled = "killed" StatusError = "error" ) + +const ( + RepoGit = "git" + RepoHg = "hg" + RepoFossil = "fossil" + RepoPerforce = "perforce" +) diff --git a/model/repo.go b/model/repo.go index 923655f5..e44af1a5 100644 --- a/model/repo.go +++ b/model/repo.go @@ -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"` diff --git a/remote/bitbucket/helper.go b/remote/bitbucket/helper.go index 6d44b8bb..65605d8a 100644 --- a/remote/bitbucket/helper.go +++ b/remote/bitbucket/helper.go @@ -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", } diff --git a/remote/github/github.go b/remote/github/github.go index b1e520dc..bf9af9d7 100644 --- a/remote/github/github.go +++ b/remote/github/github.go @@ -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 diff --git a/remote/gogs/helper.go b/remote/gogs/helper.go index f94f41f3..4e06e70c 100644 --- a/remote/gogs/helper.go +++ b/remote/gogs/helper.go @@ -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, diff --git a/store/migration/mysql/2.sql b/store/migration/mysql/2.sql new file mode 100644 index 00000000..0778e006 --- /dev/null +++ b/store/migration/mysql/2.sql @@ -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; diff --git a/store/migration/postgres/2.sql b/store/migration/postgres/2.sql new file mode 100644 index 00000000..0778e006 --- /dev/null +++ b/store/migration/postgres/2.sql @@ -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; diff --git a/store/migration/sqlite3/2.sql b/store/migration/sqlite3/2.sql new file mode 100644 index 00000000..49b4a4ec --- /dev/null +++ b/store/migration/sqlite3/2.sql @@ -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;