| 1 |
//go:build !windows |
| 2 |
|
| 3 |
package dotgit |
| 4 |
|
| 5 |
import ( |
| 6 |
"github.com/go-git/go-billy/v5" |
| 7 |
"github.com/go-git/go-git/v5/utils/trace" |
| 8 |
) |
| 9 |
|
| 10 |
func fixPermissions(fs billy.Filesystem, path string) { |
| 11 |
if chmodFS, ok := fs.(billy.Chmod); ok { |
| 12 |
if err := chmodFS.Chmod(path, 0o444); err != nil { |
| 13 |
trace.General.Printf("failed to chmod %s: %v", path, err) |
| 14 |
} |
| 15 |
} |
| 16 |
} |
| 17 |
|
| 18 |
func isReadOnly(fs billy.Filesystem, path string) (bool, error) { |
| 19 |
fi, err := fs.Stat(path) |
| 20 |
if err != nil { |
| 21 |
return false, err |
| 22 |
} |
| 23 |
|
| 24 |
if fi.Mode().Perm() == 0o444 { |
| 25 |
return true, nil |
| 26 |
} |
| 27 |
|
| 28 |
return false, nil |
| 29 |
} |