Documentation
¶
Overview ¶
Package gitutil provides shared utilities for cloning Git repositories and copying their contents to a target directory.
Index ¶
- func CloneAndCopy(repoURL, targetDir string, verbose bool) error
- func CopyDir(src, dst string) error
- func CopyFile(src, dst string) error
- func CopyRepoContents(repoDir, subPath, targetDir string) error
- func ParseGitHubURL(rawURL string) (cloneURL, branch, subPath string, err error)
- func RepoNameFromCloneURL(cloneURL string) string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CloneAndCopy ¶
CloneAndCopy clones a GitHub repository URL and copies its contents to targetDir. It handles parsing the URL, shallow cloning, navigating to subpaths, and cleanup.
func CopyRepoContents ¶
CopyRepoContents copies files from a cloned repository to the output directory. It navigates to the subPath if specified and skips the .git directory. Symlinks are skipped to prevent symlink traversal attacks from untrusted repos.
func ParseGitHubURL ¶
ParseGitHubURL parses a GitHub URL into its clone URL, branch, and subdirectory path. Supported formats:
Branch names containing slashes (e.g. feature/my-branch) are supported when encoded as %2F in the URL. The raw (escaped) path is used for splitting so the encoded branch segment is preserved, then unescaped for the return value.
func RepoNameFromCloneURL ¶
RepoNameFromCloneURL extracts the repository name from a clone URL (e.g., "https://github.com/org/my-repo.git" -> "my-repo").
Types ¶
This section is empty.