libgit

package
v1.0.34 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2017 License: BSD-3-Clause Imports: 32 Imported by: 33

Documentation

Index

Constants

This section is empty.

Variables

View Source
var NullID = ID{}

NullID is an empty ID

Functions

func CleanOldDeletedRepos

func CleanOldDeletedRepos(
	ctx context.Context, config libkbfs.Config,
	tlfHandle *libkbfs.TlfHandle) (err error)

CleanOldDeletedRepos completely removes any "deleted" repos that have been deleted for longer than `minDeletedAgeForCleaning`. The caller is responsible for syncing any data to disk, if desired.

func CleanOldDeletedReposTimeLimited

func CleanOldDeletedReposTimeLimited(
	ctx context.Context, config libkbfs.Config,
	tlfHandle *libkbfs.TlfHandle) error

CleanOldDeletedReposTimeLimited is the same as `CleanOldDeletedRepos`, except it limits the time spent on cleaning, deleting as much data as possible within the given time limit (without returning an error).

func DeleteRepo

func DeleteRepo(
	ctx context.Context, config libkbfs.Config, tlfHandle *libkbfs.TlfHandle,
	repoName string) error

DeleteRepo "deletes" the given repo in the given TLF. Right now it simply moves the repo out of the way to a special directory, to allow any concurrent writers to finish their pushes without triggering conflict resolution. The caller is responsible for syncing the FS and flushing the journal, if desired. It expects the `config` object to be unique during the lifetime of this call.

func GCRepo

func GCRepo(
	ctx context.Context, config libkbfs.Config, tlfHandle *libkbfs.TlfHandle,
	repoName string, options GCOptions) (err error)

GCRepo runs garbage collection on the specified repo, if it exceeds any of the thresholds provided in `options`.

func Init

func Init(ctx context.Context, gitKBFSParams libkbfs.InitParams,
	kbCtx libkbfs.Context, keybaseServiceCn libkbfs.KeybaseServiceCn,
	defaultLogPath string) (context.Context, libkbfs.Config, error)

Init initializes a context and a libkbfs.Config for git operations. The config should be shutdown when it is done being used.

func LastGCTime

func LastGCTime(ctx context.Context, fs billy.Filesystem) (
	time.Time, error)

LastGCTime returns the last time the repo was successfully garbage-collected.

func NeedsGC

func NeedsGC(storage storage.Storer, options GCOptions) (
	doPackRefs bool, numLooseRefs int, doPruneLoose bool, err error)

NeedsGC checks the given repo storage layer against the given options to see what kinds of GC are needed on the repo.

func NewRPCHandlerWithCtx

func NewRPCHandlerWithCtx(kbCtx libkbfs.Context, config libkbfs.Config,
	kbfsInitParams *libkbfs.InitParams) keybase1.KBFSGitInterface

NewRPCHandlerWithCtx returns a new instance of a Git RPC handler.

func Params

func Params(kbCtx libkbfs.Context,
	storageRoot string, paramsBase *libkbfs.InitParams) (
	params libkbfs.InitParams, tempDir string, err error)

Params returns a set of default parameters for git-related operations, along with a temp directory that should be cleaned after the git work is complete.

func RenameRepo

func RenameRepo(
	ctx context.Context, config libkbfs.Config, tlfHandle *libkbfs.TlfHandle,
	oldRepoName, newRepoName string) (err error)

RenameRepo renames the repo from an old name to a new name. It leaves a symlink behind so that old remotes will continue to work. The caller is responsible for syncing the FS and flushing the journal, if desired.

func UpdateRepoMD

func UpdateRepoMD(ctx context.Context, config libkbfs.Config,
	tlfHandle *libkbfs.TlfHandle, fs billy.Filesystem) error

UpdateRepoMD lets the Keybase service know that a repo's MD has been updated.

Types

type Config

type Config struct {
	ID         ID
	Name       string // the original user-supplied format of the name
	CreatorUID string
	Ctime      int64 // create time in unix nanoseconds, by creator's clock
}

Config is a KBFS git repo config file.

type GCOptions

type GCOptions struct {
	// The most loose refs we will tolerate; if there are more loose
	// refs, we should pack them.
	MaxLooseRefs int
	// The minimum number of potentially-expired loose objects we need
	// to start the pruning process.  If < 0, pruning will not be done.
	PruneMinLooseObjects int
	// Any unreachable objects older than this time are subject to
	// pruning.
	PruneExpireTime time.Time
}

GCOptions describe options foe garbage collection.

type GitConfigWithoutRemotesStorer

type GitConfigWithoutRemotesStorer struct {
	*filesystem.Storage
	// contains filtered or unexported fields
}

GitConfigWithoutRemotesStorer strips remotes from the config before writing them to disk, to work around a gcfg bug (used by go-git when reading configs from disk) that causes a freakout when it sees backslashes in git file URLs.

func NewGitConfigWithoutRemotesStorer

func NewGitConfigWithoutRemotesStorer(fs *libfs.FS) (
	*GitConfigWithoutRemotesStorer, error)

NewGitConfigWithoutRemotesStorer creates a new git config implementation that strips remotes from the config before writing them to disk.

func (*GitConfigWithoutRemotesStorer) Config

Config implements the `storer.Storer` interface.

func (*GitConfigWithoutRemotesStorer) Init

func (cwrs *GitConfigWithoutRemotesStorer) Init() error

Init implements the `storer.Initializer` interface.

func (*GitConfigWithoutRemotesStorer) SetConfig

func (cwrs *GitConfigWithoutRemotesStorer) SetConfig(c *gogitcfg.Config) (
	err error)

SetConfig implements the `storer.Storer` interface.

type ID

type ID struct {
	// contains filtered or unexported fields
}

ID encapsulates a repo ID.

func CreateRepoAndID

func CreateRepoAndID(
	ctx context.Context, config libkbfs.Config, tlfHandle *libkbfs.TlfHandle,
	repoName string) (ID, error)

CreateRepoAndID returns a new stable repo ID for the provided repoName in the given TLF. If the repo has already been created, it returns a `RepoAlreadyExistsError`. If `repoName` already exists, but is a symlink to another renamed directory, the symlink will be removed in favor of the new repo. The caller is responsible for syncing the FS and flushing the journal, if desired. It expects the `config` object to be unique during the lifetime of this call.

func GetOrCreateRepoAndID

func GetOrCreateRepoAndID(
	ctx context.Context, config libkbfs.Config, tlfHandle *libkbfs.TlfHandle,
	repoName string, uniqID string) (*libfs.FS, ID, error)

GetOrCreateRepoAndID returns a filesystem object rooted at the specified repo, along with the stable repo ID. If the repo hasn't been created yet, it generates a new ID and creates the repo. The caller is responsible for syncing the FS and flushing the journal, if desired.

func GetRepoAndID

func GetRepoAndID(
	ctx context.Context, config libkbfs.Config, tlfHandle *libkbfs.TlfHandle,
	repoName string, uniqID string) (*libfs.FS, ID, error)

GetRepoAndID returns a filesystem object rooted at the specified repo, along with the stable repo ID, if it already exists.

func (ID) Bytes

func (id ID) Bytes() []byte

Bytes returns the bytes of the ID.

func (ID) MarshalBinary

func (id ID) MarshalBinary() (data []byte, err error)

MarshalBinary implements the encoding.BinaryMarshaler interface for ID.

func (ID) MarshalText

func (id ID) MarshalText() ([]byte, error)

MarshalText implements the encoding.TextMarshaler interface for ID.

func (ID) String

func (id ID) String() string

String implements the Stringer interface for ID.

func (*ID) UnmarshalBinary

func (id *ID) UnmarshalBinary(data []byte) error

UnmarshalBinary implements the encoding.BinaryUnmarshaler interface for ID.

func (*ID) UnmarshalText

func (id *ID) UnmarshalText(buf []byte) error

UnmarshalText implements the encoding.TextUnmarshaler interface for ID.

type InvalidIDError

type InvalidIDError struct {
	// contains filtered or unexported fields
}

InvalidIDError indicates that a repo ID string is not parseable or invalid.

func (InvalidIDError) Error

func (e InvalidIDError) Error() string

type RPCHandler

type RPCHandler struct {
	// contains filtered or unexported fields
}

RPCHandler handles service->KBFS git RPC calls.

func (*RPCHandler) CreateRepo

func (rh *RPCHandler) CreateRepo(
	ctx context.Context, arg keybase1.CreateRepoArg) (
	id keybase1.RepoID, err error)

CreateRepo implements keybase1.KBFSGitInterface for KeybaseServiceBase.

func (*RPCHandler) DeleteRepo

func (rh *RPCHandler) DeleteRepo(
	ctx context.Context, arg keybase1.DeleteRepoArg) (err error)

DeleteRepo implements keybase1.KBFSGitInterface for KeybaseServiceBase.

func (*RPCHandler) Gc

func (rh *RPCHandler) Gc(
	ctx context.Context, arg keybase1.GcArg) (err error)

Gc implements keybase1.KBFSGitInterface for KeybaseServiceBase.

Jump to

Keyboard shortcuts

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