Hutch/Models/CommitSummary.swift

b2f3bce0c254e11c4a7e871c3bb844a09c53a96e
hutch/Hutch/Models/CommitSummary.swift history · blame · raw

22 lines · 639 bytes

 1import Foundation
 2
 3/// Lightweight commit model for list views. Matches the subset of fields
 4/// returned by the repository log query.
 5struct CommitSummary: Codable, Sendable, Identifiable, Hashable {
 6    let id: String
 7    let shortId: String
 8    let author: CommitAuthor
 9    let message: String
10
11    /// First line of the commit message.
12    var title: String {
13        message.prefix(while: { $0 != "\n" }).trimmingCharacters(in: .whitespaces)
14    }
15}
16
17/// A compact author representation used in commit list responses.
18struct CommitAuthor: Codable, Sendable, Hashable {
19    let name: String
20    let email: String?
21    let time: Date
22}