git

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package git provides a set of utilities for working with Git repositories.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetGitDiff

func GetGitDiff() (string, error)

GetGitDiff retrieves the staged differences. This function runs 'git diff --staged --unified=0' to show zero lines of context around differences in the output. The diff is returned as a string.

func GetGitStats

func GetGitStats() (string, error)

GetGitStats provides statistics of staged changes. It uses the command 'git diff --cached --stat' to show file statistics (insertions, deletions) for staged changes.

func GitAddAll

func GitAddAll() error

GitAddAll stages all changes (including new, modified, and deleted files). It runs the command 'git add .' which adds all files in the current directory.

func GitCommit

func GitCommit(message string) error

GitCommit commits staged changes with a provided commit message. Uses 'git commit -m <message>' to perform a commit.

func GitFetchTags added in v0.0.10

func GitFetchTags() error

GitFetchTags fetches tags from the remote repository. Runs 'git fetch --tags' to ensure local tags are up to date with remote.

func GitGetLatestTags added in v0.0.10

func GitGetLatestTags(count int) ([]string, error)

GitGetLatestTags retrieves the latest tags sorted by version (descending). Uses 'git tag --sort=-version:refname' and returns up to `count` tags.

func GitPush

func GitPush() error

GitPush pushes commits to the remote repository. Runs 'git push' to push changes to the default push target.

func GitPushTags

func GitPushTags() error

GitPushTags pushes tags to the remote repository. Executes 'git push --tags' to push all tags to the remote.

func GitTag

func GitTag(tag string) error

GitTag creates a new tag on the latest commit with the specified tag name. Uses 'git tag <tag>' to attach a tag to the current commit.

func HasStagedChanges

func HasStagedChanges() bool

HasStagedChanges checks if there are any staged but not yet committed changes. Uses 'git diff --staged --quiet', which returns error if there are changes.

func IsCurrentDirectoryGitRepo

func IsCurrentDirectoryGitRepo() bool

IsCurrentDirectoryGitRepo determines if the current directory is a Git repository. It does this by attempting to run 'git rev-parse --is-inside-work-tree' which returns true if the directory is part of a Git repository work tree.

func IsDirty

func IsDirty() bool

IsDirty checks if there are any uncommitted changes in the working directory. 'git diff --quiet' will return a non-zero exit code if there are changes, so this function returns true in that case.

func RunCommand

func RunCommand(cmd *exec.Cmd) error

RunCommand executes a given command and outputs its standard error content to os.Stderr if the command fails. This is a helper function to reduce repetition of error handling logic.

Types

This section is empty.

Jump to

Keyboard shortcuts

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