(fs billy.Filesystem)
| 419 | } |
| 420 | |
| 421 | func dotGitCommonDirectory(fs billy.Filesystem) (commonDir billy.Filesystem, err error) { |
| 422 | f, err := fs.Open("commondir") |
| 423 | if os.IsNotExist(err) { |
| 424 | return nil, nil |
| 425 | } |
| 426 | if err != nil { |
| 427 | return nil, err |
| 428 | } |
| 429 | |
| 430 | b, err := io.ReadAll(f) |
| 431 | if err != nil { |
| 432 | return nil, err |
| 433 | } |
| 434 | if len(b) > 0 { |
| 435 | path := strings.TrimSpace(string(b)) |
| 436 | if filepath.IsAbs(path) { |
| 437 | commonDir = osfs.New(path) |
| 438 | } else { |
| 439 | commonDir = osfs.New(filepath.Join(fs.Root(), path)) |
| 440 | } |
| 441 | if _, err := commonDir.Stat(""); err != nil { |
| 442 | if os.IsNotExist(err) { |
| 443 | return nil, ErrRepositoryIncomplete |
| 444 | } |
| 445 | |
| 446 | return nil, err |
| 447 | } |
| 448 | } |
| 449 | |
| 450 | return commonDir, nil |
| 451 | } |
| 452 | |
| 453 | // PlainClone a repository into the path with the given options, isBare defines |
| 454 | // if the new repository will be bare or normal. If the path is not empty |
no test coverage detected