Skip to content

Commit

Permalink
Fix gitlab hooks (woodpecker-ci#2537)
Browse files Browse the repository at this point in the history
  • Loading branch information
qwerty287 committed Oct 7, 2023
1 parent 18ff561 commit 67f38de
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion server/forge/gitlab/gitlab.go
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ func (g *GitLab) getTokenAndWebURL(link string) (token, webURL string, err error
return "", "", err
}
token = uri.Query().Get("access_token")
webURL = fmt.Sprintf("%s://%s/api/hook", uri.Scheme, uri.Host)
webURL = fmt.Sprintf("%s://%s/%s", uri.Scheme, uri.Host, strings.TrimPrefix(uri.Path, "/"))
return token, webURL, nil
}

Expand Down
6 changes: 3 additions & 3 deletions server/forge/gitlab/gitlab_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,12 @@ func Test_GitLab(t *testing.T) {
// Test activate method
g.Describe("Activate", func() {
g.It("Should be success", func() {
err := client.Activate(ctx, &user, &repo, "http://example.com/api/hook/test/test?access_token=token")
err := client.Activate(ctx, &user, &repo, "http://example.com/api/hook?access_token=token")
assert.NoError(t, err)
})

g.It("Should be failed, when token not given", func() {
err := client.Activate(ctx, &user, &repo, "http://example.com/api/hook/test/test")
err := client.Activate(ctx, &user, &repo, "http://example.com/api/hook")

g.Assert(err).IsNotNil()
})
Expand All @@ -124,7 +124,7 @@ func Test_GitLab(t *testing.T) {
// Test deactivate method
g.Describe("Deactivate", func() {
g.It("Should be success", func() {
err := client.Deactivate(ctx, &user, &repo, "http://example.com/api/hook/test/test?access_token=token")
err := client.Deactivate(ctx, &user, &repo, "http://example.com/api/hook?access_token=token")

g.Assert(err).IsNil()
})
Expand Down

0 comments on commit 67f38de

Please sign in to comment.