summaryrefslogtreecommitdiff
path: root/Hutch/Models/CommitSummary.swift
blob: 88c3e7d8bb30c1bff9a83ceb2789f8a40f503f72 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import Foundation

/// Lightweight commit model for list views. Matches the subset of fields
/// returned by the repository log query.
struct CommitSummary: Codable, Sendable, Identifiable, Hashable {
    let id: String
    let shortId: String
    let author: CommitAuthor
    let message: String

    /// First line of the commit message.
    var title: String {
        message.prefix(while: { $0 != "\n" }).trimmingCharacters(in: .whitespaces)
    }
}

/// A compact author representation used in commit list responses.
struct CommitAuthor: Codable, Sendable, Hashable {
    let name: String
    let email: String?
    let time: Date
}