mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-11-24 08:02:18 +02:00
persist self url in repo field
This commit is contained in:
parent
ed0719c624
commit
1ef6dc0bc6
@ -9,6 +9,7 @@ type Repo struct {
|
||||
Token string `meddler:"repo_token" json:"-"`
|
||||
Language string `meddler:"repo_lang" json:"language"`
|
||||
Private bool `meddler:"repo_private" json:"private"`
|
||||
Self string `meddler:"repo_self" json:"self_url"`
|
||||
Link string `meddler:"repo_link" json:"link_url"`
|
||||
Clone string `meddler:"repo_clone" json:"clone_url"`
|
||||
Branch string `meddler:"repo_branch" json:"default_branch"`
|
||||
|
@ -64,6 +64,7 @@ CREATE TABLE IF NOT EXISTS repos (
|
||||
,repo_branch VARCHAR(255)
|
||||
,repo_private BOOLEAN
|
||||
,repo_trusted BOOLEAN
|
||||
,repo_self VARCHAR(1024)
|
||||
,repo_link VARCHAR(1024)
|
||||
,repo_clone VARCHAR(1024)
|
||||
,repo_push BOOLEAN
|
||||
|
@ -212,12 +212,12 @@ func (g *GitHub) Deactivate(u *common.User, r *common.Repo, link string) error {
|
||||
return DeleteHook(client, r.Owner, r.Name, link)
|
||||
}
|
||||
|
||||
func (g *GitHub) Status(u *common.User, r *common.Repo, c *common.Commit, link string) error {
|
||||
func (g *GitHub) Status(u *common.User, r *common.Repo, c *common.Commit) error {
|
||||
client := NewClient(g.API, u.Token, g.SkipVerify)
|
||||
if len(c.PullRequest) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
link := fmt.Sprintf("%s/%v", r.Self, c.Sequence)
|
||||
status := getStatus(c.State)
|
||||
desc := getDesc(c.State)
|
||||
data := github.RepoStatus{
|
||||
|
@ -27,7 +27,7 @@ type Remote interface {
|
||||
|
||||
// Status sends the commit status to the remote system.
|
||||
// An example would be the GitHub pull request status.
|
||||
Status(u *common.User, r *common.Repo, c *common.Commit, link string) error
|
||||
Status(u *common.User, r *common.Repo, c *common.Commit) error
|
||||
|
||||
// Netrc returns a .netrc file that can be used to clone
|
||||
// private repositories from a remote system.
|
||||
|
@ -35,7 +35,10 @@ func (u *updater) SetCommit(user *common.User, r *common.Repo, c *common.Commit)
|
||||
return err
|
||||
}
|
||||
|
||||
// TODO invoke remote.Status to set the build status
|
||||
err = u.remote.Status(user, r, c)
|
||||
if err != nil {
|
||||
// log err
|
||||
}
|
||||
|
||||
msg, err := json.Marshal(c)
|
||||
if err != nil {
|
||||
|
@ -1,12 +1,10 @@
|
||||
package server
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
log "github.com/Sirupsen/logrus"
|
||||
"github.com/drone/drone/common"
|
||||
"github.com/drone/drone/common/httputil"
|
||||
"github.com/drone/drone/parser"
|
||||
"github.com/drone/drone/parser/inject"
|
||||
"github.com/drone/drone/parser/matrix"
|
||||
@ -147,13 +145,7 @@ func PostHook(c *gin.Context) {
|
||||
|
||||
c.JSON(200, commit)
|
||||
|
||||
link := fmt.Sprintf(
|
||||
"%s/%s/%d",
|
||||
httputil.GetURL(c.Request),
|
||||
repo.FullName,
|
||||
commit.Sequence,
|
||||
)
|
||||
err = remote.Status(user, repo, commit, link)
|
||||
err = remote.Status(user, repo, commit)
|
||||
if err != nil {
|
||||
log.Errorf("error setting commit status for %s/%d", repo.FullName, commit.Sequence)
|
||||
}
|
||||
|
@ -210,6 +210,11 @@ func PostRepo(c *gin.Context) {
|
||||
r.UserID = user.ID
|
||||
r.PostCommit = true
|
||||
r.PullRequest = true
|
||||
r.Self = fmt.Sprintf(
|
||||
"%s/%s",
|
||||
httputil.GetURL(c.Request),
|
||||
r.FullName,
|
||||
)
|
||||
|
||||
// generate an RSA key and add to the repo
|
||||
key, err := sshutil.GeneratePrivateKey()
|
||||
|
Loading…
Reference in New Issue
Block a user