Documentation
¶
Overview ¶
Package git wraps the local git CLI for nook's git pane.
Surfaces:
- Status: `git status --porcelain=v1 --branch -z` parsed into entries.
- Diff: `git diff -- <path>` and `git diff --cached -- <path>` for inspection.
- Stage/unstage: `git add` / `git reset HEAD -- <path>`.
- Commit: `git commit -m <msg>` (signed if config gpg.sign or commit.gpgsign set).
The Pane renders a two-column status (staged + unstaged), a commit-message editor, and emits messages so the host can route to a diff buffer.
Index ¶
- func Commit(ctx context.Context, root, msg string) (string, error)
- func Diff(ctx context.Context, root, path string, staged bool) (string, error)
- func Stage(ctx context.Context, root, path string) error
- func Unstage(ctx context.Context, root, path string) error
- type CancelMsg
- type CommitMsg
- type DiffMsg
- type Entry
- type Pane
- func (p Pane) Blur() Pane
- func (p Pane) CommitMessage() string
- func (p Pane) Editing() bool
- func (p Pane) Focus() Pane
- func (p Pane) Focused() bool
- func (p Pane) Selected() (Entry, bool)
- func (p Pane) SetStatus(s Status) Pane
- func (p Pane) Update(msg tea.Msg) (Pane, tea.Cmd)
- func (p Pane) View() string
- func (p Pane) WithSize(w, h int) Pane
- type StagedMsg
- type Status
- type StatusCode
- type StatusMsg
- type UnstagedMsg
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Entry ¶
type Entry struct {
Index StatusCode // staged side (X)
WorkTree StatusCode // unstaged side (Y)
Path string
OrigPath string // populated on rename
}
Entry is one row in `git status --porcelain`.
type Pane ¶
type Pane struct {
// contains filtered or unexported fields
}
Pane is the git status UI.
func (Pane) CommitMessage ¶
CommitMessage returns the current draft message.
func (Pane) Update ¶
Update routes a key event. Returns one of: nil, CancelMsg, or a tea.Cmd the host should execute (Stage/Unstage/Commit/Diff).
Keymap (when not editing):
j / down move cursor k / up move cursor enter request diff s stage u unstage c enter commit-message editor esc emit CancelMsg
Keymap (when editing):
ctrl+enter commit esc exit editor chars append to message backspace delete last char
type StatusCode ¶
type StatusCode rune
StatusCode is the porcelain v1 single-letter status for one side (staged X or unstaged Y).
const ( StatusUnmodified StatusCode = ' ' StatusModified StatusCode = 'M' StatusAdded StatusCode = 'A' StatusDeleted StatusCode = 'D' StatusRenamed StatusCode = 'R' StatusCopied StatusCode = 'C' StatusUntracked StatusCode = '?' StatusIgnored StatusCode = '!' StatusConflicted StatusCode = 'U' )
type UnstagedMsg ¶
UnstagedMsg is emitted after `git reset HEAD -- <path>`.