diff options
| author | mo khan <mo@mokhan.ca> | 2026-01-30 18:01:41 -0700 |
|---|---|---|
| committer | mo khan <mo@mokhan.ca> | 2026-01-30 18:01:41 -0700 |
| commit | ff213f4113434fee4ddba1f0874d3c2c99b4f9de (patch) | |
| tree | bfb5a53fb1768f350880fbd94c9a2ed1cdb38272 /pkg/git | |
| parent | c60b386be0078c86a2c8f7de3c85ca98dd7e357c (diff) | |
feat: add json and atom feeds
Diffstat (limited to 'pkg/git')
| -rw-r--r-- | pkg/git/git.go | 34 | ||||
| -rw-r--r-- | pkg/git/types.go | 25 |
2 files changed, 37 insertions, 22 deletions
diff --git a/pkg/git/git.go b/pkg/git/git.go index 4fd551a..1e05d60 100644 --- a/pkg/git/git.go +++ b/pkg/git/git.go @@ -224,6 +224,9 @@ func Commits(ref Ref, repoDir string) ([]Commit, error) { "%an", // author name "%ae", // author email "%ad", // author date + "%cn", // committer name + "%ce", // committer email + "%cd", // committer date "%P", // parent hashes "%D", // ref names without the "(", ")" wrapping. } @@ -256,22 +259,31 @@ func Commits(ref Ref, repoDir string) ([]Commit, error) { if len(parts) != len(format) { return nil, fmt.Errorf("unexpected commit format: %s", line) } - full, short, subject, body, author, email, date, parents, refs := - parts[0], parts[1], parts[2], parts[3], parts[4], parts[5], parts[6], parts[7], parts[8] + full, short, subject, body, author, email, date := + parts[0], parts[1], parts[2], parts[3], parts[4], parts[5], parts[6] + committerName, committerEmail, committerDate, parents, refs := + parts[7], parts[8], parts[9], parts[10], parts[11] timestamp, err := strconv.Atoi(date) if err != nil { return nil, fmt.Errorf("failed to parse commit date: %w", err) } + committerTimestamp, err := strconv.Atoi(committerDate) + if err != nil { + return nil, fmt.Errorf("failed to parse committer date: %w", err) + } commits = append(commits, Commit{ - Hash: full, - ShortHash: short, - Subject: subject, - Body: body, - Author: author, - Email: email, - Date: time.Unix(int64(timestamp), 0), - Parents: strings.Fields(parents), - RefNames: parseRefNames(refs), + Hash: full, + ShortHash: short, + Subject: subject, + Body: body, + Author: author, + Email: email, + Date: time.Unix(int64(timestamp), 0), + CommitterName: committerName, + CommitterEmail: committerEmail, + CommitterDate: time.Unix(int64(committerTimestamp), 0), + Parents: strings.Fields(parents), + RefNames: parseRefNames(refs), }) } return commits, nil diff --git a/pkg/git/types.go b/pkg/git/types.go index 1469976..beecfa4 100644 --- a/pkg/git/types.go +++ b/pkg/git/types.go @@ -37,17 +37,20 @@ type Blob struct { } type Commit struct { - Hash string - ShortHash string - Subject string - Body string - Author string - Email string - Date time.Time - Parents []string - Branch Ref - RefNames []RefName - Href string + Hash string + ShortHash string + Subject string + Body string + Author string + Email string + Date time.Time + CommitterName string + CommitterEmail string + CommitterDate time.Time + Parents []string + Branch Ref + RefNames []RefName + Href string } type RefKind string |
