(input: BuildEditHistoryEntryInput)
| 82 | } |
| 83 | |
| 84 | export function buildEditHistoryEntry(input: BuildEditHistoryEntryInput): EditHistoryEntry { |
| 85 | const files: Record<string, EditHistoryFileSnapshot> = {}; |
| 86 | for (const [path, snapshot] of Object.entries(input.files)) { |
| 87 | if (snapshot.before === snapshot.after) continue; |
| 88 | files[path] = { |
| 89 | before: snapshot.before, |
| 90 | after: snapshot.after, |
| 91 | beforeHash: hashEditHistoryContent(snapshot.before), |
| 92 | afterHash: hashEditHistoryContent(snapshot.after), |
| 93 | }; |
| 94 | } |
| 95 | |
| 96 | return { |
| 97 | id: input.id, |
| 98 | projectId: input.projectId, |
| 99 | label: input.label, |
| 100 | kind: input.kind ?? "manual", |
| 101 | coalesceKey: input.coalesceKey, |
| 102 | createdAt: input.now, |
| 103 | files, |
| 104 | }; |
| 105 | } |
| 106 | |
| 107 | export function pushEditHistoryEntry( |
| 108 | state: EditHistoryState, |
no test coverage detected