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 <xiaolunwen@gmail.com>
Reviewed-by: Norwin <noerw@noreply.gitea.io>
This commit is contained in:
6543 2020-09-23 10:30:29 +00:00
parent d7f429d246
commit 3652f1dcb2
2 changed files with 9 additions and 6 deletions

View File

@ -10,7 +10,6 @@ import (
"strconv" "strconv"
"code.gitea.io/sdk/gitea" "code.gitea.io/sdk/gitea"
"github.com/charmbracelet/glamour" "github.com/charmbracelet/glamour"
"github.com/urfave/cli/v2" "github.com/urfave/cli/v2"
) )
@ -59,8 +58,9 @@ func runIssueDetail(ctx *cli.Context, index string) error {
return err 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.Title,
issue.State,
issue.Poster.UserName, issue.Poster.UserName,
issue.Created.Format("2006-01-02 15:04:05"), issue.Created.Format("2006-01-02 15:04:05"),
issue.Body, issue.Body,

View File

@ -13,6 +13,7 @@ import (
local_git "code.gitea.io/tea/modules/git" local_git "code.gitea.io/tea/modules/git"
"code.gitea.io/sdk/gitea" "code.gitea.io/sdk/gitea"
"github.com/charmbracelet/glamour"
"github.com/go-git/go-git/v5" "github.com/go-git/go-git/v5"
git_config "github.com/go-git/go-git/v5/config" git_config "github.com/go-git/go-git/v5/config"
"github.com/urfave/cli/v2" "github.com/urfave/cli/v2"
@ -398,14 +399,16 @@ func runPullsCreate(ctx *cli.Context) error {
log.Fatal(err) 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.Title,
pr.State,
pr.Poster.UserName, pr.Poster.UserName,
pr.Created.Format("2006-01-02 15:04:05"), pr.Created.Format("2006-01-02 15:04:05"),
pr.Body,
) )
if len(pr.Body) != 0 { out, err := glamour.Render(in, getGlamourTheme())
fmt.Printf("\n%s\n", pr.Body) fmt.Print(out)
}
fmt.Println(pr.HTMLURL) fmt.Println(pr.HTMLURL)
return nil return nil
} }