git

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2026 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Overview

Package git runs local git commands for cloning repos, fetching PR merge refs, and checking out commits.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckoutFetchHead

func CheckoutFetchHead(repoPath string) (string, error)

func CheckoutRef added in v1.2.0

func CheckoutRef(repoPath, ref string) error

CheckoutRef checks out the given branch name or commit SHA.

func Clone

func Clone(parentDir, cloneURL, targetPath string) error

func EnsurePathIsRepo

func EnsurePathIsRepo(repoPath, cloneURL string, force bool) error

EnsurePathIsRepo ensures the given path contains a git repository. If the directory doesn't exist or is empty, it clones from cloneURL. It verifies a .git directory exists. If force is true, uncommitted changes are discarded with git reset + clean; otherwise an error is returned.

func FetchPRMergeRef

func FetchPRMergeRef(repoPath string, prNumber int) error

func GetCurrentRef added in v1.2.0

func GetCurrentRef(repoPath string) (string, error)

GetCurrentRef returns the current branch name, tag name, or commit SHA (in that order of preference).

func IsRepoForRemote added in v1.2.0

func IsRepoForRemote(repoPath, cloneURL string) bool

IsRepoForRemote returns true if the git repo at repoPath has a remote URL that refers to the same GitHub repository as cloneURL. It normalises both URLs to "host/owner/repo" before comparing so that SSH and HTTPS forms match.

func IsWorkingTreeDirty

func IsWorkingTreeDirty(repoPath string) (dirty bool, output string, err error)

IsWorkingTreeDirty returns true if the repo has uncommitted changes, along with the porcelain output describing them.

func ResetAndClean

func ResetAndClean(repoPath string) error

ResetAndClean discards all uncommitted changes (tracked and untracked).

func Run

func Run(repoPath string, args ...string) (string, error)

Types

This section is empty.

Jump to

Keyboard shortcuts

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