move generateRepoURL to ghrepo

This commit is contained in:
vilmibm 2020-07-23 11:16:47 -05:00
parent 895af993a5
commit dc02366128
5 changed files with 14 additions and 22 deletions

View file

@ -227,7 +227,7 @@ func issueList(cmd *cobra.Command, args []string) error {
}
if web {
issueListURL := generateRepoURL(baseRepo, "issues")
issueListURL := ghrepo.GenerateRepoURL(baseRepo, "issues")
openURL, err := listURLWithQuery(issueListURL, filterOptions{
entity: "issue",
state: state,
@ -504,7 +504,7 @@ func issueCreate(cmd *cobra.Command, args []string) error {
}
if isWeb, err := cmd.Flags().GetBool("web"); err == nil && isWeb {
openURL := generateRepoURL(baseRepo, "issues/new")
openURL := ghrepo.GenerateRepoURL(baseRepo, "issues/new")
if title != "" || body != "" {
milestone := ""
if len(milestoneTitles) > 0 {
@ -582,7 +582,7 @@ func issueCreate(cmd *cobra.Command, args []string) error {
}
if action == PreviewAction {
openURL := generateRepoURL(baseRepo, "issues/new")
openURL := ghrepo.GenerateRepoURL(baseRepo, "issues/new")
milestone := ""
if len(milestoneTitles) > 0 {
milestone = milestoneTitles[0]
@ -618,14 +618,6 @@ func issueCreate(cmd *cobra.Command, args []string) error {
return nil
}
func generateRepoURL(repo ghrepo.Interface, p string, args ...interface{}) string {
baseURL := fmt.Sprintf("https://%s/%s/%s", repo.RepoHost(), repo.RepoOwner(), repo.RepoName())
if p != "" {
return baseURL + "/" + fmt.Sprintf(p, args...)
}
return baseURL
}
func addMetadataToIssueParams(client *api.Client, baseRepo ghrepo.Interface, params map[string]interface{}, tb *issueMetadataState) error {
if !tb.HasMetadata() {
return nil

View file

@ -235,7 +235,7 @@ func prList(cmd *cobra.Command, args []string) error {
}
if web {
prListURL := generateRepoURL(baseRepo, "pulls")
prListURL := ghrepo.GenerateRepoURL(baseRepo, "pulls")
openURL, err := listURLWithQuery(prListURL, filterOptions{
entity: "pr",
state: state,

View file

@ -447,7 +447,7 @@ func withPrAndIssueQueryParams(baseURL, title, body string, assignees, labels, p
}
func generateCompareURL(r ghrepo.Interface, base, head, title, body string, assignees, labels, projects []string, milestone string) (string, error) {
u := generateRepoURL(r, "compare/%s...%s?expand=1", base, head)
u := ghrepo.GenerateRepoURL(r, "compare/%s...%s?expand=1", base, head)
url, err := withPrAndIssueQueryParams(u, title, body, assignees, labels, projects, milestone)
if err != nil {
return "", err