git

package
v0.32.0 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2025 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RemoteName      = "origin"
	TagPrefix       = "refs/tags/"
	BranchPrefix    = "refs/heads/"
	MainBranch      = "refs/heads/main"
	SwarmModeBranch = "refs/heads/swarm-mode"
)

Variables

View Source
var (
	ErrCheckoutFailed          = errors.New("failed To checkout repository")
	ErrFetchFailed             = errors.New("failed To fetch repository")
	ErrPullFailed              = errors.New("failed To pull repository")
	ErrRepositoryAlreadyExists = git.ErrRepositoryAlreadyExists
	ErrInvalidReference        = git.ErrInvalidReference
)

Functions

func CloneRepository

func CloneRepository(path, url, ref string, skipTLSVerify bool, proxyOpts transport.ProxyOptions) (*git.Repository, error)

CloneRepository clones a repository From a given URL and reference To a temporary directory.

func GetAuthUrl

func GetAuthUrl(url, authType, token string) string

GetAuthUrl returns a clone URL with an access token for private repositories.

func GetLatestCommit added in v0.22.0

func GetLatestCommit(repo *git.Repository, ref string) (string, error)

GetLatestCommit retrieves the last commit hash for a given reference in a repository.

func HasChangesInSubdir added in v0.29.0

func HasChangesInSubdir(changedFiles []ChangedFile, subdir string) (bool, error)

HasChangesInSubdir checks if any of the changed files are in a specified subdirectory.

func ResetTrackedFiles added in v0.26.1

func ResetTrackedFiles(worktree *git.Worktree) error

ResetTrackedFiles resets all tracked files in the worktree To their last committed state while leaving untracked files intact.

func UpdateRepository added in v0.16.0

func UpdateRepository(path, ref string, skipTLSVerify bool, proxyOpts transport.ProxyOptions) (*git.Repository, error)

UpdateRepository updates a local repository by

  1. fetching the latest changes From the remote
  2. checking out the specified reference (branch or tag)
  3. pulling the latest changes From the remote
  4. returning the updated repository

Allowed reference forma

  • Branches: refs/heads/main or main
  • Tags: refs/tags/v1.0.0 or v1.0.0

Types

type ChangedFile added in v0.29.0

type ChangedFile struct {
	// From represents the file state before the change.
	From diff.File
	// To represents the file state after the change.
	To diff.File
}

ChangedFile represents a file that has changed between two commits.

func GetChangedFilesBetweenCommits added in v0.29.0

func GetChangedFilesBetweenCommits(repo *git.Repository, commitHash1, commitHash2 plumbing.Hash) ([]ChangedFile, error)

GetChangedFilesBetweenCommits retrieves a list of changed files between two commits in a repository.

type RefSet added in v0.22.0

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

func GetReferenceSet added in v0.22.0

func GetReferenceSet(repo *git.Repository, ref string) (RefSet, error)

GetReferenceSet retrieves a RefSet of local and remote references for a given reference name.

Jump to

Keyboard shortcuts

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