show

package
v0.0.0-...-2b89969 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 18, 2021 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Command = &cli.Command{
		Name:      "show",
		Usage:     "Show additional details about a given review",
		UsageText: "show [options] <changeID>",
		Flags:     flagset.Extract(showConfig),
		Action: func(ctx *cli.Context) error {
			gerritAPI := common.GerritAPI(ctx.Context)

			accountInfo := make(map[int64]gerrit.AccountInfo)
			getAccountInfo := func(accountID int64) (*gerrit.AccountInfo, error) {
				info, ok := accountInfo[accountID]
				if !ok {
					info, err := gerritAPI.Client.GetAccountInfo(ctx.Context, strconv.FormatInt(accountID, 10))
					if err != nil {
						return nil, err
					}
					accountInfo[accountID] = info
				}

				return &info, nil
			}

			changeID := ctx.Args().Get(0)
			info, err := gerritAPI.Client.GetChangeDetail(ctx.Context, changeID, gerrit.QueryChangesOpt{
				Fields: []string{"CURRENT_REVISION"},
			})
			if err != nil {
				return err
			}

			template, err := template.New("report").
				Funcs(map[string]interface{}{
					"baseURL": func() string {
						return gerritAPI.BaseURL
					},
					"getAccountInfo": getAccountInfo,
					"formatTimeStamp": func(t gerrit.TimeStamp) string {
						return t.Time().Local().Format(time.RFC1123)
					},
				}).
				Parse(report)

			if err != nil {
				return err
			}

			return template.Execute(ctx.App.Writer, info)
		},
		HideHelpCommand: true,
	}
)

Functions

This section is empty.

Types

type Config

type Config struct{}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL