changes

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: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Command = &cli.Command{
		Name:      "changes",
		UsageText: "changes [options]",
		Usage:     "List available changes to interact with",
		Flags:     flagset.Extract(config),
		Action: func(ctx *cli.Context) error {
			gerritAPI := common.GerritAPI(ctx.Context)
			projectID := common.Project(ctx.Context)
			writer := common.TableWriter(ctx.Context)

			if config.Query == "" {
				config.Query = "status:open -is:wip"
				if !config.AllProjects {
					config.Query = config.Query + " project:" + string(projectID)
				}
			}

			log := zaputil.Extract(ctx.Context)

			log.Debug("query changes", zap.String("q", config.Query))
			changes, err := gerritAPI.Client.QueryChanges(ctx.Context, config.Query)
			if err != nil {
				return err
			}

			sort.Slice(changes, func(i, j int) bool {
				return changes[j].Updated.Time().Before(changes[i].Updated.Time())
			})

			for _, change := range changes {
				common.WriteRow(writer, &Change{
					ChangeID: strconv.Itoa(change.ChangeNumber),
					Subject:  change.Subject,
					Updated:  time.Time(change.Updated).Local().Format(time.RFC1123),
				})
			}

			return nil
		},
		HideHelpCommand: true,
	}
)

Functions

This section is empty.

Types

type Change

type Change struct {
	ChangeID string `json:"change_id"`
	Subject  string
	Updated  string
}

type Config

type Config struct {
	AllProjects bool   `json:"all_projects" alias:"A" usage:"ignore the current project and query accross all projects."`
	Query       string `json:"query"        alias:"q" usage:"provide your own custom query to use."`
}

Jump to

Keyboard shortcuts

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