MCPcopy Create free account
hub / github.com/LegacyCodeHQ/clarity-cli / validateCommit

Function validateCommit

vcs/git/git.go:78–92  ·  view source on GitHub ↗

validateCommit checks if the given commit reference exists in the repository

(repoPath, commitID string)

Source from the content-addressed store, hash-verified

76
77// validateCommit checks if the given commit reference exists in the repository
78func validateCommit(repoPath, commitID string) error {
79 if err := validateGitRef(commitID); err != nil {
80 return err
81 }
82
83 _, stderr, err := runGitCommand(repoPath, "rev-parse", "--verify", commitID+"^{commit}")
84 if err != nil {
85 if stderr != "" {
86 return fmt.Errorf("invalid commit reference '%s': %s", commitID, stderr)
87 }
88 return fmt.Errorf("invalid commit reference '%s'", commitID)
89 }
90
91 return nil
92}
93
94// GetCurrentCommitHash returns the current commit hash (HEAD)
95func GetCurrentCommitHash(repoPath string) (string, error) {

Callers 10

GetCommitTreeFilesFunction · 0.85
GetCommitFileStatsFunction · 0.85
GetCommitRangeFileStatsFunction · 0.85
GetCommitRenamesFunction · 0.85
GetCommitRangeRenamesFunction · 0.85
GetCommitDartFilesFunction · 0.85
GetCommitDeletedFilesFunction · 0.85
GetCommitRangeFilesFunction · 0.85
ResolveFirstParentFunction · 0.85

Calls 2

validateGitRefFunction · 0.85
runGitCommandFunction · 0.85

Tested by

no test coverage detected