Skip to content

Commit 22d9f76

Browse files
author
chhsia0
committed
Set secret token in CreateHook only if non-empty.
1 parent fdc0060 commit 22d9f76

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

scm/driver/gitlab/repo.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,11 @@ func (s *repositoryService) ListStatus(ctx context.Context, repo, ref string, op
114114
func (s *repositoryService) CreateHook(ctx context.Context, repo string, input *scm.HookInput) (*scm.Hook, *scm.Response, error) {
115115
params := url.Values{}
116116
params.Set("url", input.Target)
117-
params.Set("token", input.Secret)
117+
// Earlier versions of gitlab returned an error if the token was an empty string, so we only set
118+
// the token value if non-empty.
119+
if input.Secret != "" {
120+
params.Set("token", input.Secret)
121+
}
118122
params.Set("enable_ssl_verification", strconv.FormatBool(!input.SkipVerify))
119123
for k, v := range convertFromHookEvents(input.Events) {
120124
params.Set(k, strconv.FormatBool(v))

0 commit comments

Comments
 (0)