summaryrefslogtreecommitdiffstats
path: root/pkg/commands/pull_request.go
diff options
context:
space:
mode:
authorWilliam Wagner Moraes Artero <williamwmoraes@gmail.com>2020-02-25 20:18:22 +0100
committerJesse Duffield <jessedduffield@gmail.com>2020-03-01 10:57:12 +1100
commit3ce2b9b79ac909c772c2a2b56873b45b93f8d221 (patch)
tree7d6939205645b62dee08abe29cedaccb2151e6d3 /pkg/commands/pull_request.go
parenta79182e50d5dfd55389fab547110de24bb18ae87 (diff)
chore: keeping coverage up :D
Diffstat (limited to 'pkg/commands/pull_request.go')
-rw-r--r--pkg/commands/pull_request.go23
1 files changed, 17 insertions, 6 deletions
diff --git a/pkg/commands/pull_request.go b/pkg/commands/pull_request.go
index 3b08090e7..fff0978ef 100644
--- a/pkg/commands/pull_request.go
+++ b/pkg/commands/pull_request.go
@@ -29,25 +29,27 @@ type RepoInformation struct {
// NewService builds a Service based on the host type
func NewService(typeName string, repositoryDomain string, siteDomain string) *Service {
+ var service *Service
+
switch typeName {
case "github":
- return &Service{
+ service = &Service{
Name: repositoryDomain,
PullRequestURL: fmt.Sprintf("https://%s%s", siteDomain, "/%s/%s/compare/%s?expand=1"),
}
case "bitbucket":
- return &Service{
+ service = &Service{
Name: repositoryDomain,
PullRequestURL: fmt.Sprintf("https://%s%s", siteDomain, "/%s/%s/pull-requests/new?source=%s&t=1"),
}
case "gitlab":
- return &Service{
+ service = &Service{
Name: repositoryDomain,
PullRequestURL: fmt.Sprintf("https://%s%s", siteDomain, "/%s/%s/merge_requests/new?merge_request[source_branch]=%s"),
}
}
- return nil
+ return service
}
func getServices(config config.AppConfigurer) []*Service {
@@ -61,9 +63,18 @@ func getServices(config config.AppConfigurer) []*Service {
for repoDomain, typeAndDomain := range configServices {
splitData := strings.Split(typeAndDomain, ":")
- if len(splitData) == 2 {
- services = append(services, NewService(splitData[0], repoDomain, splitData[1]))
+ if len(splitData) != 2 {
+ // TODO log this misconfiguration
+ continue
+ }
+
+ service := NewService(splitData[0], repoDomain, splitData[1])
+ if service == nil {
+ // TODO log this unsupported service
+ continue
}
+
+ services = append(services, service)
}
return services