gitutil

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package gitutil provides shared utilities for cloning Git repositories and copying their contents to a target directory.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CloneAndCopy

func CloneAndCopy(repoURL, targetDir string, verbose bool) error

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 CopyDir

func CopyDir(src, dst string) error

CopyDir recursively copies a directory tree, skipping symlinks.

func CopyFile

func CopyFile(src, dst string) error

CopyFile copies a single regular file. The caller must ensure src is not a symlink.

func CopyRepoContents

func CopyRepoContents(repoDir, subPath, targetDir string) error

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

func ParseGitHubURL(rawURL string) (cloneURL, branch, subPath string, err error)

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

func RepoNameFromCloneURL(cloneURL string) string

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.

Jump to

Keyboard shortcuts

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