cmd

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2026 License: MIT Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// BranchFieldName is the current name for the branch tracking field.
	BranchFieldName = "Branch"

	// LegacyReleaseFieldName is the legacy name for the branch tracking field.
	// Used for backward compatibility with existing projects.
	LegacyReleaseFieldName = "Release"
)

Field name constants for project fields. The Branch field was previously named Release. For backward compatibility, we check for Branch first and fall back to Release for existing projects.

Variables

View Source
var ErrRepoRootProtected = errors.New("cannot write config to repository root during tests")

ErrRepoRootProtected is returned when attempting to write config to repo root during tests

Functions

func Execute

func Execute() error

func NewRootCommand

func NewRootCommand() *cobra.Command

func ResolveBranchFieldName added in v0.13.2

func ResolveBranchFieldName(fields []api.ProjectField) string

ResolveBranchFieldName returns the appropriate field name for branch tracking based on available project fields. It checks for "Branch" first and falls back to "Release" for backward compatibility with existing projects.

func ResolveBranchFieldNameFromFieldValues added in v0.13.2

func ResolveBranchFieldNameFromFieldValues(fieldValues []api.FieldValue) string

ResolveBranchFieldNameFromFieldValues returns the appropriate field name for branch tracking based on field values. This is useful when you have FieldValue slices instead of ProjectField slices.

func SetRepoRootProtection added in v0.7.5

func SetRepoRootProtection(enabled bool)

SetRepoRootProtection enables or disables repo root write protection. This should be called by test setup to prevent accidental config writes.

func SyncActiveBranches added in v0.11.0

func SyncActiveBranches(client branchClient, owner, repo string) ([]branchActiveEntry, error)

SyncActiveBranches queries open branch issues and returns active branch entries

Types

type CommentJSON

type CommentJSON struct {
	Author    string `json:"author"`
	Body      string `json:"body"`
	CreatedAt string `json:"createdAt"`
}

CommentJSON represents a comment in JSON output

type CommitComment added in v0.4.3

type CommitComment struct {
	Author string    `json:"author"`
	Body   string    `json:"body"`
	Date   time.Time `json:"date"`
}

CommitComment represents a GitHub comment on a commit

type CommitInfo added in v0.4.0

type CommitInfo struct {
	Hash       string           `json:"hash"`
	Author     string           `json:"author"`
	Date       time.Time        `json:"date"`
	Subject    string           `json:"subject"`
	Body       string           `json:"body,omitempty"`
	ChangeType string           `json:"change_type"`
	References []IssueReference `json:"references,omitempty"`
	Insertions int              `json:"insertions,omitempty"`
	Deletions  int              `json:"deletions,omitempty"`
	Comments   []CommitComment  `json:"comments,omitempty"`
	Files      []string         `json:"files,omitempty"`
	FileCount  int              `json:"file_count,omitempty"`
}

CommitInfo represents parsed information from a git commit

type ConfigFile

type ConfigFile struct {
	Version      string                  `yaml:"version,omitempty" json:"version,omitempty"`
	Project      ProjectConfig           `yaml:"project" json:"project"`
	Repositories []string                `yaml:"repositories" json:"repositories"`
	Defaults     DefaultsConfig          `yaml:"defaults" json:"defaults"`
	Fields       map[string]FieldMapping `yaml:"fields" json:"fields"`
	Triage       map[string]TriageRule   `yaml:"triage,omitempty" json:"triage,omitempty"`
}

ConfigFile represents the .gh-pmu.yml file structure.

type ConfigFileWithMetadata

type ConfigFileWithMetadata struct {
	Version      string                  `yaml:"version,omitempty" json:"version,omitempty"`
	Project      ProjectConfig           `yaml:"project" json:"project"`
	Repositories []string                `yaml:"repositories" json:"repositories"`
	Framework    string                  `yaml:"framework,omitempty" json:"framework,omitempty"`
	Defaults     DefaultsConfig          `yaml:"defaults" json:"defaults"`
	Fields       map[string]FieldMapping `yaml:"fields" json:"fields"`
	Triage       map[string]TriageRule   `yaml:"triage,omitempty" json:"triage,omitempty"`
	Acceptance   *config.Acceptance      `yaml:"acceptance,omitempty" json:"acceptance,omitempty"`
	Metadata     MetadataSection         `yaml:"metadata" json:"metadata"`
}

ConfigFileWithMetadata extends ConfigFile with metadata section.

