Merge remote-tracking branch 'cli/master' into pr-count
This commit is contained in:
commit
1a485ddd2e
19 changed files with 158 additions and 75 deletions
|
|
@ -220,8 +220,7 @@ func issueView(cmd *cobra.Command, args []string) error {
|
|||
|
||||
if preview {
|
||||
out := colorableOut(cmd)
|
||||
printIssuePreview(out, issue)
|
||||
return nil
|
||||
return printIssuePreview(out, issue)
|
||||
} else {
|
||||
fmt.Fprintf(cmd.ErrOrStderr(), "Opening %s in your browser.\n", openURL)
|
||||
return utils.OpenInBrowser(openURL)
|
||||
|
|
@ -229,7 +228,7 @@ func issueView(cmd *cobra.Command, args []string) error {
|
|||
|
||||
}
|
||||
|
||||
func printIssuePreview(out io.Writer, issue *api.Issue) {
|
||||
func printIssuePreview(out io.Writer, issue *api.Issue) error {
|
||||
coloredLabels := labelList(*issue)
|
||||
if coloredLabels != "" {
|
||||
coloredLabels = utils.Gray(fmt.Sprintf("(%s)", coloredLabels))
|
||||
|
|
@ -242,12 +241,19 @@ func printIssuePreview(out io.Writer, issue *api.Issue) {
|
|||
utils.Pluralize(issue.Comments.TotalCount, "comment"),
|
||||
coloredLabels,
|
||||
)))
|
||||
|
||||
if issue.Body != "" {
|
||||
fmt.Fprintln(out)
|
||||
fmt.Fprintln(out, utils.RenderMarkdown(issue.Body))
|
||||
fmt.Fprintln(out)
|
||||
fmt.Fprintln(out)
|
||||
md, err := utils.RenderMarkdown(issue.Body)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
fmt.Fprintln(out, md)
|
||||
fmt.Fprintln(out)
|
||||
}
|
||||
|
||||
fmt.Fprintf(out, utils.Gray("View this issue on GitHub: %s\n"), issue.URL)
|
||||
return nil
|
||||
}
|
||||
|
||||
var issueURLRE = regexp.MustCompile(`^https://github\.com/([^/]+)/([^/]+)/issues/(\d+)`)
|
||||
|
|
|
|||
|
|
@ -193,7 +193,7 @@ func prList(cmd *cobra.Command, args []string) error {
|
|||
prCount := prsData.TotalCount
|
||||
|
||||
title := utils.GetTitle(cmd, "pull request", limit, prCount, baseRepo)
|
||||
fmt.Fprintf(colorableErr(cmd), title)
|
||||
fmt.Fprintf(colorableErr(cmd), title) // Send to stderr because otherwise when piping this command it would seem like the "no open prs" message is actually a pr
|
||||
|
||||
table := utils.NewTablePrinter(cmd.OutOrStdout())
|
||||
for _, pr := range prs {
|
||||
|
|
@ -279,15 +279,14 @@ func prView(cmd *cobra.Command, args []string) error {
|
|||
|
||||
if preview {
|
||||
out := colorableOut(cmd)
|
||||
printPrPreview(out, pr)
|
||||
return nil
|
||||
return printPrPreview(out, pr)
|
||||
} else {
|
||||
fmt.Fprintf(cmd.ErrOrStderr(), "Opening %s in your browser.\n", openURL)
|
||||
return utils.OpenInBrowser(openURL)
|
||||
}
|
||||
}
|
||||
|
||||
func printPrPreview(out io.Writer, pr *api.PullRequest) {
|
||||
func printPrPreview(out io.Writer, pr *api.PullRequest) error {
|
||||
fmt.Fprintln(out, utils.Bold(pr.Title))
|
||||
fmt.Fprintln(out, utils.Gray(fmt.Sprintf(
|
||||
"%s wants to merge %s into %s from %s",
|
||||
|
|
@ -298,10 +297,16 @@ func printPrPreview(out io.Writer, pr *api.PullRequest) {
|
|||
)))
|
||||
if pr.Body != "" {
|
||||
fmt.Fprintln(out)
|
||||
fmt.Fprintln(out, utils.RenderMarkdown(pr.Body))
|
||||
md, err := utils.RenderMarkdown(pr.Body)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
fmt.Fprintln(out, md)
|
||||
fmt.Fprintln(out)
|
||||
}
|
||||
|
||||
fmt.Fprintf(out, utils.Gray("View this pull request on GitHub: %s\n"), pr.URL)
|
||||
return nil
|
||||
}
|
||||
|
||||
var prURLRE = regexp.MustCompile(`^https://github\.com/([^/]+)/([^/]+)/pull/(\d+)`)
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import (
|
|||
"io"
|
||||
"os"
|
||||
"regexp"
|
||||
"runtime/debug"
|
||||
"strings"
|
||||
|
||||
"github.com/cli/cli/api"
|
||||
|
|
@ -15,16 +16,26 @@ import (
|
|||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
// Version is dynamically set at build time in the Makefile
|
||||
// Version is dynamically set by the toolchain or overriden by the Makefile.
|
||||
var Version = "DEV"
|
||||
|
||||
// BuildDate is dynamically set at build time in the Makefile
|
||||
var BuildDate = "YYYY-MM-DD"
|
||||
// BuildDate is dynamically set at build time in the Makefile.
|
||||
var BuildDate = "" // YYYY-MM-DD
|
||||
|
||||
var versionOutput = ""
|
||||
|
||||
func init() {
|
||||
RootCmd.Version = fmt.Sprintf("%s (%s)", strings.TrimPrefix(Version, "v"), BuildDate)
|
||||
if Version == "DEV" {
|
||||
if info, ok := debug.ReadBuildInfo(); ok && info.Main.Version != "(devel)" {
|
||||
Version = info.Main.Version
|
||||
}
|
||||
}
|
||||
Version = strings.TrimPrefix(Version, "v")
|
||||
if BuildDate == "" {
|
||||
RootCmd.Version = Version
|
||||
} else {
|
||||
RootCmd.Version = fmt.Sprintf("%s (%s)", Version, BuildDate)
|
||||
}
|
||||
versionOutput = fmt.Sprintf("gh version %s\n%s\n", RootCmd.Version, changelogURL(Version))
|
||||
RootCmd.AddCommand(versionCmd)
|
||||
RootCmd.SetVersionTemplate(versionOutput)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue