From fe5f087f9c29fd6e11429ac5f412a8107ffb902d Mon Sep 17 00:00:00 2001 From: William Wagner Moraes Artero Date: Fri, 6 Dec 2019 13:38:18 +0100 Subject: [PATCH] feat: configurable services --- pkg/commands/pull_request.go | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/pkg/commands/pull_request.go b/pkg/commands/pull_request.go index 11905f01d..a6b6bc8f7 100644 --- a/pkg/commands/pull_request.go +++ b/pkg/commands/pull_request.go @@ -5,6 +5,7 @@ import ( "strings" "github.com/go-errors/errors" + "github.com/jesseduffield/lazygit/pkg/config" ) // Service is a service that repository is on (Github, Bitbucket, ...) @@ -26,8 +27,8 @@ type RepoInformation struct { Repository string } -func getServices() []*Service { - return []*Service{ +func getServices(config config.AppConfigurer) []*Service { + services := []*Service{ { Name: "github.com", 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", }, } + + 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 func NewPullRequest(gitCommand *GitCommand) *PullRequest { return &PullRequest{ - GitServices: getServices(), + GitServices: getServices(gitCommand.Config), GitCommand: gitCommand, } }