Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions cmd/app/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"errors"
"fmt"
"net/http"
"net/url"

"github.com/harrisoncramer/gitlab.nvim/cmd/app/git"
"github.com/hashicorp/go-retryablehttp"
Expand Down Expand Up @@ -66,6 +67,14 @@ func NewClient() (*Client, error) {
},
}

if proxy := pluginOptions.ConnectionSettings.Proxy; proxy != "" {
u, err := url.Parse(proxy)
if err != nil {
return nil, fmt.Errorf("parse proxy url: %w", err)
}
tr.Proxy = http.ProxyURL(u)
}

retryClient := retryablehttp.NewClient()
retryClient.HTTPClient.Transport = tr
gitlabOptions = append(gitlabOptions, gitlab.WithHTTPClient(retryClient.HTTPClient))
Expand Down Expand Up @@ -99,11 +108,11 @@ func InitProjectSettings(c *Client, gitInfo git.GitData) (*ProjectInfo, error) {
project, _, err := c.GetProject(gitInfo.ProjectPath(), &opt)

if err != nil {
return nil, fmt.Errorf(fmt.Sprintf("Error getting project at %s", gitInfo.RemoteUrl), err)
return nil, fmt.Errorf("error getting project at %s: %w", gitInfo.RemoteUrl, err)
}

if project == nil {
return nil, fmt.Errorf(fmt.Sprintf("Could not find project at %s", gitInfo.RemoteUrl), err)
return nil, fmt.Errorf("could not find project at %s", gitInfo.RemoteUrl)
}

projectId := fmt.Sprint(project.ID)
Expand Down
1 change: 1 addition & 0 deletions cmd/app/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ type PluginOptions struct {
} `json:"debug"`
ChosenMrIID int `json:"chosen_mr_iid"`
ConnectionSettings struct {
Proxy string `json:"proxy"`
Insecure bool `json:"insecure"`
Remote string `json:"remote"`
} `json:"connection_settings"`
Expand Down
1 change: 1 addition & 0 deletions doc/gitlab.nvim.txt
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ you call this function with no values the defaults will be used:
},
},
connection_settings = {
proxy = "", -- Configure a proxy URL to use when connecting to GitLab. Supports URL schemes: http, https, socks5
insecure = false, -- Like curl's --insecure option, ignore bad x509 certificates on connection
remote = "origin", -- The default remote that your MRs target
},
Expand Down
1 change: 1 addition & 0 deletions lua/gitlab/state.lua
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ M.settings = {
},
},
connection_settings = {
proxy = "",
insecure = false,
remote = "origin",
},
Expand Down
Loading