git

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package git provides Git operation wrappers for cloning and updating repositories.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Clone

func Clone(url, dest string, depth int) error

Clone clones a git repository from url to dest with the specified depth. It validates the URL before execution to prevent injection attacks. Output is streamed to os.Stdout and os.Stderr. Stdin is connected to os.Stdin to support interactive authentication (e.g., SSH passphrase, credentials).

func IsIgnored added in v0.7.0

func IsIgnored(repoPath, targetPath string) (bool, error)

IsIgnored checks if the given path is ignored by git.

func IsRepo added in v0.7.0

func IsRepo(path string) bool

func IsURL

func IsURL(s string) bool

IsURL returns true if s looks like a valid git repository URL. This acts as a loose check, but callers should prefer ValidateURL for security.

func Pull

func Pull(repoPath string) error

Pull performs a fast-forward-only pull in the specified repository directory. Output is streamed to os.Stdout and os.Stderr. Stdin is connected to os.Stdin to support interactive authentication (e.g., SSH passphrase, credentials).

func ValidateRemote

func ValidateRemote(repoPath string) error

ValidateRemote checks if repoPath is a valid git repository by verifying the existence of a .git directory.

func ValidateURL added in v0.0.3

func ValidateURL(s string) error

ValidateURL checks if the provided string is a safe and valid git URL. It allows:

  • HTTP/HTTPS: https://github.com/user/repo.git
  • SSH: ssh://git@github.com/user/repo.git
  • Git: git://github.com/user/repo.git
  • SCP-like SSH: git@github.com:user/repo.git

It rejects:

  • Strings starting with "-" (argument injection)
  • "ext::" protocol (remote code execution risk)
  • Unknown schemes

Types

This section is empty.

Jump to

Keyboard shortcuts

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