MCPcopy
hub / github.com/git-lfs/git-lfs / FixFileWriteFlagsInDir

Method FixFileWriteFlagsInDir

locking/lockable.go:81–110  ·  view source on GitHub ↗

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 t

(dir string, lockablePatterns, unlockablePatterns []string)

Source from the content-addressed store, hash-verified

79// be made writeable if it is not already. This can be used to reset files to
80// writeable when their 'lockable' attribute is turned off.
81func (c *Client) FixFileWriteFlagsInDir(dir string, lockablePatterns, unlockablePatterns []string) error {
82
83 // early-out if no patterns
84 if len(lockablePatterns) == 0 && len(unlockablePatterns) == 0 {
85 return nil
86 }
87
88 absPath := dir
89 if !filepath.IsAbs(dir) {
90 absPath = filepath.Join(c.LocalWorkingDir, dir)
91 }
92 stat, err := os.Stat(absPath)
93 if err != nil {
94 return err
95 }
96 if !stat.IsDir() {
97 return errors.New(tr.Tr.Get("%q is not a valid directory", dir))
98 }
99
100 var lockableFilter *filepathfilter.Filter
101 var unlockableFilter *filepathfilter.Filter
102 if lockablePatterns != nil {
103 lockableFilter = filepathfilter.New(lockablePatterns, nil, filepathfilter.GitAttributes)
104 }
105 if unlockablePatterns != nil {
106 unlockableFilter = filepathfilter.New(unlockablePatterns, nil, filepathfilter.GitAttributes)
107 }
108
109 return c.fixFileWriteFlags(absPath, c.LocalWorkingDir, lockableFilter, unlockableFilter)
110}
111
112// Internal implementation of fixing file write flags with precompiled filters
113func (c *Client) fixFileWriteFlags(absPath, workingDir string, lockable, unlockable *filepathfilter.Filter) error {

Callers 1

trackCommandFunction · 0.80

Calls 4

fixFileWriteFlagsMethod · 0.95
NewFunction · 0.92
NewFunction · 0.92
GetMethod · 0.65

Tested by

no test coverage detected