| 631 | } |
| 632 | |
| 633 | func withGiteaURLs(client *github.Client, apiBaseURL string) (*github.Client, error) { |
| 634 | if client == nil { |
| 635 | return nil, errors.New("client is nil") |
| 636 | } |
| 637 | |
| 638 | if apiBaseURL == "" { |
| 639 | return nil, errors.New("invalid gitea URLs") |
| 640 | } |
| 641 | |
| 642 | parsedBaseURL, err := url.ParseRequestURI(apiBaseURL) |
| 643 | if err != nil { |
| 644 | return nil, fmt.Errorf("error parsing gitea base URL: %w", err) |
| 645 | } |
| 646 | |
| 647 | if !strings.HasSuffix(parsedBaseURL.Path, "/") { |
| 648 | parsedBaseURL.Path += "/" |
| 649 | } |
| 650 | |
| 651 | if !strings.HasSuffix(parsedBaseURL.Path, "/api/v1/") { |
| 652 | parsedBaseURL.Path += "api/v1/" |
| 653 | } |
| 654 | |
| 655 | client.BaseURL = parsedBaseURL |
| 656 | client.UploadURL = parsedBaseURL |
| 657 | |
| 658 | return client, nil |
| 659 | } |
| 660 | |
| 661 | func Client(ctx context.Context, entity params.ForgeEntity) (common.GithubClient, error) { |
| 662 | httpClient, err := entity.Credentials.GetHTTPClient(ctx) |