github: fix retrieving commit sha for signed tags
if a tag is a signed tag, github's hook.After points to the signed tag object sha and not the related commit sha. In this case use hook.HeadCommit.ID.
This commit is contained in:
parent
11a2ff48d6
commit
25322a6d81
|
@ -87,6 +87,13 @@ func webhookDataFromPush(hook *github.PushEvent) (*types.WebhookData, error) {
|
||||||
whd.Tag = strings.TrimPrefix(*hook.Ref, "refs/tags/")
|
whd.Tag = strings.TrimPrefix(*hook.Ref, "refs/tags/")
|
||||||
whd.TagLink = fmt.Sprintf("%s/tree/%s", *hook.Repo.HTMLURL, whd.Tag)
|
whd.TagLink = fmt.Sprintf("%s/tree/%s", *hook.Repo.HTMLURL, whd.Tag)
|
||||||
whd.Message = fmt.Sprintf("Tag %s", whd.Tag)
|
whd.Message = fmt.Sprintf("Tag %s", whd.Tag)
|
||||||
|
|
||||||
|
// if it's a signed tag hook.After points to the signed tag sha and not the
|
||||||
|
// commit sha. In this case use hook.HeadCommit.ID
|
||||||
|
if hook.HeadCommit.ID != nil {
|
||||||
|
whd.CommitSHA = *hook.HeadCommit.ID
|
||||||
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
// ignore received webhook since it doesn't have a ref we're interested in
|
// ignore received webhook since it doesn't have a ref we're interested in
|
||||||
return nil, fmt.Errorf("unsupported webhook ref %q", *hook.Ref)
|
return nil, fmt.Errorf("unsupported webhook ref %q", *hook.Ref)
|
||||||
|
|
Loading…
Reference in New Issue