1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-06-15 22:01:43 +03:00

Remove doubled string formatting in pull request URL generation

This commit is contained in:
Denis Palashevskii
2021-06-08 11:46:50 +04:00
committed by Jesse Duffield
parent 0a63f701e5
commit d5ec0fdcd1
2 changed files with 51 additions and 12 deletions

View File

@ -38,11 +38,9 @@ func NewService(typeName string, repositoryDomain string, siteDomain string) *Se
Name: repositoryDomain,
PullRequestURL: func(owner string, repository string, from string, to string) string {
if to == "" {
urlFormat := fmt.Sprintf("https://%s%s", siteDomain, "/%s/%s/compare/%s?expand=1")
return fmt.Sprintf(urlFormat, owner, repository, from)
return fmt.Sprintf("https://%s/%s/%s/compare/%s?expand=1",siteDomain, owner, repository, from)
} else {
urlFormat := fmt.Sprintf("https://%s%s", siteDomain, "/%s/%s/compare/%s...%s?expand=1")
return fmt.Sprintf(urlFormat, owner, repository, to, from)
return fmt.Sprintf("https://%s/%s/%s/compare/%s...%s?expand=1", siteDomain, owner, repository, to, from)
}
},
}
@ -51,11 +49,9 @@ func NewService(typeName string, repositoryDomain string, siteDomain string) *Se
Name: repositoryDomain,
PullRequestURL: func(owner string, repository string, from string, to string) string {
if to == "" {
urlFormat := fmt.Sprintf("https://%s%s", siteDomain, "/%s/%s/pull-requests/new?source=%s&t=1")
return fmt.Sprintf(urlFormat, owner, repository, from)
return fmt.Sprintf("https://%s/%s/%s/pull-requests/new?source=%s&t=1", siteDomain, owner, repository, from)
} else {
urlFormat := fmt.Sprintf("https://%s%s", siteDomain, "/%s/%s/pull-requests/new?source=%s&dest=%s&t=1")
return fmt.Sprintf(urlFormat, owner, repository, from, to)
return fmt.Sprintf("https://%s/%s/%s/pull-requests/new?source=%s&dest=%s&t=1", siteDomain, owner, repository, from, to)
}
},
}
@ -64,11 +60,9 @@ func NewService(typeName string, repositoryDomain string, siteDomain string) *Se
Name: repositoryDomain,
PullRequestURL: func(owner string, repository string, from string, to string) string {
if to == "" {
urlFormat := fmt.Sprintf("https://%s%s", siteDomain, "/%s/%s/merge_requests/new?merge_request[source_branch]=%s")
return fmt.Sprintf(urlFormat, owner, repository, from)
return fmt.Sprintf("https://%s/%s/%s/merge_requests/new?merge_request[source_branch]=%s", siteDomain, owner, repository, from)
} else {
urlFormat := fmt.Sprintf("https://%s%s", siteDomain, "/%s/%s/merge_requests/new?merge_request[source_branch]=%s&merge_request[target_branch]=%s")
return fmt.Sprintf(urlFormat, owner, repository, from, to)
return fmt.Sprintf("https://%s/%s/%s/merge_requests/new?merge_request[source_branch]=%s&merge_request[target_branch]=%s", siteDomain, owner, repository, from, to)
}
},
}