Documentation
¶
Overview ¶
Package rebase provides types and parsing for declarative rebase specifications. This enables AI agents to describe rebase operations without interactive prompts.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GenerateTodoFromEntries ¶
GenerateTodoFromEntries generates a todo file from entries.
Types ¶
type Action ¶
type Action struct {
// Action is the type of operation (pick, squash, drop, etc.).
Action ActionType `json:"action"`
// Commit is the commit hash (required for all actions except exec).
Commit string `json:"commit,omitempty"`
// Message is the commit message for reword/squash operations.
// If empty during squash, git will prompt for message concatenation.
Message string `json:"message,omitempty"`
// Command is the shell command for exec actions.
Command string `json:"command,omitempty"`
}
Action represents a single rebase operation.
type ActionType ¶
type ActionType string
ActionType represents a rebase action (pick, squash, etc.).
const ( ActionPick ActionType = "pick" ActionReword ActionType = "reword" ActionEdit ActionType = "edit" ActionSquash ActionType = "squash" ActionFixup ActionType = "fixup" ActionDrop ActionType = "drop" ActionExec ActionType = "exec" )
func (ActionType) ShortForm ¶
func (a ActionType) ShortForm() string
ShortForm returns the single-letter abbreviation for the action.
func (ActionType) Valid ¶
func (a ActionType) Valid() bool
Valid returns true if the action type is recognized.
type Spec ¶
type Spec struct {
// Actions is the ordered list of rebase operations.
Actions []Action `json:"actions"`
}
Spec is a complete rebase specification.
func ParseCLISpec ¶
ParseCLISpec parses the CLI shorthand syntax.
Supported formats:
- "abc123,def456" - pick all commits
- "pick:abc123,squash:def456" - explicit actions
- "reword:abc123:New message" - action with message
- "exec:make test" - exec command
func (*Spec) ToTodoFile ¶
ToTodoFile generates a git rebase todo file from the spec. The output format matches what git expects.
func (*Spec) ToTodoFileWithMessages ¶
ToTodoFileWithMessages generates a todo file with message handling. For reword actions with messages, it uses fixup -C to set the message. This is a more advanced format for message control.
func (*Spec) ValidateAgainstCommits ¶
ValidateAgainstCommits checks that the spec actions reference valid commits from the original todo file.
type TodoEntry ¶
type TodoEntry struct {
// Action is the rebase action (pick, squash, etc.).
Action ActionType
// Commit is the commit hash.
Commit string
// Subject is the commit subject line.
Subject string
}
TodoEntry represents a single entry in a git rebase todo file.
func ParseTodoFile ¶
ParseTodoFile parses a git rebase todo file into entries. Ignores comments (lines starting with #) and empty lines.