type DefaultsConfig

type DefaultsConfig struct {
	Priority string   `yaml:"priority" json:"priority"`
	Status   string   `yaml:"status" json:"status"`
	Labels   []string `yaml:"labels,omitempty" json:"labels,omitempty"`
}

DefaultsConfig represents default values for new items.

type FieldMapping

type FieldMapping struct {
	Field  string            `yaml:"field" json:"field"`
	Values map[string]string `yaml:"values" json:"values"`
}

FieldMapping represents a field alias mapping.

type FieldMetadata

type FieldMetadata struct {
	ID       string
	Name     string
	DataType string
	Options  []OptionMetadata
}

FieldMetadata holds cached field information.

type FilterInput added in v0.5.2

type FilterInput struct {
	Number    int     `json:"number"`
	Title     string  `json:"title"`
	State     string  `json:"state"`
	URL       string  `json:"url"`
	Body      string  `json:"body"`
	Labels    []Label `json:"labels"`
	Assignees []User  `json:"assignees"`
}

FilterInput represents the expected JSON input format from gh issue list

type InitConfig

type InitConfig struct {
	ProjectName   string
	ProjectOwner  string
	ProjectNumber int
	Repositories  []string
	Framework     string
}

InitConfig holds the configuration gathered during init.

type IssueReference added in v0.4.0

type IssueReference struct {
	Number int    `json:"number"`
	Owner  string `json:"owner,omitempty"`
	Repo   string `json:"repo,omitempty"`
	Type   string `json:"type"` // fixes, closes, related
	URL    string `json:"url"`
}

IssueReference represents a parsed issue/PR reference

type JSONItem

type JSONItem struct {
	Number      int               `json:"number"`
	Title       string            `json:"title"`
	State       string            `json:"state"`
	URL         string            `json:"url"`
	Repository  string            `json:"repository"`
	Assignees   []string          `json:"assignees"`
	FieldValues map[string]string `json:"fieldValues"`
}

JSONItem represents an item in JSON output

type JSONOutput

type JSONOutput struct {
	Items []JSONItem `json:"items"`
}

JSONOutput represents the JSON output structure

type Label added in v0.5.2

type Label struct {
	Name string `json:"name"`
}

Label represents a label in the input JSON

type MetadataField

type MetadataField struct {
	Name     string                `yaml:"name" json:"name"`
	ID       string                `yaml:"id" json:"id"`
	DataType string                `yaml:"data_type" json:"data_type"`
	Options  []MetadataFieldOption `yaml:"options,omitempty" json:"options,omitempty"`
}

MetadataField represents a field in the metadata section.

type MetadataFieldOption

type MetadataFieldOption struct {
	Name string `yaml:"name" json:"name"`
	ID   string `yaml:"id" json:"id"`
}

MetadataFieldOption represents a field option.

type MetadataProject

type MetadataProject struct {
	ID string `yaml:"id" json:"id"`
}

MetadataProject holds the project ID.

type MetadataSection

type MetadataSection struct {
	Project MetadataProject `yaml:"project" json:"project"`
	Fields  []MetadataField `yaml:"fields" json:"fields"`
}

MetadataSection represents the metadata section in config file.

type OptionMetadata

type OptionMetadata struct {
	ID   string
	Name string
}

OptionMetadata holds option information for single-select fields.

type ParentIssueJSON

type ParentIssueJSON struct {
	Number int    `json:"number"`
	Title  string `json:"title"`
	URL    string `json:"url"`
}

ParentIssueJSON represents the parent issue in JSON output

type ProjectConfig

type ProjectConfig struct {
	Name   string `yaml:"name,omitempty" json:"name,omitempty"`
	Number int    `yaml:"number" json:"number"`
	Owner  string `yaml:"owner" json:"owner"`
}

ProjectConfig represents the project section of config.

type ProjectMetadata

type ProjectMetadata struct {
	ProjectID string
	Fields    []FieldMetadata
}

ProjectMetadata holds cached project information from GitHub API.

type ProjectValidator

type ProjectValidator interface {
	GetProject(owner string, number int) (interface{}, error)
}

ProjectValidator is the interface for validating projects.

type SubIssueJSON

type SubIssueJSON struct {
	Number int    `json:"number"`
	Title  string `json:"title"`
	State  string `json:"state"`
	URL    string `json:"url"`
}

SubIssueJSON represents a sub-issue in JSON output

