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) (bool, 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 SetTemplatesFromOrigin(desc *zoekt.Repository, u *url.URL) error
- type BlobLocation
- type Filter
- type Options
- type RepoCache
- type RepoWalker
- 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. The returned bool indicates whether the index was updated as a result. This can be informative if doing incremental indexing.
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 SetTemplatesFromOrigin ¶
func SetTemplatesFromOrigin(desc *zoekt.Repository, u *url.URL) error
SetTemplatesFromOrigin fills in templates based on the origin URL.
Types ¶
type BlobLocation ¶
type BlobLocation struct { GitRepo *git.Repository URL *url.URL // Branches is the list of branches that contain the blob. Branches []string }
BlobLocation holds the repo where the blob can be found, plus other information needed for indexing like its branches.
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 RepoWalker ¶
type RepoWalker struct { Files map[fileKey]BlobLocation // contains filtered or unexported fields }
RepoWalker walks one or more commit trees, collecting the files to index in its Files map.
It also recurses into submodules if Options.Submodules is enabled.
func NewRepoWalker ¶
func NewRepoWalker(r *git.Repository, repoURL string, repoCache *RepoCache) *RepoWalker
NewRepoWalker creates a new RepoWalker.
func (*RepoWalker) CollectFiles ¶
func (rw *RepoWalker) CollectFiles(t *object.Tree, branch string, ig *ignore.Matcher) (map[string]plumbing.Hash, error)
CollectFiles fetches the blob SHA1s for the 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.
The collected files are available through the RepoWalker.Files map.
type SubmoduleEntry ¶
SubmoduleEntry represent one entry in a .gitmodules file