source

package
v0.0.0-...-57fe098 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package source provides an abstraction of a "repository source" which is any service that hosts source repositories that can be searched and cloned by Grit.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cloner

type Cloner struct {
	Sources List
	Log     logs.Log
}

A Cloner clones repositories.

func (*Cloner) Clone

func (c *Cloner) Clone(
	ctx context.Context,
	source, repoID string,
	clientLog logs.Log,
) (_ LocalRepo, err error)

Clone clones a repository identified by source name and ID and returns the directory it was cloned into.

type List

type List []Source

List is a collection of sources.

func NewList

func NewList(baseURL *url.URL, sources []config.Source) List

NewList returns a new List from the given source configurations.

func (List) ByName

func (l List) ByName(n string) (Source, bool)

ByName returns the source with the given name.

Source names are case insensitive.

type LocalRepo

type LocalRepo struct {
	sourcedriver.RemoteRepo
	Source Source

	// AbsoluteCloneDir is the absolute path to the directory containing the
	// local clone.
	AbsoluteCloneDir string
}

LocalRepo represents a local clone of a remote repository.

type Source

type Source struct {
	// Name is the unique name for the repository source.
	Name string

	// Description is a human-readable description of the source.
	Description string

	// BaseCloneDir is the directory containing repositories cloned from this
	// source.
	BaseCloneDir string

	// BaseURL is the base URL for that the daemon's HTTP server route's to the
	// source's HTTP handler implementation.
	BaseURL *url.URL

	// Driver is the source implementation provided by the driver, used to
	// perform repository operations for this source.
	Driver sourcedriver.Source
}

Source is a repository source.

func (Source) Log

func (s Source) Log(log logs.Log) logs.Log

Log returns the logger to use for messages about this source.

type Suggester

type Suggester struct {
	Sources List
	Log     logs.Log
}

A Suggester suggests repositories based on a partial name.

func (*Suggester) Suggest

func (s *Suggester) Suggest(
	word string,
	includeLocal bool,
	includeRemote bool,
) map[string][]sourcedriver.RemoteRepo

Suggest suggests a set of repositories that begin with the given word.

Jump to

Keyboard shortcuts

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