(path string, fs billy.Filesystem)
| 399 | } |
| 400 | |
| 401 | func dotGitFileToOSFilesystem(path string, fs billy.Filesystem) (bfs billy.Filesystem, err error) { |
| 402 | f, err := fs.Open(GitDirName) |
| 403 | if err != nil { |
| 404 | return nil, err |
| 405 | } |
| 406 | defer ioutil.CheckClose(f, &err) |
| 407 | |
| 408 | b, err := io.ReadAll(f) |
| 409 | if err != nil { |
| 410 | return nil, err |
| 411 | } |
| 412 | |
| 413 | line := string(b) |
| 414 | const prefix = "gitdir: " |
| 415 | if !strings.HasPrefix(line, prefix) { |
| 416 | return nil, fmt.Errorf(".git file has no %s prefix", prefix) |
| 417 | } |
| 418 | |
| 419 | gitdir := strings.Split(line[len(prefix):], "\n")[0] |
| 420 | gitdir = strings.TrimSpace(gitdir) |
| 421 | if filepath.IsAbs(gitdir) { |
| 422 | return osfs.New(gitdir), nil |
| 423 | } |
| 424 | |
| 425 | return osfs.New(fs.Join(path, gitdir)), nil |
| 426 | } |
| 427 | |
| 428 | func dotGitCommonDirectory(fs billy.Filesystem) (commonDir billy.Filesystem, err error) { |
| 429 | f, err := fs.Open("commondir") |
no test coverage detected
searching dependent graphs…