mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-11-19 08:21:01 +00:00
747 lines
15 KiB
Go
747 lines
15 KiB
Go
package builtin
|
|
|
|
// DO NOT EDIT
|
|
// code generated by go:generate
|
|
|
|
import (
|
|
"database/sql"
|
|
"encoding/json"
|
|
|
|
. "github.com/drone/drone/pkg/types"
|
|
)
|
|
|
|
var _ = json.Marshal
|
|
|
|
// generic database interface, matching both *sql.Db and *sql.Tx
|
|
type buildDB interface {
|
|
Exec(query string, args ...interface{}) (sql.Result, error)
|
|
Query(query string, args ...interface{}) (*sql.Rows, error)
|
|
QueryRow(query string, args ...interface{}) *sql.Row
|
|
}
|
|
|
|
func getBuild(db buildDB, query string, args ...interface{}) (*Build, error) {
|
|
row := db.QueryRow(query, args...)
|
|
return scanBuild(row)
|
|
}
|
|
|
|
func getBuilds(db buildDB, query string, args ...interface{}) ([]*Build, error) {
|
|
rows, err := db.Query(query, args...)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rows.Close()
|
|
return scanBuilds(rows)
|
|
}
|
|
|
|
func createBuild(db buildDB, query string, v *Build) error {
|
|
var v0 int64
|
|
var v1 int
|
|
var v2 string
|
|
var v3 int64
|
|
var v4 int64
|
|
var v5 string
|
|
var v6 string
|
|
var v7 string
|
|
var v8 string
|
|
var v9 string
|
|
var v10 string
|
|
var v11 string
|
|
var v12 string
|
|
var v13 string
|
|
var v14 int
|
|
var v15 string
|
|
var v16 string
|
|
var v17 string
|
|
var v18 string
|
|
var v19 string
|
|
var v20 string
|
|
var v21 string
|
|
var v22 string
|
|
var v23 string
|
|
var v24 string
|
|
var v25 string
|
|
v0 = v.RepoID
|
|
v1 = v.Number
|
|
v2 = v.Status
|
|
v3 = v.Started
|
|
v4 = v.Finished
|
|
if v.Commit != nil {
|
|
v5 = v.Commit.Sha
|
|
v6 = v.Commit.Ref
|
|
v7 = v.Commit.Link
|
|
v8 = v.Commit.Branch
|
|
v9 = v.Commit.Message
|
|
v10 = v.Commit.Timestamp
|
|
v11 = v.Commit.Remote
|
|
if v.Commit.Author != nil {
|
|
v12 = v.Commit.Author.Login
|
|
v13 = v.Commit.Author.Email
|
|
}
|
|
}
|
|
if v.PullRequest != nil {
|
|
v14 = v.PullRequest.Number
|
|
v15 = v.PullRequest.Title
|
|
v16 = v.PullRequest.Link
|
|
if v.PullRequest.Base != nil {
|
|
v17 = v.PullRequest.Base.Sha
|
|
v18 = v.PullRequest.Base.Ref
|
|
v19 = v.PullRequest.Base.Link
|
|
v20 = v.PullRequest.Base.Branch
|
|
v21 = v.PullRequest.Base.Message
|
|
v22 = v.PullRequest.Base.Timestamp
|
|
v23 = v.PullRequest.Base.Remote
|
|
if v.PullRequest.Base.Author != nil {
|
|
v24 = v.PullRequest.Base.Author.Login
|
|
v25 = v.PullRequest.Base.Author.Email
|
|
}
|
|
}
|
|
}
|
|
res, err := db.Exec(query,
|
|
&v0,
|
|
&v1,
|
|
&v2,
|
|
&v3,
|
|
&v4,
|
|
&v5,
|
|
&v6,
|
|
&v7,
|
|
&v8,
|
|
&v9,
|
|
&v10,
|
|
&v11,
|
|
&v12,
|
|
&v13,
|
|
&v14,
|
|
&v15,
|
|
&v16,
|
|
&v17,
|
|
&v18,
|
|
&v19,
|
|
&v20,
|
|
&v21,
|
|
&v22,
|
|
&v23,
|
|
&v24,
|
|
&v25,
|
|
)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
v.ID, err = res.LastInsertId()
|
|
return err
|
|
}
|
|
|
|
func updateBuild(db buildDB, query string, v *Build) error {
|
|
var v0 int64
|
|
var v1 int64
|
|
var v2 int
|
|
var v3 string
|
|
var v4 int64
|
|
var v5 int64
|
|
var v6 string
|
|
var v7 string
|
|
var v8 string
|
|
var v9 string
|
|
var v10 string
|
|
var v11 string
|
|
var v12 string
|
|
var v13 string
|
|
var v14 string
|
|
var v15 int
|
|
var v16 string
|
|
var v17 string
|
|
var v18 string
|
|
var v19 string
|
|
var v20 string
|
|
var v21 string
|
|
var v22 string
|
|
var v23 string
|
|
var v24 string
|
|
var v25 string
|
|
var v26 string
|
|
v0 = v.ID
|
|
v1 = v.RepoID
|
|
v2 = v.Number
|
|
v3 = v.Status
|
|
v4 = v.Started
|
|
v5 = v.Finished
|
|
if v.Commit != nil {
|
|
v6 = v.Commit.Sha
|
|
v7 = v.Commit.Ref
|
|
v8 = v.Commit.Link
|
|
v9 = v.Commit.Branch
|
|
v10 = v.Commit.Message
|
|
v11 = v.Commit.Timestamp
|
|
v12 = v.Commit.Remote
|
|
if v.Commit.Author != nil {
|
|
v13 = v.Commit.Author.Login
|
|
v14 = v.Commit.Author.Email
|
|
}
|
|
}
|
|
if v.PullRequest != nil {
|
|
v15 = v.PullRequest.Number
|
|
v16 = v.PullRequest.Title
|
|
v17 = v.PullRequest.Link
|
|
if v.PullRequest.Base != nil {
|
|
v18 = v.PullRequest.Base.Sha
|
|
v19 = v.PullRequest.Base.Ref
|
|
v20 = v.PullRequest.Base.Link
|
|
v21 = v.PullRequest.Base.Branch
|
|
v22 = v.PullRequest.Base.Message
|
|
v23 = v.PullRequest.Base.Timestamp
|
|
v24 = v.PullRequest.Base.Remote
|
|
if v.PullRequest.Base.Author != nil {
|
|
v25 = v.PullRequest.Base.Author.Login
|
|
v26 = v.PullRequest.Base.Author.Email
|
|
}
|
|
}
|
|
}
|
|
|
|
_, err := db.Exec(query,
|
|
&v1,
|
|
&v2,
|
|
&v3,
|
|
&v4,
|
|
&v5,
|
|
&v6,
|
|
&v7,
|
|
&v8,
|
|
&v9,
|
|
&v10,
|
|
&v11,
|
|
&v12,
|
|
&v13,
|
|
&v14,
|
|
&v15,
|
|
&v16,
|
|
&v17,
|
|
&v18,
|
|
&v19,
|
|
&v20,
|
|
&v21,
|
|
&v22,
|
|
&v23,
|
|
&v24,
|
|
&v25,
|
|
&v26,
|
|
&v0,
|
|
)
|
|
return err
|
|
}
|
|
|
|
func scanBuild(row *sql.Row) (*Build, error) {
|
|
var v0 int64
|
|
var v1 int64
|
|
var v2 int
|
|
var v3 string
|
|
var v4 int64
|
|
var v5 int64
|
|
var v6 string
|
|
var v7 string
|
|
var v8 string
|
|
var v9 string
|
|
var v10 string
|
|
var v11 string
|
|
var v12 string
|
|
var v13 string
|
|
var v14 string
|
|
var v15 int
|
|
var v16 string
|
|
var v17 string
|
|
var v18 string
|
|
var v19 string
|
|
var v20 string
|
|
var v21 string
|
|
var v22 string
|
|
var v23 string
|
|
var v24 string
|
|
var v25 string
|
|
var v26 string
|
|
|
|
err := row.Scan(
|
|
&v0,
|
|
&v1,
|
|
&v2,
|
|
&v3,
|
|
&v4,
|
|
&v5,
|
|
&v6,
|
|
&v7,
|
|
&v8,
|
|
&v9,
|
|
&v10,
|
|
&v11,
|
|
&v12,
|
|
&v13,
|
|
&v14,
|
|
&v15,
|
|
&v16,
|
|
&v17,
|
|
&v18,
|
|
&v19,
|
|
&v20,
|
|
&v21,
|
|
&v22,
|
|
&v23,
|
|
&v24,
|
|
&v25,
|
|
&v26,
|
|
)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
v := &Build{}
|
|
v.ID = v0
|
|
v.RepoID = v1
|
|
v.Number = v2
|
|
v.Status = v3
|
|
v.Started = v4
|
|
v.Finished = v5
|
|
v.Commit = &Commit{}
|
|
v.Commit.Sha = v6
|
|
v.Commit.Ref = v7
|
|
v.Commit.Link = v8
|
|
v.Commit.Branch = v9
|
|
v.Commit.Message = v10
|
|
v.Commit.Timestamp = v11
|
|
v.Commit.Remote = v12
|
|
v.Commit.Author = &Author{}
|
|
v.Commit.Author.Login = v13
|
|
v.Commit.Author.Email = v14
|
|
v.PullRequest = &PullRequest{}
|
|
v.PullRequest.Number = v15
|
|
v.PullRequest.Title = v16
|
|
v.PullRequest.Link = v17
|
|
v.PullRequest.Base = &Commit{}
|
|
v.PullRequest.Base.Sha = v18
|
|
v.PullRequest.Base.Ref = v19
|
|
v.PullRequest.Base.Link = v20
|
|
v.PullRequest.Base.Branch = v21
|
|
v.PullRequest.Base.Message = v22
|
|
v.PullRequest.Base.Timestamp = v23
|
|
v.PullRequest.Base.Remote = v24
|
|
v.PullRequest.Base.Author = &Author{}
|
|
v.PullRequest.Base.Author.Login = v25
|
|
v.PullRequest.Base.Author.Email = v26
|
|
|
|
return v, nil
|
|
}
|
|
|
|
func scanBuilds(rows *sql.Rows) ([]*Build, error) {
|
|
var err error
|
|
var vv []*Build
|
|
for rows.Next() {
|
|
var v0 int64
|
|
var v1 int64
|
|
var v2 int
|
|
var v3 string
|
|
var v4 int64
|
|
var v5 int64
|
|
var v6 string
|
|
var v7 string
|
|
var v8 string
|
|
var v9 string
|
|
var v10 string
|
|
var v11 string
|
|
var v12 string
|
|
var v13 string
|
|
var v14 string
|
|
var v15 int
|
|
var v16 string
|
|
var v17 string
|
|
var v18 string
|
|
var v19 string
|
|
var v20 string
|
|
var v21 string
|
|
var v22 string
|
|
var v23 string
|
|
var v24 string
|
|
var v25 string
|
|
var v26 string
|
|
err = rows.Scan(
|
|
&v0,
|
|
&v1,
|
|
&v2,
|
|
&v3,
|
|
&v4,
|
|
&v5,
|
|
&v6,
|
|
&v7,
|
|
&v8,
|
|
&v9,
|
|
&v10,
|
|
&v11,
|
|
&v12,
|
|
&v13,
|
|
&v14,
|
|
&v15,
|
|
&v16,
|
|
&v17,
|
|
&v18,
|
|
&v19,
|
|
&v20,
|
|
&v21,
|
|
&v22,
|
|
&v23,
|
|
&v24,
|
|
&v25,
|
|
&v26,
|
|
)
|
|
if err != nil {
|
|
return vv, err
|
|
}
|
|
|
|
v := &Build{}
|
|
v.ID = v0
|
|
v.RepoID = v1
|
|
v.Number = v2
|
|
v.Status = v3
|
|
v.Started = v4
|
|
v.Finished = v5
|
|
v.Commit = &Commit{}
|
|
v.Commit.Sha = v6
|
|
v.Commit.Ref = v7
|
|
v.Commit.Link = v8
|
|
v.Commit.Branch = v9
|
|
v.Commit.Message = v10
|
|
v.Commit.Timestamp = v11
|
|
v.Commit.Remote = v12
|
|
v.Commit.Author = &Author{}
|
|
v.Commit.Author.Login = v13
|
|
v.Commit.Author.Email = v14
|
|
v.PullRequest = &PullRequest{}
|
|
v.PullRequest.Number = v15
|
|
v.PullRequest.Title = v16
|
|
v.PullRequest.Link = v17
|
|
v.PullRequest.Base = &Commit{}
|
|
v.PullRequest.Base.Sha = v18
|
|
v.PullRequest.Base.Ref = v19
|
|
v.PullRequest.Base.Link = v20
|
|
v.PullRequest.Base.Branch = v21
|
|
v.PullRequest.Base.Message = v22
|
|
v.PullRequest.Base.Timestamp = v23
|
|
v.PullRequest.Base.Remote = v24
|
|
v.PullRequest.Base.Author = &Author{}
|
|
v.PullRequest.Base.Author.Login = v25
|
|
v.PullRequest.Base.Author.Email = v26
|
|
vv = append(vv, v)
|
|
}
|
|
return vv, rows.Err()
|
|
}
|
|
|
|
const stmtBuildSelectList = `
|
|
SELECT
|
|
build_id
|
|
,build_repo_id
|
|
,build_number
|
|
,build_status
|
|
,build_started
|
|
,build_finished
|
|
,build_commit_sha
|
|
,build_commit_ref
|
|
,build_commit_link
|
|
,build_commit_branch
|
|
,build_commit_message
|
|
,build_commit_timestamp
|
|
,build_commit_remote
|
|
,build_commit_author_login
|
|
,build_commit_author_email
|
|
,build_pull_request_number
|
|
,build_pull_request_title
|
|
,build_pull_request_link
|
|
,build_pull_request_base_sha
|
|
,build_pull_request_base_ref
|
|
,build_pull_request_base_link
|
|
,build_pull_request_base_branch
|
|
,build_pull_request_base_message
|
|
,build_pull_request_base_timestamp
|
|
,build_pull_request_base_remote
|
|
,build_pull_request_base_author_login
|
|
,build_pull_request_base_author_email
|
|
FROM builds
|
|
`
|
|
|
|
const stmtBuildSelectRange = `
|
|
SELECT
|
|
build_id
|
|
,build_repo_id
|
|
,build_number
|
|
,build_status
|
|
,build_started
|
|
,build_finished
|
|
,build_commit_sha
|
|
,build_commit_ref
|
|
,build_commit_link
|
|
,build_commit_branch
|
|
,build_commit_message
|
|
,build_commit_timestamp
|
|
,build_commit_remote
|
|
,build_commit_author_login
|
|
,build_commit_author_email
|
|
,build_pull_request_number
|
|
,build_pull_request_title
|
|
,build_pull_request_link
|
|
,build_pull_request_base_sha
|
|
,build_pull_request_base_ref
|
|
,build_pull_request_base_link
|
|
,build_pull_request_base_branch
|
|
,build_pull_request_base_message
|
|
,build_pull_request_base_timestamp
|
|
,build_pull_request_base_remote
|
|
,build_pull_request_base_author_login
|
|
,build_pull_request_base_author_email
|
|
FROM builds
|
|
LIMIT ? OFFSET ?
|
|
`
|
|
|
|
const stmtBuildSelect = `
|
|
SELECT
|
|
build_id
|
|
,build_repo_id
|
|
,build_number
|
|
,build_status
|
|
,build_started
|
|
,build_finished
|
|
,build_commit_sha
|
|
,build_commit_ref
|
|
,build_commit_link
|
|
,build_commit_branch
|
|
,build_commit_message
|
|
,build_commit_timestamp
|
|
,build_commit_remote
|
|
,build_commit_author_login
|
|
,build_commit_author_email
|
|
,build_pull_request_number
|
|
,build_pull_request_title
|
|
,build_pull_request_link
|
|
,build_pull_request_base_sha
|
|
,build_pull_request_base_ref
|
|
,build_pull_request_base_link
|
|
,build_pull_request_base_branch
|
|
,build_pull_request_base_message
|
|
,build_pull_request_base_timestamp
|
|
,build_pull_request_base_remote
|
|
,build_pull_request_base_author_login
|
|
,build_pull_request_base_author_email
|
|
FROM builds
|
|
WHERE build_id = ?
|
|
`
|
|
|
|
const stmtBuildSelectBuildRepoId = `
|
|
SELECT
|
|
build_id
|
|
,build_repo_id
|
|
,build_number
|
|
,build_status
|
|
,build_started
|
|
,build_finished
|
|
,build_commit_sha
|
|
,build_commit_ref
|
|
,build_commit_link
|
|
,build_commit_branch
|
|
,build_commit_message
|
|
,build_commit_timestamp
|
|
,build_commit_remote
|
|
,build_commit_author_login
|
|
,build_commit_author_email
|
|
,build_pull_request_number
|
|
,build_pull_request_title
|
|
,build_pull_request_link
|
|
,build_pull_request_base_sha
|
|
,build_pull_request_base_ref
|
|
,build_pull_request_base_link
|
|
,build_pull_request_base_branch
|
|
,build_pull_request_base_message
|
|
,build_pull_request_base_timestamp
|
|
,build_pull_request_base_remote
|
|
,build_pull_request_base_author_login
|
|
,build_pull_request_base_author_email
|
|
FROM builds
|
|
WHERE build_repo_id = ?
|
|
`
|
|
|
|
const stmtBuildSelectBuildNumber = `
|
|
SELECT
|
|
build_id
|
|
,build_repo_id
|
|
,build_number
|
|
,build_status
|
|
,build_started
|
|
,build_finished
|
|
,build_commit_sha
|
|
,build_commit_ref
|
|
,build_commit_link
|
|
,build_commit_branch
|
|
,build_commit_message
|
|
,build_commit_timestamp
|
|
,build_commit_remote
|
|
,build_commit_author_login
|
|
,build_commit_author_email
|
|
,build_pull_request_number
|
|
,build_pull_request_title
|
|
,build_pull_request_link
|
|
,build_pull_request_base_sha
|
|
,build_pull_request_base_ref
|
|
,build_pull_request_base_link
|
|
,build_pull_request_base_branch
|
|
,build_pull_request_base_message
|
|
,build_pull_request_base_timestamp
|
|
,build_pull_request_base_remote
|
|
,build_pull_request_base_author_login
|
|
,build_pull_request_base_author_email
|
|
FROM builds
|
|
WHERE build_repo_id = ?
|
|
AND build_number = ?
|
|
`
|
|
|
|
const stmtBuildSelectCommitBranch = `
|
|
SELECT
|
|
build_id
|
|
,build_repo_id
|
|
,build_number
|
|
,build_status
|
|
,build_started
|
|
,build_finished
|
|
,build_commit_sha
|
|
,build_commit_ref
|
|
,build_commit_link
|
|
,build_commit_branch
|
|
,build_commit_message
|
|
,build_commit_timestamp
|
|
,build_commit_remote
|
|
,build_commit_author_login
|
|
,build_commit_author_email
|
|
,build_pull_request_number
|
|
,build_pull_request_title
|
|
,build_pull_request_link
|
|
,build_pull_request_base_sha
|
|
,build_pull_request_base_ref
|
|
,build_pull_request_base_link
|
|
,build_pull_request_base_branch
|
|
,build_pull_request_base_message
|
|
,build_pull_request_base_timestamp
|
|
,build_pull_request_base_remote
|
|
,build_pull_request_base_author_login
|
|
,build_pull_request_base_author_email
|
|
FROM builds
|
|
WHERE build_branch = ?
|
|
AND build_branch = ?
|
|
`
|
|
|
|
const stmtBuildSelectCount = `
|
|
SELECT count(1)
|
|
FROM builds
|
|
`
|
|
|
|
const stmtBuildInsert = `
|
|
INSERT INTO builds (
|
|
build_repo_id
|
|
,build_number
|
|
,build_status
|
|
,build_started
|
|
,build_finished
|
|
,build_commit_sha
|
|
,build_commit_ref
|
|
,build_commit_link
|
|
,build_commit_branch
|
|
,build_commit_message
|
|
,build_commit_timestamp
|
|
,build_commit_remote
|
|
,build_commit_author_login
|
|
,build_commit_author_email
|
|
,build_pull_request_number
|
|
,build_pull_request_title
|
|
,build_pull_request_link
|
|
,build_pull_request_base_sha
|
|
,build_pull_request_base_ref
|
|
,build_pull_request_base_link
|
|
,build_pull_request_base_branch
|
|
,build_pull_request_base_message
|
|
,build_pull_request_base_timestamp
|
|
,build_pull_request_base_remote
|
|
,build_pull_request_base_author_login
|
|
,build_pull_request_base_author_email
|
|
) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?);
|
|
`
|
|
|
|
const stmtBuildUpdate = `
|
|
UPDATE builds SET
|
|
build_repo_id = ?
|
|
,build_number = ?
|
|
,build_status = ?
|
|
,build_started = ?
|
|
,build_finished = ?
|
|
,build_commit_sha = ?
|
|
,build_commit_ref = ?
|
|
,build_commit_link = ?
|
|
,build_commit_branch = ?
|
|
,build_commit_message = ?
|
|
,build_commit_timestamp = ?
|
|
,build_commit_remote = ?
|
|
,build_commit_author_login = ?
|
|
,build_commit_author_email = ?
|
|
,build_pull_request_number = ?
|
|
,build_pull_request_title = ?
|
|
,build_pull_request_link = ?
|
|
,build_pull_request_base_sha = ?
|
|
,build_pull_request_base_ref = ?
|
|
,build_pull_request_base_link = ?
|
|
,build_pull_request_base_branch = ?
|
|
,build_pull_request_base_message = ?
|
|
,build_pull_request_base_timestamp = ?
|
|
,build_pull_request_base_remote = ?
|
|
,build_pull_request_base_author_login = ?
|
|
,build_pull_request_base_author_email = ?
|
|
WHERE build_id = ?
|
|
`
|
|
|
|
const stmtBuildDelete = `
|
|
DELETE FROM builds
|
|
WHERE build_id = ?
|
|
`
|
|
|
|
const stmtBuildTable = `
|
|
CREATE TABLE IF NOT EXISTS builds (
|
|
build_id INTEGER PRIMARY KEY AUTOINCREMENT
|
|
,build_repo_id INTEGER
|
|
,build_number INTEGER
|
|
,build_status VARCHAR
|
|
,build_started INTEGER
|
|
,build_finished INTEGER
|
|
,build_commit_sha VARCHAR
|
|
,build_commit_ref VARCHAR
|
|
,build_commit_link VARCHAR
|
|
,build_commit_branch VARCHAR
|
|
,build_commit_message VARCHAR
|
|
,build_commit_timestamp VARCHAR
|
|
,build_commit_remote VARCHAR
|
|
,build_commit_author_login VARCHAR
|
|
,build_commit_author_email VARCHAR
|
|
,build_pull_request_number INTEGER
|
|
,build_pull_request_title VARCHAR
|
|
,build_pull_request_link VARCHAR
|
|
,build_pull_request_base_sha VARCHAR
|
|
,build_pull_request_base_ref VARCHAR
|
|
,build_pull_request_base_link VARCHAR
|
|
,build_pull_request_base_branch VARCHAR
|
|
,build_pull_request_base_message VARCHAR
|
|
,build_pull_request_base_timestamp VARCHAR
|
|
,build_pull_request_base_remote VARCHAR
|
|
,build_pull_request_base_author_login VARCHAR
|
|
,build_pull_request_base_author_email VARCHAR
|
|
);
|
|
`
|
|
|
|
const stmtBuildBuildRepoIdIndex = `
|
|
CREATE INDEX IF NOT EXISTS ix_build_repo_id ON builds (build_repo_id);
|
|
`
|
|
|
|
const stmtBuildBuildNumberIndex = `
|
|
CREATE UNIQUE INDEX IF NOT EXISTS ux_build_number ON builds (build_repo_id,build_number);
|
|
`
|
|
|
|
const stmtBuildCommitBranchIndex = `
|
|
CREATE INDEX IF NOT EXISTS ix_commit_branch ON builds (build_branch,build_branch);
|
|
`
|