Optimize performance

This commit is contained in:
Michael de Wit 2016-12-22 14:24:05 +01:00
parent 5c2938d970
commit c2703ff89c

View file

@ -177,13 +177,14 @@ func (c *client) File(u *model.User, r *model.Repo, b *model.Build, f string) ([
client := c.newClientToken(u.Token) client := c.newClientToken(u.Token)
buildRef := b.Commit buildRef := b.Commit
if buildRef == "" { if buildRef == "" {
buildRef = b.Ref
// Remove refs/tags or refs/heads, Gogs needs a short ref // Remove refs/tags or refs/heads, Gogs needs a short ref
refPath := strings.SplitAfterN(b.Ref, "/", 3) buildRef = strings.TrimPrefix(
if len(refPath) > 0 { strings.TrimPrefix(
buildRef = refPath[len(refPath)-1] b.Ref,
} "refs/heads/",
),
"refs/tags/",
)
} }
cfg, err := client.GetFile(r.Owner, r.Name, buildRef, f) cfg, err := client.GetFile(r.Owner, r.Name, buildRef, f)
return cfg, err return cfg, err