Suppression de EventBranch
This commit is contained in:
parent
fe750c751a
commit
82c534ad18
3 changed files with 24 additions and 3 deletions
|
@ -166,7 +166,12 @@ func (c *client) Perm(u *model.User, owner, name string) (*model.Perm, error) {
|
|||
// File fetches the file from the Gogs repository and returns its contents.
|
||||
func (c *client) File(u *model.User, r *model.Repo, b *model.Build, f string) ([]byte, error) {
|
||||
client := c.newClientToken(u.Token)
|
||||
cfg, err := client.GetFile(r.Owner, r.Name, b.Commit, f)
|
||||
buildRef := b.Commit
|
||||
if buildRef == "" {
|
||||
buildRef = b.Ref
|
||||
}
|
||||
cfg, err := client.GetFile(r.Owner, r.Name, buildRef, f)
|
||||
|
||||
return cfg, err
|
||||
}
|
||||
|
||||
|
|
|
@ -70,13 +70,28 @@ func buildFromPush(hook *pushHook) *model.Build {
|
|||
hook.Repo.URL,
|
||||
fixMalformedAvatar(hook.Sender.Avatar),
|
||||
)
|
||||
|
||||
var eventType string
|
||||
var message string
|
||||
|
||||
switch {
|
||||
case hook.RefType == "tag":
|
||||
eventType = model.EventTag
|
||||
message = "Tag " + hook.Ref
|
||||
case hook.RefType == "branch":
|
||||
eventType = ""
|
||||
default:
|
||||
eventType = model.EventPush
|
||||
message = hook.Commits[0].Message
|
||||
}
|
||||
|
||||
return &model.Build{
|
||||
Event: model.EventPush,
|
||||
Event: eventType,
|
||||
Commit: hook.After,
|
||||
Ref: hook.Ref,
|
||||
Link: hook.Compare,
|
||||
Branch: strings.TrimPrefix(hook.Ref, "refs/heads/"),
|
||||
Message: hook.Commits[0].Message,
|
||||
Message: message,
|
||||
Avatar: avatar,
|
||||
Author: hook.Sender.Login,
|
||||
Timestamp: time.Now().UTC().Unix(),
|
||||
|
|
|
@ -5,6 +5,7 @@ type pushHook struct {
|
|||
Before string `json:"before"`
|
||||
After string `json:"after"`
|
||||
Compare string `json:"compare_url"`
|
||||
RefType string `json:"ref_type"`
|
||||
|
||||
Pusher struct {
|
||||
Name string `json:"name"`
|
||||
|
|
Loading…
Reference in a new issue