type SubListIssueJSON

type SubListIssueJSON struct {
	Number int    `json:"number"`
	Title  string `json:"title"`
	State  string `json:"state"`
	URL    string `json:"url"`
}

type SubListItem

type SubListItem struct {
	Number     int    `json:"number"`
	Title      string `json:"title"`
	State      string `json:"state"`
	URL        string `json:"url"`
	Repository string `json:"repository"` // owner/repo format
}

type SubListJSONExtended

type SubListJSONExtended struct {
	Issue    SubListIssueJSON   `json:"issue"`
	Parent   *SubListParentJSON `json:"parent,omitempty"`
	Children []SubListItem      `json:"children,omitempty"`
	Siblings []SubListItem      `json:"siblings,omitempty"`
	Summary  SubListSummary     `json:"summary"`
}

SubListJSONExtended represents extended JSON output for sub list with relation support

type SubListJSONOutput

type SubListJSONOutput struct {
	Parent    SubListParent  `json:"parent"`
	SubIssues []SubListItem  `json:"subIssues"`
	Summary   SubListSummary `json:"summary"`
}

SubListJSONOutput represents the JSON output for sub list command

type SubListParent

type SubListParent struct {
	Number int    `json:"number"`
	Title  string `json:"title"`
}

type SubListParentJSON

type SubListParentJSON struct {
	Number int    `json:"number"`
	Title  string `json:"title"`
	State  string `json:"state"`
	URL    string `json:"url"`
}

type SubListResult

type SubListResult struct {
	Issue    *api.Issue
	Parent   *api.Issue
	Children []api.SubIssue
	Siblings []api.SubIssue
}

SubListResult holds all the data for sub list output

type SubListSummary

type SubListSummary struct {
	Total  int `json:"total"`
	Open   int `json:"open"`
	Closed int `json:"closed"`
}

type SubProgressJSON

type SubProgressJSON struct {
	Total      int `json:"total"`
	Completed  int `json:"completed"`
	Percentage int `json:"percentage"`
}

SubProgressJSON represents sub-issue progress in JSON output

type TriageApply

type TriageApply struct {
	Labels []string          `yaml:"labels,omitempty" json:"labels,omitempty"`
	Fields map[string]string `yaml:"fields,omitempty" json:"fields,omitempty"`
}

TriageApply represents what to apply when a triage rule matches.

type TriageRule

type TriageRule struct {
	Query       string          `yaml:"query" json:"query"`
	Apply       TriageApply     `yaml:"apply" json:"apply"`
	Interactive map[string]bool `yaml:"interactive,omitempty" json:"interactive,omitempty"`
}

TriageRule represents a single triage rule configuration.

type User added in v0.5.2

type User struct {
	Login string `json:"login"`
}

User represents a user/assignee in the input JSON

type ValidationError added in v0.8.0

type ValidationError struct {
	IssueNumber int
	Message     string
	Suggestion  string
}

ValidationError represents a validation failure with actionable message

func (*ValidationError) Error added in v0.8.0

func (e *ValidationError) Error() string

type ValidationErrors added in v0.8.0

type ValidationErrors struct {
	Errors []ValidationError
}

ValidationErrors collects multiple validation failures

func (*ValidationErrors) Add added in v0.8.0

func (e *ValidationErrors) Add(err ValidationError)

func (*ValidationErrors) Error added in v0.8.0

func (e *ValidationErrors) Error() string

func (*ValidationErrors) HasErrors added in v0.8.0

func (e *ValidationErrors) HasErrors() bool

type ViewJSONOutput

type ViewJSONOutput struct {
	Number      int               `json:"number"`
	Title       string            `json:"title"`
	State       string            `json:"state"`
	Body        string            `json:"body"`
	URL         string            `json:"url"`
	Author      string            `json:"author"`
	Assignees   []string          `json:"assignees"`
	Labels      []string          `json:"labels"`
	Milestone   string            `json:"milestone,omitempty"`
	FieldValues map[string]string `json:"fieldValues"`
	SubIssues   []SubIssueJSON    `json:"subIssues,omitempty"`
	SubProgress *SubProgressJSON  `json:"subProgress,omitempty"`
	ParentIssue *ParentIssueJSON  `json:"parentIssue,omitempty"`
	Comments    []CommentJSON     `json:"comments,omitempty"`
}

ViewJSONOutput represents the JSON output for view command

Jump to

Keyboard shortcuts

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