Documentation ¶
Index ¶
- Constants
- Variables
- func CleanOldDeletedRepos(ctx context.Context, config libkbfs.Config, tlfHandle *tlfhandle.Handle) (err error)
- func CleanOldDeletedReposTimeLimited(ctx context.Context, config libkbfs.Config, tlfHandle *tlfhandle.Handle) error
- func DeleteRepo(ctx context.Context, config libkbfs.Config, tlfHandle *tlfhandle.Handle, ...) error
- func GCRepo(ctx context.Context, config libkbfs.Config, tlfHandle *tlfhandle.Handle, ...) (err error)
- func Init(ctx context.Context, gitKBFSParams libkbfs.InitParams, kbCtx libkbfs.Context, ...) (context.Context, libkbfs.Config, error)
- func LastGCTime(ctx context.Context, fs billy.Filesystem) (time.Time, error)
- func NeedsGC(storage storage.Storer, options GCOptions) (doPackRefs bool, numLooseRefs int, doPruneLoose, doObjectRepack bool, ...)
- func NormalizeRepoName(repoName string) string
- func Params(kbCtx libkbfs.Context, storageRoot string, paramsBase *libkbfs.InitParams) (params libkbfs.InitParams, tempDir string, err error)
- func RenameRepo(ctx context.Context, config libkbfs.Config, tlfHandle *tlfhandle.Handle, ...) (err error)
- func StartAutogit(config libkbfs.Config, browserCacheSize int) func()
- func UpdateRepoMD(ctx context.Context, config libkbfs.Config, tlfHandle *tlfhandle.Handle, ...) error
- type AutogitManager
- func (am *AutogitManager) BatchChanges(ctx context.Context, _ []libkbfs.NodeChange, affectedNodeIDs []libkbfs.NodeID)
- func (am *AutogitManager) GetBrowserForRepo(ctx context.Context, gitFS *libfs.FS, repoName string, ...) (*libfs.FS, *Browser, error)
- func (am *AutogitManager) LocalChange(ctx context.Context, node libkbfs.Node, wr libkbfs.WriteRange)
- func (am *AutogitManager) Shutdown()
- func (am *AutogitManager) TlfHandleChange(ctx context.Context, newHandle *tlfhandle.Handle)
- type Browser
- func (b *Browser) Chroot(p string) (newFS billy.Filesystem, err error)
- func (b *Browser) Create(_ string) (billy.File, error)
- func (b *Browser) Join(elem ...string) string
- func (b *Browser) Lstat(filename string) (fi os.FileInfo, err error)
- func (b *Browser) MkdirAll(_ string, _ os.FileMode) (err error)
- func (b *Browser) Open(filename string) (f billy.File, err error)
- func (b *Browser) OpenFile(filename string, flag int, _ os.FileMode) (f billy.File, err error)
- func (b *Browser) ReadDir(p string) (fis []os.FileInfo, err error)
- func (b *Browser) Readlink(link string) (target string, err error)
- func (b *Browser) Remove(_ string) (err error)
- func (b *Browser) Rename(_, _ string) (err error)
- func (b *Browser) Root() string
- func (b *Browser) Stat(filename string) (fi os.FileInfo, err error)
- func (b *Browser) Symlink(_, _ string) (err error)
- func (b *Browser) TempFile(_, _ string) (billy.File, error)
- type Config
- type GCOptions
- type GitConfigWithoutRemotesStorer
- type ID
- func CreateRepoAndID(ctx context.Context, config libkbfs.Config, tlfHandle *tlfhandle.Handle, ...) (ID, error)
- func GetOrCreateRepoAndID(ctx context.Context, config libkbfs.Config, tlfHandle *tlfhandle.Handle, ...) (*libfs.FS, ID, error)
- func GetRepoAndID(ctx context.Context, config libkbfs.Config, tlfHandle *tlfhandle.Handle, ...) (*libfs.FS, ID, error)
- type InvalidIDError
- type OnDemandStorer
- type RPCHandler
- func (rh *RPCHandler) CreateRepo(ctx context.Context, arg keybase1.CreateRepoArg) (id keybase1.RepoID, err error)
- func (rh *RPCHandler) DeleteRepo(ctx context.Context, arg keybase1.DeleteRepoArg) (err error)
- func (rh *RPCHandler) Gc(ctx context.Context, arg keybase1.GcArg) (err error)
- func (rh *RPCHandler) RenameRepo(ctx context.Context, folder keybase1.FolderHandle, oldName, newName string) (err error)
- type RefData
- type RefDataByName
Constants ¶
const ( // AutogitRoot is the subdirectory name within a TLF where autogit // can be accessed. AutogitRoot = ".kbfs_autogit" // AutogitBranchPrefix is a prefix of a subdirectory name // containing one element of a git reference name. AutogitBranchPrefix = ".kbfs_autogit_branch_" // AutogitCommitPrefix is a prefix of a file name // containing the full commit hash. AutogitCommitPrefix = ".kbfs_autogit_commit_" )
const (
GitSuffixToIgnore = ".git"
)
const (
// LFSSubdir is the prefix for the LFS directory under .kbfs_git
LFSSubdir = "kbfs_lfs"
)
Variables ¶
var CommitSentinelValue *object.Commit
CommitSentinelValue marks the end of a list of commits, where there are still commits that haven't been read. Use the zero-value `nil`.
var NullID = ID{}
NullID is an empty ID
var RepoNameRE = `(?:[a-zA-Z0-9][a-zA-Z0-9_\.-]*)`
RepoNameRE is the uncompiled regex for repo names.
Functions ¶
func CleanOldDeletedRepos ¶
func CleanOldDeletedRepos( ctx context.Context, config libkbfs.Config, tlfHandle *tlfhandle.Handle) (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 *tlfhandle.Handle) 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 *tlfhandle.Handle, 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 *tlfhandle.Handle, 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, vlogLevel 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 ¶
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, doObjectRepack bool, numObjectPacks int, 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 NormalizeRepoName ¶
NormalizeRepoName removes the .git suffix from repoName.
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 *tlfhandle.Handle, 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 StartAutogit ¶
StartAutogit launches autogit, and returns a function that should be called on shutdown.
func UpdateRepoMD ¶
func UpdateRepoMD(ctx context.Context, config libkbfs.Config, tlfHandle *tlfhandle.Handle, fs billy.Filesystem, pushType keybase1.GitPushType, oldRepoName string, refDataByName RefDataByName) error
UpdateRepoMD lets the Keybase service know that a repo's MD has been updated.
Types ¶
type AutogitManager ¶
type AutogitManager struct {
// contains filtered or unexported fields
}
AutogitManager can clone and pull source git repos into a destination folder, potentially across different TLFs. New requests for an operation in a destination repo are blocked by any ongoing requests for the same folder, and multiple outstanding requests for the same destination folder get rolled up into one.
func NewAutogitManager ¶
func NewAutogitManager( config libkbfs.Config, browserCacheSize int) *AutogitManager
NewAutogitManager constructs a new AutogitManager instance.
func (*AutogitManager) BatchChanges ¶
func (am *AutogitManager) BatchChanges( ctx context.Context, _ []libkbfs.NodeChange, affectedNodeIDs []libkbfs.NodeID)
BatchChanges implements the libkbfs.Observer interface for AutogitManager.
func (*AutogitManager) GetBrowserForRepo ¶
func (am *AutogitManager) GetBrowserForRepo( ctx context.Context, gitFS *libfs.FS, repoName string, branch plumbing.ReferenceName, subdir string) (*libfs.FS, *Browser, error)
GetBrowserForRepo returns the root FS for the specified repo and a `Browser` for the branch and subdir.
func (*AutogitManager) LocalChange ¶
func (am *AutogitManager) LocalChange( ctx context.Context, node libkbfs.Node, wr libkbfs.WriteRange)
LocalChange implements the libkbfs.Observer interface for AutogitManager.
func (*AutogitManager) Shutdown ¶
func (am *AutogitManager) Shutdown()
Shutdown shuts down this manager.
func (*AutogitManager) TlfHandleChange ¶
func (am *AutogitManager) TlfHandleChange( ctx context.Context, newHandle *tlfhandle.Handle)
TlfHandleChange implements the libkbfs.Observer interface for AutogitManager.
type Browser ¶
type Browser struct {
// contains filtered or unexported fields
}
Browser presents the contents of a git repo as a read-only file system, using only the dotgit directory of the repo.
func NewBrowser ¶
func NewBrowser( repoFS *libfs.FS, clock libkbfs.Clock, gitBranchName plumbing.ReferenceName, sharedCache sharedInBrowserCache) (*Browser, error)
NewBrowser makes a new Browser instance, browsing the given branch of the given repo. If `gitBranchName` is empty, "refs/heads/master" is used. If `gitBranchName` is not empty, but it doesn't begin with "refs/", then "refs/heads/" is prepended to it.
func (*Browser) Chroot ¶
func (b *Browser) Chroot(p string) (newFS billy.Filesystem, err error)
Chroot implements the billy.Filesystem interface for Browser.
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 // The most object packs we will tolerate; if there are more // object packs, we should re-pack all the objects. If < 0, // re-packing will not be done. MaxObjectPacks int }
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 ¶
func (cwrs *GitConfigWithoutRemotesStorer) Config() (*gogitcfg.Config, error)
Config implements the `storer.Storer` interface.
func (*GitConfigWithoutRemotesStorer) Init ¶
func (cwrs *GitConfigWithoutRemotesStorer) Init() error
Init implements the `storer.Initializer` 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 *tlfhandle.Handle, 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 *tlfhandle.Handle, 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 *tlfhandle.Handle, 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) MarshalBinary ¶
MarshalBinary implements the encoding.BinaryMarshaler interface for ID.
func (ID) MarshalText ¶
MarshalText implements the encoding.TextMarshaler interface for ID.
func (*ID) UnmarshalBinary ¶
UnmarshalBinary implements the encoding.BinaryUnmarshaler interface for ID.
func (*ID) UnmarshalText ¶
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 OnDemandStorer ¶
OnDemandStorer is a wrapper around a storage.Storer that reads encoded objects from disk only when the data is needed, to avoid pulling too much data into memory.
func NewOnDemandStorer ¶
func NewOnDemandStorer(s storage.Storer) (*OnDemandStorer, error)
NewOnDemandStorer constructs an on-demand storage layer on top of an existing `Storer`.
func (*OnDemandStorer) DeltaObject ¶
func (ods *OnDemandStorer) DeltaObject( ot plumbing.ObjectType, hash plumbing.Hash) ( plumbing.EncodedObject, error)
DeltaObject implements the storer.DeltaObjectStorer interface for OnDemandStorer.
func (*OnDemandStorer) EncodedObject ¶
func (ods *OnDemandStorer) EncodedObject( ot plumbing.ObjectType, hash plumbing.Hash) ( plumbing.EncodedObject, error)
EncodedObject implements the storage.Storer interface for OnDemandStorer.
type RPCHandler ¶
type RPCHandler struct {
// contains filtered or unexported fields
}
RPCHandler handles service->KBFS git RPC calls.
func NewRPCHandlerWithCtx ¶
func NewRPCHandlerWithCtx(kbCtx libkbfs.Context, config libkbfs.Config, kbfsInitParams *libkbfs.InitParams) (*RPCHandler, func())
NewRPCHandlerWithCtx returns a new instance of a Git RPC handler.
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) RenameRepo ¶
func (rh *RPCHandler) RenameRepo(ctx context.Context, folder keybase1.FolderHandle, oldName, newName string) (err error)
RenameRepo renames an existing git repository.
TODO: Hook this up to an RPC.
type RefDataByName ¶
type RefDataByName map[plumbing.ReferenceName]*RefData
RefDataByName represents a map of reference names to data about that ref.
Source Files ¶
- autogit_manager.go
- autogit_node_wrappers.go
- browser.go
- browser_file.go
- browser_file_info.go
- config.go
- diff_file.go
- diff_file_info.go
- ephemeral_git_config_with_fixed_pack_window.go
- git_config_without_remotes_storer.go
- id.go
- init.go
- lfs_file_info.go
- on_demand_delta_object.go
- on_demand_object.go
- on_demand_storer.go
- repo.go
- rpc.go
- shared_browser_cache.go
- submodule_file.go
- submodule_file_info.go
- util.go