package vcs import ( "fmt" "os" "path/filepath" ) // IsPijulRepo checks if the given path contains a Pijul repository. func IsPijulRepo(path string) bool { info, err := os.Stat(filepath.Join(path, ".pijul")) if err != nil { return false } return info.IsDir() } // IsGitRepo checks if the given path contains a Git repository. func IsGitRepo(path string) bool { info, err := os.Stat(filepath.Join(path, ".git")) if err != nil { // Also check for bare git repos (HEAD file at top level). if _, err := os.Stat(filepath.Join(path, "HEAD")); err == nil { return true } return false } return info.IsDir() } // DetectVCS detects whether a path contains a Git or Pijul repository. func DetectVCS(path string) (string, error) { if IsPijulRepo(path) { return "pijul", nil } if IsGitRepo(path) { return "git", nil } return "", fmt.Errorf("no VCS repository found at %s", path) }