From c1bda3c4d4fb6344d08a64c1943ae9597ca330b2 Mon Sep 17 00:00:00 2001 From: Andrew Thornton Date: Tue, 12 Nov 2019 18:32:27 +0000 Subject: [PATCH 1/2] Fix Notify Create Ref Error on tag creation --- modules/notification/webhook/webhook.go | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/modules/notification/webhook/webhook.go b/modules/notification/webhook/webhook.go index 8059ec1c00f89..fa32a8cdcb9e5 100644 --- a/modules/notification/webhook/webhook.go +++ b/modules/notification/webhook/webhook.go @@ -573,9 +573,22 @@ func (m *webhookNotifier) NotifyCreateRef(pusher *models.User, repo *models.Repo return } - shaSum, err := gitRepo.GetBranchCommitID(refName) - if err != nil { - log.Error("GetBranchCommitID[%s]: %v", refFullName, err) + var shaSum string + switch refType { + case "branch": + shaSum, err = gitRepo.GetBranchCommitID(refName) + if err != nil { + log.Error("GetBranchCommitID[%s]: %v", refFullName, err) + return + } + case "tag": + shaSum, err = gitRepo.GetTagCommitID(refName) + if err != nil { + log.Error("GetBranchCommitID[%s]: %v", refFullName, err) + return + } + default: + log.Error("Unknown refType: %s for refName: %s", refType, refName) return } From 2c9e19b697c57ce0fe1e548f178bc81f66eebbf7 Mon Sep 17 00:00:00 2001 From: Andrew Thornton Date: Tue, 12 Nov 2019 18:38:58 +0000 Subject: [PATCH 2/2] Just use the provided full ref instead of BranchCommit --- modules/notification/webhook/webhook.go | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/modules/notification/webhook/webhook.go b/modules/notification/webhook/webhook.go index fa32a8cdcb9e5..27afbba7ab81e 100644 --- a/modules/notification/webhook/webhook.go +++ b/modules/notification/webhook/webhook.go @@ -573,22 +573,9 @@ func (m *webhookNotifier) NotifyCreateRef(pusher *models.User, repo *models.Repo return } - var shaSum string - switch refType { - case "branch": - shaSum, err = gitRepo.GetBranchCommitID(refName) - if err != nil { - log.Error("GetBranchCommitID[%s]: %v", refFullName, err) - return - } - case "tag": - shaSum, err = gitRepo.GetTagCommitID(refName) - if err != nil { - log.Error("GetBranchCommitID[%s]: %v", refFullName, err) - return - } - default: - log.Error("Unknown refType: %s for refName: %s", refType, refName) + shaSum, err := gitRepo.GetRefCommitID(refFullName) + if err != nil { + log.Error("GetRefCommitID[%s]: %v", refFullName, err) return }