diff options
author | Kim "BKC" Carlbäcker <kim.carlbacker@gmail.com> | 2016-11-29 09:13:30 +0100 |
---|---|---|
committer | Kim "BKC" Carlbäcker <kim.carlbacker@gmail.com> | 2016-11-29 11:50:22 +0100 |
commit | dad806d3ea0da6a09eea14ac467d0c843a98dda4 (patch) | |
tree | f4d84d2c443a4c3f046e141d26992b8fa799747b /models/action.go | |
parent | 57dc9efaaef3756f5b432b030973295934634544 (diff) | |
download | gitea-dad806d3ea0da6a09eea14ac467d0c843a98dda4.tar.gz gitea-dad806d3ea0da6a09eea14ac467d0c843a98dda4.zip |
CreateBranch-hook has shasum. Use the full ref for fetching shasum
Diffstat (limited to 'models/action.go')
-rw-r--r-- | models/action.go | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/models/action.go b/models/action.go index aebc02be54..e2ac1756ab 100644 --- a/models/action.go +++ b/models/action.go @@ -540,6 +540,8 @@ func CommitRepoAction(opts CommitRepoActionOptions) error { apiPusher := pusher.APIFormat() apiRepo := repo.APIFormat(nil) + + var shaSum string switch opType { case ActionCommitRepo: // Push if err = PrepareWebhooks(repo, HookEventPush, &api.PushPayload{ @@ -556,8 +558,17 @@ func CommitRepoAction(opts CommitRepoActionOptions) error { } if isNewBranch { + gitRepo, err := git.OpenRepository(repo.RepoPath()) + if err != nil { + log.Error(4, "OpenRepository[%s]: %v", repo.RepoPath(), err) + } + shaSum, err = gitRepo.GetBranchCommitID(opts.RefFullName) + if err != nil { + log.Error(4, "GetBranchCommitID[%s]: %v", opts.RefFullName, err) + } return PrepareWebhooks(repo, HookEventCreate, &api.CreatePayload{ Ref: refName, + Sha: shaSum, RefType: "branch", Repo: apiRepo, Sender: apiPusher, @@ -565,7 +576,14 @@ func CommitRepoAction(opts CommitRepoActionOptions) error { } case ActionPushTag: // Create - shaSum := git.OpenRepository(repo.RepoPath()).GetTagCommitID(refName) + gitRepo, err := git.OpenRepository(repo.RepoPath()) + if err != nil { + log.Error(4, "OpenRepository[%s]: %v", repo.RepoPath(), err) + } + shaSum, err = gitRepo.GetTagCommitID(opts.RefFullName) + if err != nil { + log.Error(4, "GetTagCommitID[%s]: %v", opts.RefFullName, err) + } return PrepareWebhooks(repo, HookEventCreate, &api.CreatePayload{ Ref: refName, Sha: shaSum, |