Documentation
¶
Index ¶
- Variables
- func ExtractBaseBranch(content string) (string, bool)
- func ExtractBranchInfo(content string) (string, string, bool)
- func FilterMergeCommits(commitMessages []string) []string
- func FindSavedTemplates() ([]string, error)
- func FormatValidationErrors(errs []error, stackingCtx *StackingContext) string
- func GetDependentPRsWarning(stackingCtx *StackingContext) string
- func GetEditorCommand() (string, error)
- func GetStackingInfo(stackingCtx *StackingContext) string
- func IsEmptyCommitMessage(message string) bool
- func LoadSavedTemplate(path string) (string, error)
- func OpenEditor(templateContent string) (string, error)
- func ReadTemplateFrom(r io.Reader) (string, error)
- func RemoveSavedTemplate(path string) error
- func SaveTemplate(content string) (string, error)
- func ValidateFields(fields *TemplateFields, requireTestPlan bool, stackingCtx *StackingContext) []error
- func ValidateFieldsWithContext(fields *TemplateFields, requireTestPlan bool, stackingCtx *StackingContext) (bool, string)
- func WriteTemplateTo(w io.Writer, templateContent string) error
- type CommitAnalysis
- type CommitRepository
- type StackingContext
- type TemplateFields
- type TemplateGenerator
Constants ¶
This section is empty.
Variables ¶
var ( // ErrEditorCancelled is returned when user cancels editor ErrEditorCancelled = errors.New("editor cancelled: template unchanged or empty") // ErrNoEditor is returned when no editor is available ErrNoEditor = errors.New("no editor available: set $EDITOR environment variable") // ErrTemplateValidationFailed is returned when template validation fails ErrTemplateValidationFailed = errors.New("template validation failed") )
Functions ¶
func ExtractBaseBranch ¶
ExtractBaseBranch extracts only the base branch name from template header This is useful for continue mode where head branch is obtained from git Returns (baseBranch, found)
func ExtractBranchInfo ¶
ExtractBranchInfo extracts head and base branch names from template header Returns (headBranch, baseBranch, found)
func FilterMergeCommits ¶
FilterMergeCommits filters out merge commits from commit messages
func FindSavedTemplates ¶
FindSavedTemplates finds all saved template files in temp directory
func FormatValidationErrors ¶
func FormatValidationErrors(errs []error, stackingCtx *StackingContext) string
FormatValidationErrors formats validation errors for display with stacking context stackingCtx can be nil for non-stacking scenarios
func GetDependentPRsWarning ¶
func GetDependentPRsWarning(stackingCtx *StackingContext) string
GetDependentPRsWarning returns a formatted warning about dependent PRs
func GetEditorCommand ¶
GetEditorCommand returns the editor command to use
func GetStackingInfo ¶
func GetStackingInfo(stackingCtx *StackingContext) string
GetStackingInfo returns a formatted string with stacking information for display
func IsEmptyCommitMessage ¶
IsEmptyCommitMessage checks if a commit message is effectively empty
func LoadSavedTemplate ¶
LoadSavedTemplate loads a previously saved template
func OpenEditor ¶
OpenEditor opens the template in the user's $EDITOR
func ReadTemplateFrom ¶
ReadTemplateFrom reads template content from a reader (for testing)
func RemoveSavedTemplate ¶
RemoveSavedTemplate removes a saved template file
func SaveTemplate ¶
SaveTemplate saves template content to a file for --continue support
func ValidateFields ¶
func ValidateFields(fields *TemplateFields, requireTestPlan bool, stackingCtx *StackingContext) []error
ValidateFields validates that required template fields are filled stackingCtx can be nil for non-stacking scenarios
func ValidateFieldsWithContext ¶
func ValidateFieldsWithContext(fields *TemplateFields, requireTestPlan bool, stackingCtx *StackingContext) (bool, string)
ValidateFieldsWithContext is a convenience wrapper that combines validation and formatting
Types ¶
type CommitAnalysis ¶
type CommitAnalysis struct {
Title string // Suggested PR title
Summary string // Suggested PR summary/body
BaseBranch string // Base branch used for analysis
CommitCount int // Number of commits analyzed
CommitMessages []string // All commit messages
HasMergeCommits bool // Whether merge commits were found
}
CommitAnalysis represents the result of analyzing commits for template pre-filling
func AnalyzeCommitsForTemplate ¶
func AnalyzeCommitsForTemplate(repo CommitRepository, baseBranch, headBranch string) (*CommitAnalysis, error)
AnalyzeCommitsForTemplate analyzes commits between base and head branches to generate suggested content for PR template
type CommitRepository ¶
type CommitRepository interface {
GetCommitsBetween(base, head string) ([]git.CommitInfo, error)
}
CommitRepository defines the minimal interface needed for commit analysis. This allows for easier testing without depending on the full git.Repository.
type StackingContext ¶
type StackingContext struct {
IsStacking bool
BaseBranch string
ParentPR *github.PullRequest
DependentPRs []*github.PullRequest
CurrentBranch string
ShowDependents bool
}
StackingContext contains stacking information for template header
type TemplateFields ¶
type TemplateFields struct {
Title string
Summary string
TestPlan string
Reviewers []string // List of @usernames or @org/team
Ref []string // Linear issue references
Draft bool // Whether PR should be created as draft
BaseBranch string // Read-only display of base branch
}
TemplateFields contains all the structured data from the template
func ParseTemplate ¶
func ParseTemplate(content string) (*TemplateFields, error)
ParseTemplate parses the template content into structured fields
type TemplateGenerator ¶
type TemplateGenerator struct {
// contains filtered or unexported fields
}
TemplateGenerator generates PR templates with stacking context
func NewTemplateGenerator ¶
func NewTemplateGenerator(stackingCtx *StackingContext, analysis *CommitAnalysis, reviewers []string, linearEnabled bool, defaultDraft bool) *TemplateGenerator
NewTemplateGenerator creates a new template generator
func (*TemplateGenerator) Generate ¶
func (g *TemplateGenerator) Generate() string
Generate creates the template content