Documentation ¶
Overview ¶
Package gitindex provides functions for indexing Git repositories.
Index ¶
- func CloneRepo(destDir, name, cloneURL string, settings map[string]string) (string, error)
- func DeleteRepos(baseDir string, urlPrefix *url.URL, names map[string]struct{}, filter *Filter) error
- func FindGitRepos(dir string) ([]string, error)
- func IndexGitRepo(opts Options) error
- func ListRepos(baseDir string, u *url.URL) ([]string, error)
- func ParseGitModules(content []byte) (map[string]*SubmoduleEntry, error)
- func Path(baseDir string, name string) string
- func RepoModTime(dir string) (time.Time, error)
- func SetTemplatesFromOrigin(desc *zoekt.Repository, u *url.URL) error
- func TreeToFiles(r *git.Repository, t *object.Tree, repoURL string, repoCache *RepoCache) (map[fileKey]BlobLocation, map[string]plumbing.Hash, error)
- type BlobLocation
- type Filter
- type Options
- type RepoCache
- type SubmoduleEntry
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CloneRepo ¶
CloneRepo clones one repository, adding the given config settings. It returns the bare repo directory. The `name` argument determines where the repo is stored relative to `destDir`. Returns the directory of the repository.
func DeleteRepos ¶
func DeleteRepos(baseDir string, urlPrefix *url.URL, names map[string]struct{}, filter *Filter) error
DeleteRepos deletes stale repos under a specific path in disk. The `names` argument stores names of repos retrieved from the git hosting site and is used along with the `filter` argument to decide on repo deletion.
func FindGitRepos ¶
FindGitRepos finds directories holding git repositories below the given directory. It will find both bare and the ".git" dirs in non-bare repositories. It returns the full path including the dir passed in.
func IndexGitRepo ¶
IndexGitRepo indexes the git repository as specified by the options.
func ListRepos ¶
ListRepos returns paths to repos on disk that start with the given URL prefix. The paths are relative to baseDir, and typically include a ".git" suffix.
func ParseGitModules ¶
func ParseGitModules(content []byte) (map[string]*SubmoduleEntry, error)
ParseGitModules parses the contents of a .gitmodules file.
func RepoModTime ¶
RepoModTime returns the time of last fetch of a git repository.
func SetTemplatesFromOrigin ¶
func SetTemplatesFromOrigin(desc *zoekt.Repository, u *url.URL) error
SetTemplatesFromOrigin fills in templates based on the origin URL.
func TreeToFiles ¶
func TreeToFiles(r *git.Repository, t *object.Tree, repoURL string, repoCache *RepoCache) (map[fileKey]BlobLocation, map[string]plumbing.Hash, error)
TreeToFiles fetches the blob SHA1s for a tree. If repoCache is non-nil, recurse into submodules. In addition, it returns a mapping that indicates in which repo each SHA1 can be found.
Types ¶
type BlobLocation ¶
type BlobLocation struct { Repo *git.Repository URL *url.URL }
BlobLocation holds data where a blob can be found.
type Filter ¶
type Filter struct {
// contains filtered or unexported fields
}
Filter is a include/exclude filter to be used for repo names.
type Options ¶
type Options struct { // The repository to be indexed. RepoDir string // If set, follow submodule links. This requires RepoCacheDir to be set. Submodules bool // If set, skip indexing if the existing index shard is newer // than the refs in the repository. Incremental bool // Don't error out if some branch is missing AllowMissingBranch bool // Specifies the root of a Repository cache. Needed for submodule indexing. RepoCacheDir string // Indexing options. BuildOptions build.Options // Prefix of the branch to index, e.g. `remotes/origin`. BranchPrefix string // List of branch names to index, e.g. []string{"HEAD", "stable"} Branches []string // DeltaShardNumberFallbackThreshold defines an upper limit (inclusive) on the number of preexisting shards // that can exist before attempting another delta build. If the number of preexisting shards exceeds this threshold, // then a normal build will be performed instead. // // If DeltaShardNumberFallbackThreshold is 0, then this fallback behavior is disabled: // a delta build will always be performed regardless of the number of preexisting shards. DeltaShardNumberFallbackThreshold uint64 }
The Options structs controls details of the indexing process.
type RepoCache ¶
type RepoCache struct {
// contains filtered or unexported fields
}
RepoCache is a set of repositories on the file system, named and stored by URL.
func NewRepoCache ¶
NewRepoCache creates a new RepoCache rooted at the given directory.
type SubmoduleEntry ¶
SubmoduleEntry represent one entry in a .gitmodules file