Skip to content

Commit 8df0167

Browse files
committed
fixed error where push webhook not called if is new branch or tag
removed unnecessary code Signed-off-by: David Schneiderbauer <[email protected]>
1 parent 85cb006 commit 8df0167

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

models/action.go

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -622,13 +622,15 @@ func CommitRepoAction(opts CommitRepoActionOptions) error {
622622
if err != nil {
623623
log.Error(4, "GetBranchCommitID[%s]: %v", opts.RefFullName, err)
624624
}
625-
return PrepareWebhooks(repo, HookEventCreate, &api.CreatePayload{
625+
if err = PrepareWebhooks(repo, HookEventCreate, &api.CreatePayload{
626626
Ref: refName,
627627
Sha: shaSum,
628628
RefType: "branch",
629629
Repo: apiRepo,
630630
Sender: apiPusher,
631-
})
631+
}); err != nil {
632+
return fmt.Errorf("PrepareWebhooks: %v", err)
633+
}
632634
}
633635

634636
case ActionDeleteBranch: // Delete Branch
@@ -645,14 +647,15 @@ func CommitRepoAction(opts CommitRepoActionOptions) error {
645647
if err != nil {
646648
log.Error(4, "GetTagCommitID[%s]: %v", opts.RefFullName, err)
647649
}
648-
return PrepareWebhooks(repo, HookEventCreate, &api.CreatePayload{
650+
if err = PrepareWebhooks(repo, HookEventCreate, &api.CreatePayload{
649651
Ref: refName,
650652
Sha: shaSum,
651653
RefType: "tag",
652654
Repo: apiRepo,
653655
Sender: apiPusher,
654-
})
655-
656+
}); err != nil {
657+
return fmt.Errorf("PrepareWebhooks: %v", err)
658+
}
656659
case ActionDeleteTag: // Delete Tag
657660
isHookEventPush = true
658661
}

models/action_test.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -312,9 +312,7 @@ func TestCommitRepoAction(t *testing.T) {
312312
s.commitRepoActionOptions.RepoName = repo.Name
313313

314314
s.action.ActUserID = user.ID
315-
s.action.ActUser = user
316315
s.action.RepoID = repo.ID
317-
s.action.Repo = repo
318316
s.action.IsPrivate = repo.IsPrivate
319317

320318
testCorrectRepoAction(t, s.commitRepoActionOptions, &s.action)

0 commit comments

Comments
 (0)