GetRepositoryStateSignature returns a compact signature of repository state. It includes HEAD and porcelain status so callers can detect commit/index/worktree transitions.
(repoPath string)
| 10 | // GetRepositoryStateSignature returns a compact signature of repository state. |
| 11 | // It includes HEAD and porcelain status so callers can detect commit/index/worktree transitions. |
| 12 | func GetRepositoryStateSignature(repoPath string) (string, error) { |
| 13 | head, err := getHEADSignature(repoPath) |
| 14 | if err != nil { |
| 15 | return "", err |
| 16 | } |
| 17 | |
| 18 | status, stderr, err := runGitCommand(repoPath, "status", "--porcelain", "--untracked-files=all") |
| 19 | if err != nil { |
| 20 | return "", gitCommandError(err, stderr) |
| 21 | } |
| 22 | |
| 23 | return fmt.Sprintf("%s\n%s", head, strings.TrimSpace(string(status))), nil |
| 24 | } |
| 25 | |
| 26 | func getHEADSignature(repoPath string) (string, error) { |
| 27 | head, stderr, err := runGitCommand(repoPath, "rev-parse", "--verify", "HEAD") |