Committer avatar
This commit is contained in:
parent
193d524493
commit
fbf36458f1
3 changed files with 29 additions and 1 deletions
|
@ -372,6 +372,10 @@ func mergeRequest(parsed *client.HookPayload, req *http.Request) (*model.Repo, *
|
||||||
|
|
||||||
build.Author = parsed.ObjectAttributes.LastCommit.Author.Name
|
build.Author = parsed.ObjectAttributes.LastCommit.Author.Name
|
||||||
build.Email = parsed.ObjectAttributes.LastCommit.Author.Email
|
build.Email = parsed.ObjectAttributes.LastCommit.Author.Email
|
||||||
|
if len(build.Email) != 0 {
|
||||||
|
build.Avatar = GetUserAvatar(build.Email)
|
||||||
|
}
|
||||||
|
|
||||||
build.Title = parsed.ObjectAttributes.Title
|
build.Title = parsed.ObjectAttributes.Title
|
||||||
build.Link = parsed.ObjectAttributes.Url
|
build.Link = parsed.ObjectAttributes.Url
|
||||||
|
|
||||||
|
@ -417,6 +421,9 @@ func push(parsed *client.HookPayload, req *http.Request) (*model.Repo, *model.Bu
|
||||||
case head.Author != nil:
|
case head.Author != nil:
|
||||||
build.Email = head.Author.Email
|
build.Email = head.Author.Email
|
||||||
build.Author = parsed.UserName
|
build.Author = parsed.UserName
|
||||||
|
if len(build.Email) != 0 {
|
||||||
|
build.Avatar = GetUserAvatar(build.Email)
|
||||||
|
}
|
||||||
case head.Author == nil:
|
case head.Author == nil:
|
||||||
build.Author = parsed.UserName
|
build.Author = parsed.UserName
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
package gitlab
|
package gitlab
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"crypto/md5"
|
||||||
|
"encoding/hex"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/url"
|
"net/url"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
@ -8,6 +10,10 @@ import (
|
||||||
"github.com/drone/drone/remote/gitlab/client"
|
"github.com/drone/drone/remote/gitlab/client"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
gravatarBase = "https://www.gravatar.com/avatar"
|
||||||
|
)
|
||||||
|
|
||||||
// NewClient is a helper function that returns a new GitHub
|
// NewClient is a helper function that returns a new GitHub
|
||||||
// client using the provided OAuth token.
|
// client using the provided OAuth token.
|
||||||
func NewClient(url, accessToken string, skipVerify bool) *client.Client {
|
func NewClient(url, accessToken string, skipVerify bool) *client.Client {
|
||||||
|
@ -79,6 +85,18 @@ func ns(owner, name string) string {
|
||||||
return fmt.Sprintf("%s%%2F%s", owner, name)
|
return fmt.Sprintf("%s%%2F%s", owner, name)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func GetUserAvatar(email string) string {
|
||||||
|
hasher := md5.New()
|
||||||
|
hasher.Write([]byte(email))
|
||||||
|
|
||||||
|
return fmt.Sprintf(
|
||||||
|
"%s/%v.jpg?s=%s",
|
||||||
|
gravatarBase,
|
||||||
|
hex.EncodeToString(hasher.Sum(nil)),
|
||||||
|
"128",
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
func GetUserEmail(c *client.Client, defaultURL string) (*client.Client, error) {
|
func GetUserEmail(c *client.Client, defaultURL string) (*client.Client, error) {
|
||||||
return c, nil
|
return c, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,7 +32,10 @@ block content
|
||||||
each $build in $group.Builds
|
each $build in $group.Builds
|
||||||
a.card[href=$repo.Name+"/"+$build.Number][data-build=$build.Number]
|
a.card[href=$repo.Name+"/"+$build.Number][data-build=$build.Number]
|
||||||
div.card-header
|
div.card-header
|
||||||
img[src=$build.Avatar]
|
if $build.Avatar != ""
|
||||||
|
img[src=$build.Avatar]
|
||||||
|
else
|
||||||
|
img[src="/static/images/dummy.png"]
|
||||||
div.card-block
|
div.card-block
|
||||||
div
|
div
|
||||||
div.status[class=$build.Status] #{$build.Status}
|
div.status[class=$build.Status] #{$build.Status}
|
||||||
|
|
Loading…
Reference in a new issue