Merge remote-tracking branch 'origin' into doc-examples-tweaks
This commit is contained in:
commit
73ab5810ea
6 changed files with 47 additions and 25 deletions
|
|
@ -2,6 +2,7 @@ package command
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
|
|
@ -21,23 +22,21 @@ func init() {
|
|||
|
||||
var configCmd = &cobra.Command{
|
||||
Use: "config",
|
||||
Short: "Set and get gh settings",
|
||||
Long: `Get and set key/value strings.
|
||||
Short: "Manage configuration for gh",
|
||||
Long: `Display or change configuration settings for gh.
|
||||
|
||||
Current respected settings:
|
||||
- git_protocol: https or ssh. Default is https.
|
||||
- git_protocol: "https" or "ssh". Default is "https".
|
||||
- editor: if unset, defaults to environment variables.
|
||||
`,
|
||||
}
|
||||
|
||||
var configGetCmd = &cobra.Command{
|
||||
Use: "get <key>",
|
||||
Short: "Prints the value of a given configuration key",
|
||||
Long: `Get the value for a given configuration key.
|
||||
|
||||
Examples:
|
||||
$ gh config get git_protocol
|
||||
https
|
||||
Short: "Print the value of a given configuration key",
|
||||
Example: `
|
||||
$ gh config get git_protocol
|
||||
https
|
||||
`,
|
||||
Args: cobra.ExactArgs(1),
|
||||
RunE: configGet,
|
||||
|
|
@ -45,11 +44,9 @@ Examples:
|
|||
|
||||
var configSetCmd = &cobra.Command{
|
||||
Use: "set <key> <value>",
|
||||
Short: "Updates configuration with the value of a given key",
|
||||
Long: `Update the configuration by setting a key to a value.
|
||||
|
||||
Examples:
|
||||
$ gh config set editor vim
|
||||
Short: "Update configuration with a value for the given key",
|
||||
Example: `
|
||||
$ gh config set editor vim
|
||||
`,
|
||||
Args: cobra.ExactArgs(2),
|
||||
RunE: configSet,
|
||||
|
|
|
|||
|
|
@ -132,6 +132,9 @@ func issueList(cmd *cobra.Command, args []string) error {
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if limit <= 0 {
|
||||
return fmt.Errorf("invalid limit: %v", limit)
|
||||
}
|
||||
|
||||
author, err := cmd.Flags().GetString("author")
|
||||
if err != nil {
|
||||
|
|
@ -245,11 +248,9 @@ func issueView(cmd *cobra.Command, args []string) error {
|
|||
if web {
|
||||
fmt.Fprintf(cmd.ErrOrStderr(), "Opening %s in your browser.\n", openURL)
|
||||
return utils.OpenInBrowser(openURL)
|
||||
} else {
|
||||
out := colorableOut(cmd)
|
||||
return printIssuePreview(out, issue)
|
||||
}
|
||||
|
||||
out := colorableOut(cmd)
|
||||
return printIssuePreview(out, issue)
|
||||
}
|
||||
|
||||
func issueStateTitleWithColor(state string) string {
|
||||
|
|
|
|||
|
|
@ -181,6 +181,18 @@ No issues match your search in OWNER/REPO
|
|||
eq(t, reqBody.Variables.Author, "foo")
|
||||
}
|
||||
|
||||
func TestIssueList_withInvalidLimitFlag(t *testing.T) {
|
||||
initBlankContext("", "OWNER/REPO", "master")
|
||||
http := initFakeHTTP()
|
||||
http.StubRepoResponse("OWNER", "REPO")
|
||||
|
||||
_, err := RunCommand("issue list --limit=0")
|
||||
|
||||
if err == nil || err.Error() != "invalid limit: 0" {
|
||||
t.Errorf("error running command `issue list`: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestIssueList_nullAssigneeLabels(t *testing.T) {
|
||||
initBlankContext("", "OWNER/REPO", "master")
|
||||
http := initFakeHTTP()
|
||||
|
|
|
|||
|
|
@ -195,6 +195,10 @@ func prList(cmd *cobra.Command, args []string) error {
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if limit <= 0 {
|
||||
return fmt.Errorf("invalid limit: %v", limit)
|
||||
}
|
||||
|
||||
state, err := cmd.Flags().GetString("state")
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
@ -328,10 +332,9 @@ func prView(cmd *cobra.Command, args []string) error {
|
|||
if web {
|
||||
fmt.Fprintf(cmd.ErrOrStderr(), "Opening %s in your browser.\n", openURL)
|
||||
return utils.OpenInBrowser(openURL)
|
||||
} else {
|
||||
out := colorableOut(cmd)
|
||||
return printPrPreview(out, pr)
|
||||
}
|
||||
out := colorableOut(cmd)
|
||||
return printPrPreview(out, pr)
|
||||
}
|
||||
|
||||
func prClose(cmd *cobra.Command, args []string) error {
|
||||
|
|
|
|||
|
|
@ -437,6 +437,17 @@ func TestPRList_filteringAssigneeLabels(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestPRList_withInvalidLimitFlag(t *testing.T) {
|
||||
initBlankContext("", "OWNER/REPO", "master")
|
||||
http := initFakeHTTP()
|
||||
http.StubRepoResponse("OWNER", "REPO")
|
||||
|
||||
_, err := RunCommand(`pr list --limit=0`)
|
||||
if err == nil && err.Error() != "invalid limit: 0" {
|
||||
t.Errorf("error running command `issue list`: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestPRView_Preview(t *testing.T) {
|
||||
tests := map[string]struct {
|
||||
ownerRepo string
|
||||
|
|
|
|||
|
|
@ -371,10 +371,8 @@ func titleBodySurvey(cmd *cobra.Command, issueState *issueMetadataState, apiClie
|
|||
issueState.Assignees = values.Assignees
|
||||
issueState.Labels = values.Labels
|
||||
issueState.Projects = values.Projects
|
||||
issueState.Milestones = []string{values.Milestone}
|
||||
|
||||
if len(issueState.Milestones) > 0 && issueState.Milestones[0] == noMilestone {
|
||||
issueState.Milestones = issueState.Milestones[0:0]
|
||||
if values.Milestone != "" && values.Milestone != noMilestone {
|
||||
issueState.Milestones = []string{values.Milestone}
|
||||
}
|
||||
|
||||
allowPreview = !issueState.HasMetadata()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue