MCPcopy Create free account
hub / github.com/celer-pkg/celer / GetCommitHash

Function GetCommitHash

pkgs/git/local.go:144–157  ·  view source on GitHub ↗

GetCommitHash read git commit hash.

(repoDir string)

Source from the content-addressed store, hash-verified

142
143// GetCommitHash read git commit hash.
144func GetCommitHash(repoDir string) (string, error) {
145 // Check if repo exists.
146 if _, err := os.Stat(repoDir); err != nil {
147 return "", fmt.Errorf("directory error: %w", err)
148 }
149
150 cmd := exec.Command("git", "-C", repoDir, "rev-parse", "HEAD")
151 output, err := cmd.CombinedOutput()
152 if err != nil {
153 return "", fmt.Errorf("read git commit hash: %s", output)
154 }
155
156 return strings.TrimSpace(string(output)), nil
157}
158
159// GetDefaultBranch read git default branch.
160func GetDefaultBranch(nameVersion, repoDir string) (string, error) {

Calls 1

CommandMethod · 0.65