git

package
v0.0.62 Latest Latest
Warning

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

Go to latest
Published: May 27, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckRemoteAccessWithHelp added in v0.0.29

func CheckRemoteAccessWithHelp(exitOnError bool)

CheckRemoteAccessWithHelp checks remote push permissions and provides helpful error messages exitOnError: if true, exits on error; if false, displays warning and continues

func CheckRemotePushPermission

func CheckRemotePushPermission() error

CheckRemotePushPermission checks if the user has valid git credentials for pushing to the remote repository. It uses the same authentication mechanism as git push (SSH keys, credential helpers, etc.) to verify access.

func CheckRepoWritePermission

func CheckRepoWritePermission() error

CheckRepoWritePermission checks if the user has write permissions on the dotfiles directory

func Commit

func Commit(message string) error

Commits the changes in the git repository located at the specified path.

func CopyAndAddFile

func CopyAndAddFile(file, destination string) error

CopyAndAddFile takes a file path as an argument, copies the file to the git repo and adds the file to the git repo.

func DisplaySSHAgentError added in v0.0.29

func DisplaySSHAgentError(exitOnError bool)

DisplaySSHAgentError displays a helpful error message when SSH agent is not configured exitOnError: if true, exits the program; if false, just displays a warning

func GetRepository added in v0.0.61

func GetRepository(rootGitRepoPath string) (*git.Repository, error)

GetRepository opens the git repository located at the specified path.

func GetWorktree

func GetWorktree(rootGitRepoPath string) (*git.Worktree, error)

GetWorktree returns the worktree of the git repository located at the specified path.

func HasOriginRemote added in v0.0.60

func HasOriginRemote() (bool, error)

HasOriginRemote reports whether the configured repository has an origin remote.

func HasRemoteUpdates added in v0.0.40

func HasRemoteUpdates() (bool, error)

HasRemoteUpdates checks if the current branch needs pull from origin. Returns true when remote is ahead or diverged.

func InitFromExistingRepo

func InitFromExistingRepo(rootGitRepoPath string) error

InitFromExistingRepo initializes a git repository from an existing repository located at the specified path.

func InitGitRepo

func InitGitRepo(rootGitRepoPath string, remoteUrl string, opts ...bool) (*git.Repository, error)

InitGitRepo initializes a new git repository at the specified path, with an optional remote URL and bare repository flag. If a remote URL is provided and the remote repository exists, it clones the repository. Otherwise, it initializes a new empty repository and sets up the remote.

func IsGitRepo

func IsGitRepo(path string) bool

Check if folder has git repo

func IsSSHAgentError added in v0.0.29

func IsSSHAgentError(err error) bool

IsSSHAgentError checks if the error is related to missing SSH_AUTH_SOCK

func LinkAndAddFile

func LinkAndAddFile(file string) error

LinkAndAddFile takes a file path as an argument, makes a hard-link to the git repo and adds the file to the git repo.

func ListFiles

func ListFiles() ([]string, error)

func PullRepo added in v0.0.40

func PullRepo() (bool, error)

PullRepo pulls changes from the origin remote for the current branch. Returns true if updates were applied, false if already up to date.

func PushRepo

func PushRepo() (bool, error)

PushRepo pushes changes in the configured git repository to the remote repository. It returns true when commits were pushed and false when the remote was already up to date.

func ReadyForClone

func ReadyForClone(folderPath string) (bool, error)

func RemoveFile

func RemoveFile(file string) error

func SetMaxAncestorSearchDepthForTesting added in v0.0.49

func SetMaxAncestorSearchDepthForTesting(depth int) func()

SetMaxAncestorSearchDepthForTesting overrides the remote sync ancestor search depth. It returns a restore function so tests can reset the previous value.

func StageAndCommitAgentSkillChanges added in v0.0.62

func StageAndCommitAgentSkillChanges(message string) (bool, error)

StageAndCommitAgentSkillChanges stages and commits agent skill changes under omd-agents. Returns true when a commit was created, false when there were no committable changes.

func StageAndCommitShellFeatureChanges added in v0.0.41

func StageAndCommitShellFeatureChanges(message string) (bool, error)

StageAndCommitShellFeatureChanges stages and commits shell framework changes under omd-shells. Device-local override manifests (enabled.local.json) are always excluded. Returns true when a commit was created, false when there were no committable changes.

func StageChange

func StageChange(file string) error

StageChange adds the specified file to the git repository.

func UrlIsGitRepo

func UrlIsGitRepo(url string) bool

Types

type PushCompactionGroup added in v0.0.56

type PushCompactionGroup struct {
	Subject string
	Count   int
}

PushCompactionGroup describes consecutive unpublished commits that can be squashed.

type PushCompactionPlan added in v0.0.56

type PushCompactionPlan struct {
	OriginalCommitCount  int
	CompactedCommitCount int
	Groups               []PushCompactionGroup
	SkippedReason        string
	// contains filtered or unexported fields
}

PushCompactionPlan describes eligible unpublished commit compaction work.

func CompactPushHistory added in v0.0.56

func CompactPushHistory(plan PushCompactionPlan) (PushCompactionPlan, error)

CompactPushHistory rewrites eligible unpublished commits according to the supplied plan.

func PlanPushCompaction added in v0.0.56

func PlanPushCompaction() (PushCompactionPlan, error)

PlanPushCompaction inspects unpublished local commits for consecutive duplicate subjects.

func (PushCompactionPlan) HasCompaction added in v0.0.56

func (p PushCompactionPlan) HasCompaction() bool

HasCompaction reports whether the plan would rewrite any commits.

type RemoteSyncState added in v0.0.40

type RemoteSyncState string

RemoteSyncState describes local/remote relationship for the current branch.

const (
	// RemoteSyncUpToDate indicates local and remote point to the same commit.
	RemoteSyncUpToDate RemoteSyncState = "up-to-date"
	// RemoteSyncRemoteAhead indicates remote contains commits missing locally.
	RemoteSyncRemoteAhead RemoteSyncState = "remote-ahead"
	// RemoteSyncRemoteSignificantlyAhead indicates local is at least 100 commits behind remote.
	RemoteSyncRemoteSignificantlyAhead RemoteSyncState = "remote-significantly-ahead"
	// RemoteSyncLocalAhead indicates local contains commits missing on remote.
	RemoteSyncLocalAhead RemoteSyncState = "local-ahead"
	// RemoteSyncDiverged indicates both sides contain unique commits.
	RemoteSyncDiverged RemoteSyncState = "diverged"
)

func GetRemoteSyncState added in v0.0.40

func GetRemoteSyncState() (RemoteSyncState, error)

GetRemoteSyncState returns local/remote relationship for the current branch. It uses a lightweight remote reference list and local commit graph traversal.

Jump to

Keyboard shortcuts

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