Merge pull request #165 from github/appropriate-context-and-feedback
Add context and feedback output to commands
This commit is contained in:
commit
c6775eae6c
6 changed files with 36 additions and 4 deletions
|
|
@ -104,6 +104,8 @@ func issueList(cmd *cobra.Command, args []string) error {
|
|||
return err
|
||||
}
|
||||
|
||||
fmt.Fprintf(colorableErr(cmd), "\nIssues for %s/%s\n\n", baseRepo.RepoOwner(), baseRepo.RepoName())
|
||||
|
||||
issues, err := api.IssueList(apiClient, baseRepo, state, labels, assignee, limit)
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
@ -242,6 +244,8 @@ func issueCreate(cmd *cobra.Command, args []string) error {
|
|||
return err
|
||||
}
|
||||
|
||||
fmt.Fprintf(colorableErr(cmd), "\nCreating issue in %s/%s\n\n", baseRepo.RepoOwner(), baseRepo.RepoName())
|
||||
|
||||
var templateFiles []string
|
||||
if rootDir, err := git.ToplevelDir(); err == nil {
|
||||
// TODO: figure out how to stub this in tests
|
||||
|
|
|
|||
|
|
@ -133,7 +133,11 @@ func TestIssueList_withFlags(t *testing.T) {
|
|||
}
|
||||
|
||||
eq(t, output.String(), "")
|
||||
eq(t, output.Stderr(), "No issues match your search\n")
|
||||
eq(t, output.Stderr(), `
|
||||
Issues for OWNER/REPO
|
||||
|
||||
No issues match your search
|
||||
`)
|
||||
|
||||
bodyBytes, _ := ioutil.ReadAll(http.Requests[0].Body)
|
||||
reqBody := struct {
|
||||
|
|
|
|||
|
|
@ -137,6 +137,8 @@ func prList(cmd *cobra.Command, args []string) error {
|
|||
return err
|
||||
}
|
||||
|
||||
fmt.Fprintf(colorableErr(cmd), "\nPull requests for %s/%s\n\n", baseRepo.RepoOwner(), baseRepo.RepoName())
|
||||
|
||||
limit, err := cmd.Flags().GetInt("limit")
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
|
|||
|
|
@ -46,6 +46,16 @@ func prCreate(cmd *cobra.Command, _ []string) error {
|
|||
return err
|
||||
}
|
||||
|
||||
target, err := cmd.Flags().GetString("base")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if target == "" {
|
||||
target = "master"
|
||||
}
|
||||
|
||||
fmt.Fprintf(colorableErr(cmd), "\nCreating pull request for %s into %s in %s/%s\n\n", utils.Cyan(head), utils.Cyan(target), repo.RepoOwner(), repo.RepoName())
|
||||
|
||||
if err = git.Push(remote, fmt.Sprintf("HEAD:%s", head)); err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -116,7 +116,11 @@ func TestPRCreate_web(t *testing.T) {
|
|||
eq(t, err, nil)
|
||||
|
||||
eq(t, output.String(), "")
|
||||
eq(t, output.Stderr(), "Opening https://github.com/OWNER/REPO/pull/feature in your browser.\n")
|
||||
eq(t, output.Stderr(), `
|
||||
Creating pull request for feature into master in OWNER/REPO
|
||||
|
||||
Opening https://github.com/OWNER/REPO/pull/feature in your browser.
|
||||
`)
|
||||
|
||||
eq(t, len(ranCommands), 3)
|
||||
eq(t, strings.Join(ranCommands[1], " "), "git push --set-upstream origin HEAD:feature")
|
||||
|
|
@ -155,5 +159,9 @@ func TestPRCreate_ReportsUncommittedChanges(t *testing.T) {
|
|||
eq(t, err, nil)
|
||||
|
||||
eq(t, output.String(), "https://github.com/OWNER/REPO/pull/12\n")
|
||||
eq(t, output.Stderr(), "Warning: 1 uncommitted change\n")
|
||||
eq(t, output.Stderr(), `Warning: 1 uncommitted change
|
||||
|
||||
Creating pull request for feature into master in OWNER/REPO
|
||||
|
||||
`)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -183,7 +183,11 @@ func TestPRList_filtering(t *testing.T) {
|
|||
}
|
||||
|
||||
eq(t, output.String(), "")
|
||||
eq(t, output.Stderr(), "No pull requests match your search\n")
|
||||
eq(t, output.Stderr(), `
|
||||
Pull requests for OWNER/REPO
|
||||
|
||||
No pull requests match your search
|
||||
`)
|
||||
|
||||
bodyBytes, _ := ioutil.ReadAll(http.Requests[0].Body)
|
||||
reqBody := struct {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue