diff --git a/api/queries_issue.go b/api/queries_issue.go index 3fb20e094..d76e1b79e 100644 --- a/api/queries_issue.go +++ b/api/queries_issue.go @@ -41,16 +41,8 @@ const fragments = ` } ` -func IssueCreate(client *Client, ghRepo Repo, params map[string]interface{}) (*Issue, error) { - repo, err := GitHubRepo(client, ghRepo) - if err != nil { - return nil, err - } - - if !repo.HasIssuesEnabled { - return nil, fmt.Errorf("the '%s/%s' repository has disabled issues", ghRepo.RepoOwner(), ghRepo.RepoName()) - } - +// IssueCreate creates an issue in a GitHub repository +func IssueCreate(client *Client, repo *Repository, params map[string]interface{}) (*Issue, error) { query := ` mutation CreateIssue($input: CreateIssueInput!) { createIssue(input: $input) { @@ -76,7 +68,7 @@ func IssueCreate(client *Client, ghRepo Repo, params map[string]interface{}) (*I } }{} - err = client.GraphQL(query, variables, &result) + err := client.GraphQL(query, variables, &result) if err != nil { return nil, err } diff --git a/command/issue.go b/command/issue.go index df30b6e52..5383daf41 100644 --- a/command/issue.go +++ b/command/issue.go @@ -257,6 +257,14 @@ func issueCreate(cmd *cobra.Command, args []string) error { return err } + repo, err := api.GitHubRepo(apiClient, baseRepo) + if err != nil { + return err + } + if !repo.HasIssuesEnabled { + return fmt.Errorf("the '%s/%s' repository has disabled issues", baseRepo.RepoOwner(), baseRepo.RepoName()) + } + title, err := cmd.Flags().GetString("title") if err != nil { return errors.Wrap(err, "could not parse title") @@ -291,7 +299,7 @@ func issueCreate(cmd *cobra.Command, args []string) error { "body": body, } - newIssue, err := api.IssueCreate(apiClient, baseRepo, params) + newIssue, err := api.IssueCreate(apiClient, repo, params) if err != nil { return err }