mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-06-17 00:18:05 +02:00
feat: configurable services
This commit is contained in:
committed by
Jesse Duffield
parent
79299be3b2
commit
fe5f087f9c
@ -5,6 +5,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/go-errors/errors"
|
"github.com/go-errors/errors"
|
||||||
|
"github.com/jesseduffield/lazygit/pkg/config"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Service is a service that repository is on (Github, Bitbucket, ...)
|
// Service is a service that repository is on (Github, Bitbucket, ...)
|
||||||
@ -26,8 +27,8 @@ type RepoInformation struct {
|
|||||||
Repository string
|
Repository string
|
||||||
}
|
}
|
||||||
|
|
||||||
func getServices() []*Service {
|
func getServices(config config.AppConfigurer) []*Service {
|
||||||
return []*Service{
|
services := []*Service{
|
||||||
{
|
{
|
||||||
Name: "github.com",
|
Name: "github.com",
|
||||||
PullRequestURL: "https://github.com/%s/%s/compare/%s?expand=1",
|
PullRequestURL: "https://github.com/%s/%s/compare/%s?expand=1",
|
||||||
@ -41,12 +42,23 @@ func getServices() []*Service {
|
|||||||
PullRequestURL: "https://gitlab.com/%s/%s/merge_requests/new?merge_request[source_branch]=%s",
|
PullRequestURL: "https://gitlab.com/%s/%s/merge_requests/new?merge_request[source_branch]=%s",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
configServices := config.GetUserConfig().GetStringMapString("services")
|
||||||
|
|
||||||
|
for name, prURL := range configServices {
|
||||||
|
services = append(services, &Service{
|
||||||
|
Name: name,
|
||||||
|
PullRequestURL: prURL,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
return services
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewPullRequest creates new instance of PullRequest
|
// NewPullRequest creates new instance of PullRequest
|
||||||
func NewPullRequest(gitCommand *GitCommand) *PullRequest {
|
func NewPullRequest(gitCommand *GitCommand) *PullRequest {
|
||||||
return &PullRequest{
|
return &PullRequest{
|
||||||
GitServices: getServices(),
|
GitServices: getServices(gitCommand.Config),
|
||||||
GitCommand: gitCommand,
|
GitCommand: gitCommand,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user