vcs

package
v0.0.13 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2026 License: BSD-3-Clause Imports: 2 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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)
}

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