Documentation
¶
Overview ¶
Package sourcecontrol provides domain types for source control operations.
Package sourcecontrol provides domain types for source control operations.
Package sourcecontrol provides domain types for source control operations.
Package sourcecontrol provides domain types for source control operations.
Index ¶
- Variables
- type Author
- type BranchInfo
- type Commit
- func (c *Commit) Author() Author
- func (c *Commit) Committer() Author
- func (c *Commit) Date() time.Time
- func (c *Commit) Hash() CommitHash
- func (c *Commit) IsMergeCommit() bool
- func (c *Commit) Message() string
- func (c *Commit) Parents() []CommitHash
- func (c *Commit) SetCommitter(committer Author)
- func (c *Commit) SetParents(parents []CommitHash)
- func (c *Commit) SetTreeHash(hash string)
- func (c *Commit) ShortHash() string
- func (c *Commit) Subject() string
- func (c *Commit) TreeHash() string
- type CommitHash
- type CommitReader
- type FileChange
- type FileStatus
- type GitRepository
- type RemoteInfo
- type RemoteOperator
- type RepositoryInfo
- type RepositoryInfoReader
- type Tag
- func (t *Tag) Date() time.Time
- func (t *Tag) HasPrefix(prefix string) bool
- func (t *Tag) Hash() CommitHash
- func (t *Tag) IsLightweight() bool
- func (t *Tag) IsVersionTag() bool
- func (t *Tag) Message() string
- func (t *Tag) Name() string
- func (t *Tag) SetDate(date time.Time)
- func (t *Tag) SetMessage(msg string)
- func (t *Tag) SetTagger(tagger Author)
- func (t *Tag) Tagger() Author
- func (t *Tag) Version() *version.SemanticVersion
- func (t *Tag) WithoutPrefix(prefix string) string
- type TagList
- type TagManager
- type TagReader
- type TagWriter
- type VersionDiscovery
- type WorkingTreeInspector
- type WorkingTreeStatus
Constants ¶
This section is empty.
Variables ¶
var ( // ErrRepositoryNotFound indicates the repository was not found. ErrRepositoryNotFound = errors.New("repository not found") // ErrNotARepository indicates the path is not a git repository. ErrNotARepository = errors.New("not a git repository") // ErrCommitNotFound indicates the commit was not found. ErrCommitNotFound = errors.New("commit not found") // ErrTagNotFound indicates the tag was not found. ErrTagNotFound = errors.New("tag not found") // ErrTagAlreadyExists indicates the tag already exists. ErrTagAlreadyExists = errors.New("tag already exists") // ErrBranchNotFound indicates the branch was not found. ErrBranchNotFound = errors.New("branch not found") // ErrRemoteNotFound indicates the remote was not found. ErrRemoteNotFound = errors.New("remote not found") // ErrWorkingTreeDirty indicates the working tree has uncommitted changes. ErrWorkingTreeDirty = errors.New("working tree has uncommitted changes") // ErrNoCommits indicates no commits were found. ErrNoCommits = errors.New("no commits found") // ErrNoTags indicates no tags were found. ErrNoTags = errors.New("no tags found") // ErrPushFailed indicates a push operation failed. ErrPushFailed = errors.New("push failed") // ErrFetchFailed indicates a fetch operation failed. ErrFetchFailed = errors.New("fetch failed") // ErrAuthenticationRequired indicates authentication is required. ErrAuthenticationRequired = errors.New("authentication required") )
Domain errors for source control operations.
Functions ¶
This section is empty.
Types ¶
type BranchInfo ¶
type BranchInfo struct {
Name string
IsRemote bool
IsCurrent bool
Hash CommitHash
Upstream string
}
BranchInfo represents a git branch.
type Commit ¶
type Commit struct {
// contains filtered or unexported fields
}
Commit represents a git commit entity.
func (*Commit) IsMergeCommit ¶
IsMergeCommit returns true if this is a merge commit.
func (*Commit) Parents ¶
func (c *Commit) Parents() []CommitHash
Parents returns the parent commit hashes.
func (*Commit) SetCommitter ¶
SetCommitter sets the committer.
func (*Commit) SetParents ¶
func (c *Commit) SetParents(parents []CommitHash)
SetParents sets the parent hashes.
func (*Commit) SetTreeHash ¶
SetTreeHash sets the tree hash.
type CommitHash ¶
type CommitHash string
CommitHash represents a git commit hash.
func (CommitHash) IsEmpty ¶
func (h CommitHash) IsEmpty() bool
IsEmpty returns true if the hash is empty.
func (CommitHash) Short ¶
func (h CommitHash) Short() string
Short returns the short (7 character) hash.
type CommitReader ¶
type CommitReader interface {
GetCommit(ctx context.Context, hash CommitHash) (*Commit, error)
GetCommitsBetween(ctx context.Context, from, to string) ([]*Commit, error)
GetCommitsSince(ctx context.Context, ref string) ([]*Commit, error)
GetLatestCommit(ctx context.Context, branch string) (*Commit, error)
}
CommitReader provides read access to commits. Use this interface when you only need to read commit history.
type FileChange ¶
type FileChange struct {
Path string
Status FileStatus
}
FileChange represents a file change.
type FileStatus ¶
type FileStatus string
FileStatus represents the status of a file change.
const ( FileStatusAdded FileStatus = "added" FileStatusModified FileStatus = "modified" FileStatusDeleted FileStatus = "deleted" FileStatusRenamed FileStatus = "renamed" FileStatusCopied FileStatus = "copied" )
type GitRepository ¶
type GitRepository interface {
RepositoryInfoReader
CommitReader
TagManager
WorkingTreeInspector
RemoteOperator
}
GitRepository defines the full interface for git operations. This is a repository interface in DDD - implemented in infrastructure layer. For more focused use cases, consider using the smaller interfaces: - RepositoryInfoReader: for reading repository metadata - CommitReader: for reading commit history - TagReader/TagWriter/TagManager: for tag operations - WorkingTreeInspector: for checking working tree status - RemoteOperator: for remote synchronization
type RemoteInfo ¶
RemoteInfo represents a git remote.
type RemoteOperator ¶
type RemoteOperator interface {
Fetch(ctx context.Context, remote string) error
Pull(ctx context.Context, remote, branch string) error
Push(ctx context.Context, remote, branch string) error
}
RemoteOperator provides operations for interacting with remote repositories. Use this interface when you need to sync with remote repositories.
type RepositoryInfo ¶
type RepositoryInfo struct {
Path string
Name string
Owner string
RemoteURL string
DefaultBranch string
CurrentBranch string
IsDirty bool
}
RepositoryInfo represents repository metadata.
type RepositoryInfoReader ¶
type RepositoryInfoReader interface {
GetInfo(ctx context.Context) (*RepositoryInfo, error)
GetRemotes(ctx context.Context) ([]RemoteInfo, error)
GetBranches(ctx context.Context) ([]BranchInfo, error)
GetCurrentBranch(ctx context.Context) (string, error)
}
RepositoryInfoReader provides read access to repository metadata. Use this interface when you only need to read repository information.
type Tag ¶
type Tag struct {
// contains filtered or unexported fields
}
Tag represents a git tag entity.
func NewAnnotatedTag ¶
func NewAnnotatedTag(name string, hash CommitHash, message string, tagger Author) *Tag
NewAnnotatedTag creates a new annotated Tag entity.
func (*Tag) IsLightweight ¶
IsLightweight returns true if this is a lightweight tag.
func (*Tag) IsVersionTag ¶
IsVersionTag returns true if this tag represents a version.
func (*Tag) Version ¶
func (t *Tag) Version() *version.SemanticVersion
Version returns the semantic version if this is a version tag.
func (*Tag) WithoutPrefix ¶
WithoutPrefix returns the tag name without the specified prefix.
type TagList ¶
type TagList []*Tag
TagList represents a sorted list of tags.
func (TagList) FilterByPrefix ¶
FilterByPrefix returns tags with the specified prefix.
func (TagList) VersionTags ¶
VersionTags returns only version tags.
type TagManager ¶
TagManager combines read and write access to tags. Use this interface when you need full tag management capabilities.
type TagReader ¶
type TagReader interface {
GetTags(ctx context.Context) (TagList, error)
GetTag(ctx context.Context, name string) (*Tag, error)
GetLatestVersionTag(ctx context.Context, prefix string) (*Tag, error)
}
TagReader provides read access to tags. Use this interface when you only need to read tag information.
type TagWriter ¶
type TagWriter interface {
CreateTag(ctx context.Context, name string, hash CommitHash, message string) (*Tag, error)
DeleteTag(ctx context.Context, name string) error
PushTag(ctx context.Context, name string, remote string) error
}
TagWriter provides write access to tags. Use this interface when you need to create, delete, or push tags.
type VersionDiscovery ¶
type VersionDiscovery struct {
// contains filtered or unexported fields
}
VersionDiscovery provides methods for discovering versions from tags.
func NewVersionDiscovery ¶
func NewVersionDiscovery(tagPrefix string) *VersionDiscovery
NewVersionDiscovery creates a new VersionDiscovery.
func (*VersionDiscovery) DiscoverAllVersions ¶
func (vd *VersionDiscovery) DiscoverAllVersions(ctx context.Context, repo GitRepository) ([]version.SemanticVersion, error)
DiscoverAllVersions finds all versions from tags.
func (*VersionDiscovery) DiscoverCurrentVersion ¶
func (vd *VersionDiscovery) DiscoverCurrentVersion(ctx context.Context, repo GitRepository) (version.SemanticVersion, error)
DiscoverCurrentVersion finds the current version from tags.
type WorkingTreeInspector ¶
type WorkingTreeInspector interface {
IsDirty(ctx context.Context) (bool, error)
GetStatus(ctx context.Context) (*WorkingTreeStatus, error)
}
WorkingTreeInspector provides methods to inspect the working tree status. Use this interface when you only need to check working tree state.
type WorkingTreeStatus ¶
type WorkingTreeStatus struct {
IsClean bool
Staged []FileChange
Unstaged []FileChange
Untracked []string
}
WorkingTreeStatus represents the status of the working tree.