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

Function GetCommitHistory

vcs/git/git_commit_history.go:11–31  ·  view source on GitHub ↗

GetCommitHistory returns commits in chronological order for a HEAD transition.

(repoPath, fromCommit, toCommit string)

Source from the content-addressed store, hash-verified

9
10// GetCommitHistory returns commits in chronological order for a HEAD transition.
11func GetCommitHistory(repoPath, fromCommit, toCommit string) ([]vcs.CommitSummary, error) {
12 if err := validateGitRef(toCommit); err != nil {
13 return nil, err
14 }
15 args := []string{"log", "--reverse", "--format=%H%x00%h%x00%an%x00%ae%x00%aI%x00%s%x1e"}
16 if fromCommit == "" || fromCommit == unbornHeadSignature {
17 args = append(args, toCommit)
18 } else {
19 if err := validateGitRef(fromCommit); err != nil {
20 return nil, err
21 }
22 args = append(args, fromCommit+".."+toCommit)
23 }
24
25 stdout, stderr, err := runGitCommand(repoPath, args...)
26 if err != nil {
27 return nil, gitCommandError(err, stderr)
28 }
29
30 return parseCommitHistory(stdout), nil
31}
32
33func parseCommitHistory(output []byte) []vcs.CommitSummary {
34 raw := strings.TrimSuffix(string(output), "\x1e\n")

Calls 4

validateGitRefFunction · 0.85
runGitCommandFunction · 0.85
gitCommandErrorFunction · 0.85
parseCommitHistoryFunction · 0.85