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 ¶
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 IsURL ¶
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 ¶
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 ¶
ValidateRemote checks if repoPath is a valid git repository by verifying the existence of a .git directory.
func ValidateURL ¶ added in v0.0.3
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.