vcs

package
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 6, 2026 License: BSD-3-Clause Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ListVCS

func ListVCS() []string

func RegisterVCS

func RegisterVCS(vcs VersionControlSystem)

Global functions for easy access

func UnregisterVCS

func UnregisterVCS(name string)

Types

type VCSRegistry

type VCSRegistry struct {
	// contains filtered or unexported fields
}

VCSRegistry manages available version control systems

func (*VCSRegistry) GetActiveVCS

func (r *VCSRegistry) GetActiveVCS() VersionControlSystem

GetActiveVCS returns the first VCS that detects it's in a repository

func (*VCSRegistry) GetVCS

func (r *VCSRegistry) GetVCS(name string) VersionControlSystem

GetVCS returns a specific VCS by name

func (*VCSRegistry) ListVCS

func (r *VCSRegistry) ListVCS() []string

ListVCS returns all registered VCS names

func (*VCSRegistry) RegisterVCS

func (r *VCSRegistry) RegisterVCS(vcs VersionControlSystem)

RegisterVCS registers a version control system

func (*VCSRegistry) UnregisterVCS

func (r *VCSRegistry) UnregisterVCS(name string)

UnregisterVCS unregisters a version control system

type VersionControlSystem

type VersionControlSystem interface {
	// Name returns the name of the VCS (e.g., "git", "svn")
	Name() string

	// IsRepository checks if we're in a repository of this type
	IsRepository() bool

	// GetRepositoryRoot returns the root directory of the repository
	GetRepositoryRoot() (string, error)

	// IsWorkingDirectoryClean checks if there are no uncommitted changes
	IsWorkingDirectoryClean() (bool, error)

	// GetVCSIdentifier returns a VCS-specific identifier for the current state
	GetVCSIdentifier(length int) (string, error)

	// CreateTag creates a tag with the specified name and message
	CreateTag(tagName, message string) error

	// TagExists checks if a tag with the specified name exists
	TagExists(tagName string) (bool, error)

	// CreateBranch creates a branch with the specified name from the current HEAD
	CreateBranch(branchName string) error

	// BranchExists checks if a branch with the specified name exists
	BranchExists(branchName string) (bool, error)

	// GetBranchName returns the current branch name
	GetBranchName() (string, error)

	// GetCommitDate returns the date of the current commit
	GetCommitDate() (time.Time, error)

	// GetCommitsSinceTag returns the number of commits since the most recent semver tag
	// Returns 0 if on a tagged commit, -1 if no tags exist
	GetCommitsSinceTag() (int, error)

	// GetUncommittedChanges returns the count of uncommitted changes (staged + unstaged + untracked)
	GetUncommittedChanges() (int, error)

	// GetLastTag returns the most recent semver tag
	// Returns empty string if no matching tags exist
	GetLastTag() (string, error)

	// GetLastTagCommit returns the SHA of the commit the last tag points to
	GetLastTagCommit() (string, error)

	// GetCommitAuthor returns the name of the current commit's author
	GetCommitAuthor() (string, error)

	// GetCommitAuthorEmail returns the email of the current commit's author
	GetCommitAuthorEmail() (string, error)

	// GetCommitMessagesSinceTag returns all commit messages since the most recent tag
	// Returns commit messages newest first, empty slice if on tagged commit or no tags
	GetCommitMessagesSinceTag() ([]string, error)

	// GetDirtyFiles returns the list of files with uncommitted changes
	// Returns relative paths from the repository root
	GetDirtyFiles() ([]string, error)

	// CommitFiles stages and commits the specified files with the given message
	CommitFiles(files []string, message string) error

	// AmendCommit stages the specified files and amends the last commit
	AmendCommit(files []string) error

	// GetHooksPath returns the path to the hooks directory
	GetHooksPath() (string, error)

	// PushTag pushes a tag to the remote repository
	PushTag(tagName string) error

	// PushBranch pushes a branch to the remote repository
	PushBranch(branchName string) error
}

VersionControlSystem defines the interface for version control operations

func GetActiveVCS

func GetActiveVCS() VersionControlSystem

func GetVCS

func GetVCS(name string) VersionControlSystem

Directories

Path Synopsis
Package mock is a generated GoMock package.
Package mock is a generated GoMock package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL