From 3652f1dcb286e6f535e0a4868d33aa3d329a5121 Mon Sep 17 00:00:00 2001 From: 6543 <6543@noreply.gitea.io> Date: Wed, 23 Sep 2020 10:30:29 +0000 Subject: [PATCH] Issues/Pulls: Details show State (#196) Pull: Render output & add State to issues Co-authored-by: 6543 <6543@obermui.de> Reviewed-on: https://gitea.com/gitea/tea/pulls/196 Reviewed-by: Lunny Xiao Reviewed-by: Norwin --- cmd/issues.go | 4 ++-- cmd/pulls.go | 11 +++++++---- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/cmd/issues.go b/cmd/issues.go index fd31d6a..848bd4f 100644 --- a/cmd/issues.go +++ b/cmd/issues.go @@ -10,7 +10,6 @@ import ( "strconv" "code.gitea.io/sdk/gitea" - "github.com/charmbracelet/glamour" "github.com/urfave/cli/v2" ) @@ -59,8 +58,9 @@ func runIssueDetail(ctx *cli.Context, index string) error { return err } - in := fmt.Sprintf("# #%d %s\n%s created %s\n\n%s\n", issue.Index, + in := fmt.Sprintf("# #%d %s (%s)\n%s created %s\n\n%s\n", issue.Index, issue.Title, + issue.State, issue.Poster.UserName, issue.Created.Format("2006-01-02 15:04:05"), issue.Body, diff --git a/cmd/pulls.go b/cmd/pulls.go index 6cbb699..c9afcb4 100644 --- a/cmd/pulls.go +++ b/cmd/pulls.go @@ -13,6 +13,7 @@ import ( local_git "code.gitea.io/tea/modules/git" "code.gitea.io/sdk/gitea" + "github.com/charmbracelet/glamour" "github.com/go-git/go-git/v5" git_config "github.com/go-git/go-git/v5/config" "github.com/urfave/cli/v2" @@ -398,14 +399,16 @@ func runPullsCreate(ctx *cli.Context) error { log.Fatal(err) } - fmt.Printf("#%d %s\n%s created %s\n", pr.Index, + in := fmt.Sprintf("# #%d %s (%s)\n%s created %s\n\n%s\n", pr.Index, pr.Title, + pr.State, pr.Poster.UserName, pr.Created.Format("2006-01-02 15:04:05"), + pr.Body, ) - if len(pr.Body) != 0 { - fmt.Printf("\n%s\n", pr.Body) - } + out, err := glamour.Render(in, getGlamourTheme()) + fmt.Print(out) + fmt.Println(pr.HTMLURL) return nil }