1
0
mirror of https://github.com/woodpecker-ci/woodpecker.git synced 2025-02-04 18:21:06 +02:00

Merge pull request #813 from bradrydzewski/master

fixed dependency issue w/ gopkg.in
This commit is contained in:
Brad Rydzewski 2015-01-13 23:36:38 -08:00
commit dac460f488
6 changed files with 31 additions and 11 deletions

View File

@ -29,10 +29,11 @@ func (w *Webhook) Send(context *model.Request) error {
func (w *Webhook) send(context *model.Request) error {
// data will get posted in this format
data := struct {
From string `json:"from_url"`
Owner *model.User `json:"owner"`
Repo *model.Repo `json:"repository"`
Commit *model.Commit `json:"commit"`
}{context.User, context.Repo, context.Commit}
}{context.Host, context.User, context.Repo, context.Commit}
// data json encoded
payload, err := json.Marshal(data)

View File

@ -6,7 +6,7 @@ import (
"github.com/drone/drone/shared/build/buildfile"
"github.com/drone/drone/shared/build/repo"
"gopkg.in/v1/yaml"
"gopkg.in/yaml.v1"
)
type PublishToDrone struct {

View File

@ -5,7 +5,7 @@ import (
"strings"
"testing"
"gopkg.in/v1/yaml"
"gopkg.in/yaml.v1"
)
var validcfg = map[string]interface{}{

View File

@ -49,20 +49,15 @@ func (db *Userstore) GetUserList() ([]*model.User, error) {
// PostUser saves a User in the datastore.
func (db *Userstore) PostUser(user *model.User) error {
if user.Created == 0 {
user.Created = time.Now().UTC().Unix()
}
user.Created = time.Now().UTC().Unix()
user.Updated = time.Now().UTC().Unix()
return meddler.Save(db, userTable, user)
return meddler.Insert(db, userTable, user)
}
// PutUser saves a user in the datastore.
func (db *Userstore) PutUser(user *model.User) error {
if user.Created == 0 {
user.Created = time.Now().UTC().Unix()
}
user.Updated = time.Now().UTC().Unix()
return meddler.Save(db, userTable, user)
return meddler.Update(db, userTable, user)
}
// DelUser removes the user from the datastore.

View File

@ -70,6 +70,13 @@ func GetLogin(c web.C, w http.ResponseWriter, r *http.Request) {
return
}
// the user id should NEVER equal zero
if u.ID == 0 {
log.Println("Unable to create account. User ID is zero")
w.WriteHeader(http.StatusInternalServerError)
return
}
// if this is the first user, they
// should be an admin.
if u.ID == 1 {

View File

@ -1,5 +1,9 @@
package model
import (
"fmt"
)
type Request struct {
Host string `json:"-"`
User *User `json:"-"`
@ -7,3 +11,16 @@ type Request struct {
Commit *Commit `json:"commit"`
Prior *Commit `json:"prior_commit"`
}
// URL returns the link to the commit in
// string format.
func (r *Request) URL() string {
return fmt.Sprintf("%s/%s/%s/%s/%s/%s",
r.Host,
r.Repo.Host,
r.Repo.Owner,
r.Repo.Name,
r.Commit.Branch,
r.Commit.Sha,
)
}