How dagimg-dot/gitsnip works
gitsnip is a command-line tool for downloading selected files and folders from Git repositories. The main workflow parses the source, ref, and requested paths; selects a downloader; stages a repository snapshot; selects matching files; and safely writes them to the destination before reporting the result. The README also documents support for multiple Git hosts, private-repository credentials, and a GitHub API fallback. Some downloader and output details are documented but not fully excerpted, so those relationships are shown only where the README or source index supports them.
Main entry points: root.go Command workflow · factory.go Method selection · files.go File selection and writing · app.go Download orchestration
Components 18
CLI and reporting
- Signal entry point
cmd/gitsnip/main.go - Command workflow
internal/cli/root.go - Result formatting
internal/cli/output.go - Terminal feedback
internal/ui
Request interpretation
- Source parsing
internal/source/source.go - Path patterns
internal/pathspec/pathspec.go - Request and snapshot
internal/app/model/types.go
Download methods
- Download orchestration
internal/app/app.go - Method selection
internal/app/downloader/factory.go - Sparse Git checkout
internal/app/downloader/sparse_checkout.go - GitHub API fetch
internal/app/downloader/github_api.go - Git command runner
internal/app/gitutil/command.go
Selection and writing
- File selection and writing
internal/app/files.go - Safe file utilities
internal/util/fs.go
Other components
- CLI user
- Git repository host
- GitHub API and raw content
- Local filesystem
Connections 20
- CLI user → Signal entry point: runs command
README.md - Signal entry point → Command workflow: starts
cmd/gitsnip/main.go - Command workflow → Source parsing: parses source
internal/cli/root.go - Command workflow → Path patterns: parses paths
internal/cli/root.go - Command workflow → Request and snapshot: builds request
internal/cli/root.go - Command workflow → Download orchestration: invokes download
internal/cli/root.go - Command workflow → Terminal feedback: reports progress
internal/cli/root.go - Download orchestration → Method selection: selects method
internal/app/app.go - Method selection → Sparse Git checkout: constructs
internal/app/downloader/factory.go - Method selection → GitHub API fetch: constructs
internal/app/downloader/factory.go - Method selection → Git command runner: uses runner
internal/app/downloader/factory.go - Sparse Git checkout → Git repository host: fetches repository
README.md - Sparse Git checkout → Git command runner: runs Git commands
internal/app/downloader/sparse_checkout.go - GitHub API fetch → GitHub API and raw content: requests trees and files
internal/app/downloader/github_api.go - Download orchestration → File selection and writing: selects and writes
internal/app/app.go - File selection and writing → Path patterns: matches patterns
internal/app/files.go - File selection and writing → Safe file utilities: copies files safely
internal/app/files.go - File selection and writing → Local filesystem: reads and writes
internal/app/files.go - Command workflow → Result formatting: formats result
internal/cli/output.go - Result formatting → Terminal feedback: builds summary
internal/cli/output.go