(ctx context.Context, owner, name string, hook *github.Hook)
| 36 | } |
| 37 | |
| 38 | func (g *githubClient) createGiteaRepoHook(ctx context.Context, owner, name string, hook *github.Hook) (ret *github.Hook, err error) { |
| 39 | u := fmt.Sprintf("repos/%v/%v/hooks", owner, name) |
| 40 | createOpts := &createGiteaHookOptions{ |
| 41 | Type: "gitea", |
| 42 | Events: hook.Events, |
| 43 | Active: hook.GetActive(), |
| 44 | BranchFilter: "*", |
| 45 | Config: map[string]string{ |
| 46 | "content_type": hook.GetConfig().GetContentType(), |
| 47 | "url": hook.GetConfig().GetURL(), |
| 48 | "http_method": "post", |
| 49 | "secret": hook.GetConfig().GetSecret(), |
| 50 | }, |
| 51 | } |
| 52 | |
| 53 | req, err := g.cli.NewRequest(http.MethodPost, u, createOpts) |
| 54 | if err != nil { |
| 55 | return nil, fmt.Errorf("failed to construct request: %w", err) |
| 56 | } |
| 57 | |
| 58 | hook = new(github.Hook) |
| 59 | _, err = g.cli.Do(ctx, req, hook) |
| 60 | if err != nil { |
| 61 | return nil, fmt.Errorf("request failed for %s: %w", req.URL.String(), err) |
| 62 | } |
| 63 | return hook, nil |
| 64 | } |
| 65 | |
| 66 | func (g *githubClient) createGiteaOrgHook(ctx context.Context, owner string, hook *github.Hook) (ret *github.Hook, err error) { |
| 67 | u := fmt.Sprintf("orgs/%v/hooks", owner) |
no test coverage detected