mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2025-01-03 14:18:42 +00:00
Build ref link point to commit not compare if only one commit was pushed (#673)
close #401
This commit is contained in:
parent
7986eba002
commit
1588495b1a
2 changed files with 7 additions and 2 deletions
|
@ -84,15 +84,20 @@ func buildFromPush(hook *pushHook) *model.Build {
|
||||||
}
|
}
|
||||||
|
|
||||||
message := ""
|
message := ""
|
||||||
|
link := hook.Compare
|
||||||
if len(hook.Commits) > 0 {
|
if len(hook.Commits) > 0 {
|
||||||
message = hook.Commits[0].Message
|
message = hook.Commits[0].Message
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if len(hook.Commits) == 1 {
|
||||||
|
link = hook.Commits[0].URL
|
||||||
|
}
|
||||||
|
|
||||||
return &model.Build{
|
return &model.Build{
|
||||||
Event: model.EventPush,
|
Event: model.EventPush,
|
||||||
Commit: hook.After,
|
Commit: hook.After,
|
||||||
Ref: hook.Ref,
|
Ref: hook.Ref,
|
||||||
Link: hook.Compare,
|
Link: link,
|
||||||
Branch: strings.TrimPrefix(hook.Ref, "refs/heads/"),
|
Branch: strings.TrimPrefix(hook.Ref, "refs/heads/"),
|
||||||
Message: message,
|
Message: message,
|
||||||
Avatar: avatar,
|
Avatar: avatar,
|
||||||
|
|
|
@ -101,7 +101,7 @@ func Test_parse(t *testing.T) {
|
||||||
g.Assert(build.Event).Equal(model.EventPush)
|
g.Assert(build.Event).Equal(model.EventPush)
|
||||||
g.Assert(build.Commit).Equal(hook.After)
|
g.Assert(build.Commit).Equal(hook.After)
|
||||||
g.Assert(build.Ref).Equal(hook.Ref)
|
g.Assert(build.Ref).Equal(hook.Ref)
|
||||||
g.Assert(build.Link).Equal(hook.Compare)
|
g.Assert(build.Link).Equal(hook.Commits[0].URL)
|
||||||
g.Assert(build.Branch).Equal("master")
|
g.Assert(build.Branch).Equal("master")
|
||||||
g.Assert(build.Message).Equal(hook.Commits[0].Message)
|
g.Assert(build.Message).Equal(hook.Commits[0].Message)
|
||||||
g.Assert(build.Avatar).Equal("http://1.gravatar.com/avatar/8c58a0be77ee441bb8f8595b7f1b4e87")
|
g.Assert(build.Avatar).Equal("http://1.gravatar.com/avatar/8c58a0be77ee441bb8f8595b7f1b4e87")
|
||||||
|
|
Loading…
Reference in a new issue