Documentation
¶
Overview ¶
Package model defines the internal value types shared across the git packages.
Types such as Oid, Reference, Signature, and Commit model core git objects independently of any backend so the higher-level git API and its adapters exchange a single representation.
Index ¶
- Constants
- func WithLogExtraArgs(args ...string) func(*LogOptions)
- type BlameLine
- type BlameOption
- type BlameOptions
- type Branch
- type BranchFilter
- type CheckoutOption
- type CheckoutOptions
- type CherryPickOption
- type CherryPickOptions
- type CleanOption
- type CleanOptions
- type Commit
- type CommitOption
- type CommitOptions
- type DescribeOption
- func WithDescribeAbbreviated(abbreviated bool) DescribeOption
- func WithDescribeAlways(always bool) DescribeOption
- func WithDescribeAnnotatedTagsOnly(only bool) DescribeOption
- func WithDescribeExtraArgs(args ...string) DescribeOption
- func WithDescribeLong(long bool) DescribeOption
- func WithDescribeMatch(match string) DescribeOption
- type DescribeOptions
- type DiffEntry
- type DiffOption
- type DiffOptions
- type DiffStats
- type EntryKind
- type EntryState
- type FetchOption
- type FetchOptions
- type FileStatus
- type GrepMatch
- type GrepOption
- type GrepOptions
- type LogOptions
- type MergeOption
- type MergeOptions
- type MergeResult
- type Oid
- type OpenOptions
- type Option
- type PushOption
- type PushOptions
- type RebaseOption
- type RebaseOptions
- type RebaseResult
- type Reference
- type Remote
- type ResetMode
- type SignFormat
- type SignOptions
- type Signature
- type StashEntry
- type StatusEntry
- type Tag
- type TreeEntry
- type TreeHash
Constants ¶
const DefaultBranch = "main"
DefaultBranch is the short branch name used for newly initialized repositories.
Variables ¶
This section is empty.
Functions ¶
func WithLogExtraArgs ¶
func WithLogExtraArgs(args ...string) func(*LogOptions)
WithLogExtraArgs appends backend-specific raw log args.
Types ¶
type BlameOption ¶
type BlameOption func(*BlameOptions)
BlameOption configures blame behavior.
func WithBlameExtraArgs ¶
func WithBlameExtraArgs(args ...string) BlameOption
WithBlameExtraArgs appends backend-specific raw blame args.
func WithIgnoreWhitespace ¶
func WithIgnoreWhitespace(ignore bool) BlameOption
WithIgnoreWhitespace requests whitespace-insensitive blame when supported.
func WithLineRange ¶
func WithLineRange(start, end int) BlameOption
WithLineRange limits blame results to the inclusive range [start, end].
type BlameOptions ¶
BlameOptions controls blame output.
type BranchFilter ¶
type BranchFilter int
BranchFilter controls which branches to list.
const ( LocalBranches BranchFilter = iota RemoteBranches AllBranches )
type CheckoutOption ¶
type CheckoutOption func(*CheckoutOptions)
CheckoutOption configures checkout behavior.
func WithCheckoutCreateBranch ¶
func WithCheckoutCreateBranch(name string) CheckoutOption
WithCheckoutCreateBranch creates a new branch while checking out.
func WithCheckoutDetach ¶
func WithCheckoutDetach(detach bool) CheckoutOption
WithCheckoutDetach detaches HEAD at the target revision.
func WithCheckoutExtraArgs ¶
func WithCheckoutExtraArgs(args ...string) CheckoutOption
WithCheckoutExtraArgs appends backend-specific raw checkout args.
func WithCheckoutForce ¶
func WithCheckoutForce(force bool) CheckoutOption
WithCheckoutForce forces checkout.
type CheckoutOptions ¶
CheckoutOptions controls checkout behavior.
type CherryPickOption ¶
type CherryPickOption func(*CherryPickOptions)
CherryPickOption configures cherry-pick behavior.
func WithCherryPickExtraArgs ¶
func WithCherryPickExtraArgs(args ...string) CherryPickOption
WithCherryPickExtraArgs appends backend-specific raw cherry-pick args.
func WithCherryPickMainline ¶
func WithCherryPickMainline(mainline int) CherryPickOption
WithCherryPickMainline selects the mainline parent for merge commits.
func WithCherryPickNoCommit ¶
func WithCherryPickNoCommit(noCommit bool) CherryPickOption
WithCherryPickNoCommit applies changes without creating a commit.
type CherryPickOptions ¶
CherryPickOptions controls cherry-pick behavior.
type CleanOption ¶
type CleanOption func(*CleanOptions)
CleanOption configures clean behavior.
func WithCleanDirectories ¶
func WithCleanDirectories(directories bool) CleanOption
WithCleanDirectories includes untracked directories in clean operations.
func WithCleanExtraArgs ¶
func WithCleanExtraArgs(args ...string) CleanOption
WithCleanExtraArgs appends backend-specific raw clean args.
func WithCleanForce ¶
func WithCleanForce(force bool) CleanOption
WithCleanForce toggles destructive clean mode.
func WithCleanIgnored ¶
func WithCleanIgnored(ignored bool) CleanOption
WithCleanIgnored includes ignored files in clean operations.
type CleanOptions ¶
CleanOptions controls git clean behavior.
type CommitOption ¶
type CommitOption func(*CommitOptions)
CommitOption configures commit behavior.
func WithCommitAmend ¶
func WithCommitAmend(amend bool) CommitOption
WithCommitAmend requests amending the current HEAD commit.
func WithCommitAuthor ¶
func WithCommitAuthor(sig Signature) CommitOption
WithCommitAuthor sets the author signature for a commit.
func WithCommitCommitter ¶
func WithCommitCommitter(sig Signature) CommitOption
WithCommitCommitter sets the committer signature for a commit.
func WithCommitExtraArgs ¶
func WithCommitExtraArgs(args ...string) CommitOption
WithCommitExtraArgs appends backend-specific raw commit args.
func WithCommitSign ¶
func WithCommitSign(sign bool) CommitOption
WithCommitSign requests commit signing.
type CommitOptions ¶
type CommitOptions struct {
Author *Signature
Committer *Signature
Sign bool
Amend bool
ExtraArgs []string
}
CommitOptions controls commit creation.
type DescribeOption ¶
type DescribeOption func(*DescribeOptions)
DescribeOption configures describe behavior.
func WithDescribeAbbreviated ¶
func WithDescribeAbbreviated(abbreviated bool) DescribeOption
WithDescribeAbbreviated controls abbreviated fallback output.
func WithDescribeAlways ¶
func WithDescribeAlways(always bool) DescribeOption
WithDescribeAlways requests fallback to an object name.
func WithDescribeAnnotatedTagsOnly ¶
func WithDescribeAnnotatedTagsOnly(only bool) DescribeOption
WithDescribeAnnotatedTagsOnly limits describe to annotated tags.
func WithDescribeExtraArgs ¶
func WithDescribeExtraArgs(args ...string) DescribeOption
WithDescribeExtraArgs appends backend-specific raw describe args.
func WithDescribeLong ¶
func WithDescribeLong(long bool) DescribeOption
WithDescribeLong requests long describe output.
func WithDescribeMatch ¶
func WithDescribeMatch(match string) DescribeOption
WithDescribeMatch restricts matching tags.
type DescribeOptions ¶
type DescribeOptions struct {
Match string
AnnotatedTagsOnly bool
Long bool
Abbreviated bool
Always bool
ExtraArgs []string
}
DescribeOptions controls git describe output.
type DiffEntry ¶
type DiffEntry struct {
Path string
OldPath string
OldOID Oid
NewOID Oid
Status FileStatus
}
DiffEntry represents a single file change between two refs.
type DiffOption ¶
type DiffOption func(*DiffOptions)
DiffOption configures diff generation.
func WithDiffContext ¶
func WithDiffContext(lines int) DiffOption
WithDiffContext sets the requested number of context lines.
func WithDiffExtraArgs ¶
func WithDiffExtraArgs(args ...string) DiffOption
WithDiffExtraArgs appends backend-specific raw diff args.
func WithDiffNameOnly ¶
func WithDiffNameOnly(nameOnly bool) DiffOption
WithDiffNameOnly requests name-only diff output when supported.
type DiffOptions ¶
DiffOptions controls diff generation.
type EntryState ¶
type EntryState int
EntryState describes a file's state in the working tree or index.
const ( Staged EntryState = iota Unstaged Untracked Conflicted )
func (EntryState) String ¶
func (s EntryState) String() string
type FetchOption ¶
type FetchOption func(*FetchOptions)
FetchOption configures fetch behavior.
func WithFetchExtraArgs ¶
func WithFetchExtraArgs(args ...string) FetchOption
WithFetchExtraArgs appends backend-specific raw fetch args.
func WithFetchPrune ¶
func WithFetchPrune(prune bool) FetchOption
WithFetchPrune sets whether fetch prunes stale remote-tracking refs.
func WithFetchRefspecs ¶
func WithFetchRefspecs(refspecs ...string) FetchOption
WithFetchRefspecs sets fetch refspecs.
type FetchOptions ¶
FetchOptions controls fetch behavior.
type FileStatus ¶
type FileStatus int
FileStatus describes how a file changed in a diff.
const ( FileAdded FileStatus = iota FileModified FileDeleted FileRenamed FileCopied FileUntracked FileIgnored FileTypeChanged FileConflicted )
func (FileStatus) String ¶
func (s FileStatus) String() string
type GrepOption ¶
type GrepOption func(*GrepOptions)
GrepOption configures grep behavior.
func WithGrepExtraArgs ¶
func WithGrepExtraArgs(args ...string) GrepOption
WithGrepExtraArgs appends backend-specific raw grep args.
func WithGrepIgnoreCase ¶
func WithGrepIgnoreCase(ignore bool) GrepOption
WithGrepIgnoreCase toggles case-insensitive matching.
func WithGrepLineNumbers ¶
func WithGrepLineNumbers(enabled bool) GrepOption
WithGrepLineNumbers toggles line-number output when supported.
func WithGrepPathspecs ¶
func WithGrepPathspecs(pathspecs ...string) GrepOption
WithGrepPathspecs restricts grep to the provided paths.
type GrepOptions ¶
GrepOptions controls git grep behavior.
type LogOptions ¶
type LogOptions struct {
MaxCount int
PathFilter string
AuthorFilter string
Since *time.Time
Until *time.Time
ExtraArgs []string
}
LogOptions controls log traversal.
type MergeOption ¶
type MergeOption func(*MergeOptions)
MergeOption configures merge behavior.
func WithMergeCommit ¶
func WithMergeCommit(commit bool) MergeOption
WithMergeCommit toggles automatic merge commit creation.
func WithMergeExtraArgs ¶
func WithMergeExtraArgs(args ...string) MergeOption
WithMergeExtraArgs appends backend-specific raw merge args.
func WithMergeFFOnly ¶
func WithMergeFFOnly(ffOnly bool) MergeOption
WithMergeFFOnly requests fast-forward-only merges.
func WithMergeMessage ¶
func WithMergeMessage(message string) MergeOption
WithMergeMessage sets the merge commit message.
func WithMergeNoFastForward ¶
func WithMergeNoFastForward(noFF bool) MergeOption
WithMergeNoFastForward requests a merge commit even when fast-forward is possible.
func WithMergeSquash ¶
func WithMergeSquash(squash bool) MergeOption
WithMergeSquash requests squash merge behavior.
type MergeOptions ¶
type MergeOptions struct {
Commit bool
FFOnly bool
NoFastForward bool
Squash bool
Message string
ExtraArgs []string
}
MergeOptions controls merge behavior.
type MergeResult ¶
MergeResult summarizes a merge operation.
type OpenOptions ¶
type OpenOptions struct {
PreferCLI bool
CLIPath string
Transport gitauth.Transport
Signing gitauth.Signing
ExtraArgs []string
}
OpenOptions controls repository construction and backend selection.
func ApplyOptions ¶
func ApplyOptions(opts ...Option) *OpenOptions
ApplyOptions materializes constructor options.
type Option ¶
type Option func(*OpenOptions)
Option configures repository construction behavior.
func WithCLIPath ¶
WithCLIPath sets the git executable path used by the CLI backend.
func WithExtraArgs ¶
WithExtraArgs appends raw CLI args for backends that support them.
func WithPreferCLI ¶
WithPreferCLI requests CLI-backed operations where available.
func WithSigning ¶
WithSigning sets the signing configuration used by write operations when supported.
func WithTransport ¶
WithTransport sets the transport auth configuration used by clone/fetch/push operations.
type PushOption ¶
type PushOption func(*PushOptions)
PushOption configures push behavior.
func WithPushExtraArgs ¶
func WithPushExtraArgs(args ...string) PushOption
WithPushExtraArgs appends backend-specific raw push args.
func WithPushForce ¶
func WithPushForce(force bool) PushOption
WithPushForce sets whether push is forced.
func WithPushRefspecs ¶
func WithPushRefspecs(refspecs ...string) PushOption
WithPushRefspecs sets push refspecs.
type PushOptions ¶
PushOptions controls push behavior.
type RebaseOption ¶
type RebaseOption func(*RebaseOptions)
RebaseOption configures rebase behavior.
func WithRebaseAutosquash ¶
func WithRebaseAutosquash(autosquash bool) RebaseOption
WithRebaseAutosquash toggles autosquash behavior.
func WithRebaseExtraArgs ¶
func WithRebaseExtraArgs(args ...string) RebaseOption
WithRebaseExtraArgs appends backend-specific raw rebase args.
func WithRebaseInteractive ¶
func WithRebaseInteractive(interactive bool) RebaseOption
WithRebaseInteractive toggles interactive rebase mode.
type RebaseOptions ¶
RebaseOptions controls rebase behavior.
type RebaseResult ¶
RebaseResult summarizes a rebase operation.
type SignFormat ¶
type SignFormat int
SignFormat identifies the object-signing backend git should use.
const ( SignFormatDefault SignFormat = iota SignFormatOpenPGP SignFormatSSH SignFormatX509 )
func (SignFormat) GitConfig ¶
func (f SignFormat) GitConfig() string
GitConfig returns the value accepted by git's gpg.format configuration.
type SignOptions ¶
type SignOptions struct {
Format SignFormat
Key string
}
SignOptions controls signed tag creation.
type StashEntry ¶
StashEntry represents a stash reference.
type StatusEntry ¶
type StatusEntry struct {
Path string
State EntryState
}
StatusEntry represents a file's status in the working tree.