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

Function parseCommitHistory

vcs/git/git_commit_history.go:33–65  ·  view source on GitHub ↗
(output []byte)

Source from the content-addressed store, hash-verified

31}
32
33func parseCommitHistory(output []byte) []vcs.CommitSummary {
34 raw := strings.TrimSuffix(string(output), "\x1e\n")
35 raw = strings.TrimSuffix(raw, "\x1e")
36 if raw == "" {
37 return nil
38 }
39
40 records := strings.Split(raw, "\x1e\n")
41 commits := make([]vcs.CommitSummary, 0, len(records))
42 for _, record := range records {
43 record = strings.TrimSuffix(record, "\x1e")
44 if record == "" {
45 continue
46 }
47 fields := strings.SplitN(record, "\x00", 6)
48 if len(fields) != 6 {
49 continue
50 }
51 timestamp, err := time.Parse(time.RFC3339, fields[4])
52 if err != nil {
53 continue
54 }
55 commits = append(commits, vcs.CommitSummary{
56 Hash: fields[0],
57 ShortHash: fields[1],
58 Author: fields[2],
59 Email: fields[3],
60 Timestamp: timestamp,
61 Subject: fields[5],
62 })
63 }
64 return commits
65}

Callers 1

GetCommitHistoryFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected