{"modulePath":"github.com/2lambda123/git-lfs","version":"v2.5.2+incompatible","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package locking\n\n## Variables\n\n```go\nvar (\n\t// ErrNoMatchingLocks is an error returned when no matching locks were\n\t// able to be resolved\n\tErrNoMatchingLocks = errors.New(\"lfs: no matching locks found\")\n\t// ErrLockAmbiguous is an error returned when multiple matching locks\n\t// were found\n\tErrLockAmbiguous = errors.New(\"lfs: multiple locks found; ambiguous\")\n)\n```\n\n## Types\n\n```go\ntype Client struct {\n\tRemote    string\n\tRemoteRef *git.Ref\n\n\tLocalWorkingDir          string\n\tLocalGitDir              string\n\tSetLockableFilesReadOnly bool\n\t// contains filtered or unexported fields\n}\n```\nClient is the main interface object for the locking package\n\n```go\nfunc NewClient(remote string, lfsClient *lfsapi.Client) (*Client, error)\n```\nNewClient creates a new locking client with the given configuration You must call the returned object's \\`Close\\` method when you are finished with it\n\n```go\nfunc (c *Client) Close() error\n```\nClose this client instance; must be called to dispose of resources\n\n```go\nfunc (c *Client) FixAllLockableFileWriteFlags() error\n```\nFixAllLockableFileWriteFlags recursively scans the repo looking for files which are lockable, and makes sure their write flags are set correctly based on whether they are currently locked or unlocked. Files which are unlocked are made read-only, files which are locked are made writeable. This function can be used after a clone or checkout to ensure that file state correctly reflects the locking state\n\n```go\nfunc (c *Client) FixFileWriteFlagsInDir(dir string, lockablePatterns, unlockablePatterns []string) error\n```\nFixFileWriteFlagsInDir scans dir (which can either be a relative dir from the root of the repo, or an absolute dir within the repo) looking for files to change permissions for. If lockablePatterns is non-nil, then any file matching those patterns will be checked to see if it is currently locked by the current committer, and if so it will be writeable, and if not locked it will be read-only. If unlockablePatterns is non-nil, then any file matching those patterns will be made writeable if it is not already. This can be used to reset files to writeable when their 'lockable' attribute is turned off.\n\n```go\nfunc (c *Client) FixLockableFileWriteFlags(files []string) error\n```\nFixLockableFileWriteFlags checks each file in the provided list, and for those which are lockable, makes sure their write flags are set correctly based on whether they are currently locked or unlocked. Files which are unlocked are made read-only, files which are locked are made writeable. Files which are not lockable are ignored. This function can be used after a clone or checkout to ensure that file state correctly reflects the locking state, and is more efficient than FixAllLockableFileWriteFlags when you know which files changed\n\n```go\nfunc (c *Client) GetLockablePatterns() []string\n```\nGetLockablePatterns returns a list of patterns in .gitattributes which are marked as lockable\n\n```go\nfunc (c *Client) IsFileLockable(path string) bool\n```\nIsFileLockable returns whether a specific file path is marked as Lockable, ie has the 'lockable' attribute in .gitattributes Lockable patterns are cached once for performance, unless you call RefreshLockablePatterns path should be relative to repository root\n\n```go\nfunc (c *Client) IsFileLockedByCurrentCommitter(path string) bool\n```\nIsFileLockedByCurrentCommitter returns whether a file is locked by the current user, as cached locally\n\n```go\nfunc (c *Client) LockFile(path string) (Lock, error)\n```\nLockFile attempts to lock a file on the current remote path must be relative to the root of the repository Returns the lock id if successful, or an error\n\n```go\nfunc (c *Client) SearchLocks(filter map[string]string, limit int, localOnly bool) ([]Lock, error)\n```\nSearchLocks returns a channel of locks which match the given name/value filter If limit \u003e 0 then search stops at that number of locks If localOnly = true, don't query the server \u0026 report only own local locks\n\n```go\nfunc (c *Client) SetupFileCache(path string) error\n```\n\n```go\nfunc (c *Client) UnlockFile(path string, force bool) error\n```\nUnlockFile attempts to unlock a file on the current remote path must be relative to the root of the repository Force causes the file to be unlocked from other users as well\n\n```go\nfunc (c *Client) UnlockFileById(id string, force bool) error\n```\nUnlockFileById attempts to unlock a lock with a given id on the current remote Force causes the file to be unlocked from other users as well\n\n```go\nfunc (c *Client) VerifiableLocks(ref *git.Ref, limit int) (ourLocks, theirLocks []Lock, err error)\n```\n\n```go\ntype Lock struct {\n\t// Id is the unique identifier corresponding to this particular Lock. It\n\t// must be consistent with the local copy, and the server's copy.\n\tId string `json:\"id\"`\n\t// Path is an absolute path to the file that is locked as a part of this\n\t// lock.\n\tPath string `json:\"path\"`\n\t// Owner is the identity of the user that created this lock.\n\tOwner *User `json:\"owner,omitempty\"`\n\t// LockedAt is the time at which this lock was acquired.\n\tLockedAt time.Time `json:\"locked_at\"`\n}\n```\nLock is a record of a locked file\n\n```go\ntype LockCache struct {\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc NewLockCache(filepath string) (*LockCache, error)\n```\n\n```go\nfunc (c *LockCache) Add(l Lock) error\n```\nCache a successful lock for faster local lookup later\n\n```go\nfunc (c *LockCache) Clear()\n```\nClear the cache\n\n```go\nfunc (c *LockCache) Locks() []Lock\n```\nGet the list of cached locked files\n\n```go\nfunc (c *LockCache) RemoveById(id string) error\n```\nRemove a cached lock by id because it's been relinquished\n\n```go\nfunc (c *LockCache) RemoveByPath(filePath string) error\n```\nRemove a cached lock by path becuase it's been relinquished\n\n```go\nfunc (c *LockCache) Save() error\n```\nSave the cache\n\n```go\ntype LockCacher interface {\n\tAdd(l Lock) error\n\tRemoveByPath(filePath string) error\n\tRemoveById(id string) error\n\tLocks() []Lock\n\tClear()\n\tSave() error\n}\n```\n\n```go\ntype User struct {\n\t// Name is the name of the individual who would like to obtain the\n\t// lock, for instance: \"Rick Sanchez\".\n\tName string `json:\"name\"`\n}\n```\nUser represents the owner of a lock.\n\n```go\nfunc NewUser(name string) *User\n```\n\n```go\nfunc (u *User) String() string\n```\nString implements the fmt.Stringer interface.\n\n","path":"github.com/2lambda123/git-lfs/locking","name":"locking","synopsis":"","isRedistributable":true}
