1234module history56import os7import time8import src.storage910const log_marker = '<!-- Koh maintains this file. Do not edit. Read before starting work. -->'11const log_shown = 201213pub fn write_log_md(store &storage.Store, root string) ! {14 path := os.join_path(root, 'LOG.md')15 if os.is_file(path) {16 existing := os.read_file(path)!17 if !existing.starts_with(log_marker) {18 19 return20 }21 }22 saves := line(store)!23 shown := if saves.len < log_shown { saves.len } else { log_shown }24 mut text := '${log_marker}\n\n# Koh Log\n\n'25 for save in saves[..shown] {26 text += '✦ [${save.id}] ${save.message} · ${clock(save.created_at)}\n'27 }28 if saves.len > shown {29 text += '\n… ${saves.len - shown} older saves\n'30 }31 text += '\n*full history: koh log*\n'32 os.write_file(path, text)!33}3435fn clock(unix_seconds i64) string {36 return time.unix(unix_seconds).local().format_ss()37}