A vibe coded tangled fork which supports pijul.
1package vcs
2
3import (
4 "fmt"
5 "os"
6 "path/filepath"
7)
8
9// IsPijulRepo checks if the given path contains a Pijul repository.
10func IsPijulRepo(path string) bool {
11 info, err := os.Stat(filepath.Join(path, ".pijul"))
12 if err != nil {
13 return false
14 }
15 return info.IsDir()
16}
17
18// IsGitRepo checks if the given path contains a Git repository.
19func IsGitRepo(path string) bool {
20 info, err := os.Stat(filepath.Join(path, ".git"))
21 if err != nil {
22 // Also check for bare git repos (HEAD file at top level).
23 if _, err := os.Stat(filepath.Join(path, "HEAD")); err == nil {
24 return true
25 }
26 return false
27 }
28 return info.IsDir()
29}
30
31// DetectVCS detects whether a path contains a Git or Pijul repository.
32func DetectVCS(path string) (string, error) {
33 if IsPijulRepo(path) {
34 return "pijul", nil
35 }
36 if IsGitRepo(path) {
37 return "git", nil
38 }
39 return "", fmt.Errorf("no VCS repository found at %s", path)
40}