Documentation ¶
Index ¶
- Variables
- type Client
- func (c *Client) Close() error
- func (c *Client) FixAllLockableFileWriteFlags() error
- func (c *Client) FixFileWriteFlagsInDir(dir string, lockablePatterns, unlockablePatterns []string) error
- func (c *Client) FixLockableFileWriteFlags(files []string) error
- func (c *Client) GetLockablePatterns() []string
- func (c *Client) IsFileLockable(path string) bool
- func (c *Client) IsFileLockedByCurrentCommitter(path string) bool
- func (c *Client) LockFile(path string) (Lock, error)
- func (c *Client) SearchLocks(filter map[string]string, limit int, localOnly bool) ([]Lock, error)
- func (c *Client) SetupFileCache(path string) error
- func (c *Client) UnlockFile(path string, force bool) error
- func (c *Client) UnlockFileById(id string, force bool) error
- func (c *Client) VerifiableLocks(ref *git.Ref, limit int) (ourLocks, theirLocks []Lock, err error)
- type Lock
- type LockCache
- type LockCacher
- type User
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNoMatchingLocks is an error returned when no matching locks were // able to be resolved ErrNoMatchingLocks = errors.New("lfs: no matching locks found") // ErrLockAmbiguous is an error returned when multiple matching locks // were found ErrLockAmbiguous = errors.New("lfs: multiple locks found; ambiguous") )
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct { Remote string RemoteRef *git.Ref LocalWorkingDir string LocalGitDir string SetLockableFilesReadOnly bool // contains filtered or unexported fields }
Client is the main interface object for the locking package
func NewClient ¶
NewClient creates a new locking client with the given configuration You must call the returned object's `Close` method when you are finished with it
func (*Client) FixAllLockableFileWriteFlags ¶
FixAllLockableFileWriteFlags 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
func (*Client) FixFileWriteFlagsInDir ¶
func (c *Client) FixFileWriteFlagsInDir(dir string, lockablePatterns, unlockablePatterns []string) error
FixFileWriteFlagsInDir 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.
func (*Client) FixLockableFileWriteFlags ¶
FixLockableFileWriteFlags 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
func (*Client) GetLockablePatterns ¶
GetLockablePatterns returns a list of patterns in .gitattributes which are marked as lockable
func (*Client) IsFileLockable ¶
IsFileLockable 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
func (*Client) IsFileLockedByCurrentCommitter ¶
IsFileLockedByCurrentCommitter returns whether a file is locked by the current user, as cached locally
func (*Client) LockFile ¶
LockFile 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
func (*Client) SearchLocks ¶
SearchLocks returns a channel of locks which match the given name/value filter If limit > 0 then search stops at that number of locks If localOnly = true, don't query the server & report only own local locks
func (*Client) SetupFileCache ¶
func (*Client) UnlockFile ¶
UnlockFile 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
func (*Client) UnlockFileById ¶
UnlockFileById 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
type Lock ¶
type Lock struct { // Id is the unique identifier corresponding to this particular Lock. It // must be consistent with the local copy, and the server's copy. Id string `json:"id"` // Path is an absolute path to the file that is locked as a part of this // lock. Path string `json:"path"` // Owner is the identity of the user that created this lock. Owner *User `json:"owner,omitempty"` // LockedAt is the time at which this lock was acquired. LockedAt time.Time `json:"locked_at"` }
Lock is a record of a locked file
type LockCache ¶
type LockCache struct {
// contains filtered or unexported fields
}
func NewLockCache ¶
func (*LockCache) RemoveById ¶
Remove a cached lock by id because it's been relinquished
func (*LockCache) RemoveByPath ¶
Remove a cached lock by path becuase it's been relinquished