Skip to content

refactor(log): split graph renderer and date formatting out of log.mbt#136

Merged
mizchi merged 1 commit into
mainfrom
claude/bold-mendel-2d7ygx
Jul 6, 2026
Merged

refactor(log): split graph renderer and date formatting out of log.mbt#136
mizchi merged 1 commit into
mainfrom
claude/bold-mendel-2d7ygx

Conversation

@mizchi

@mizchi mizchi commented Jul 6, 2026

Copy link
Copy Markdown
Member

Summary

cmd/bit/log.mbt had grown to 7586 lines. This splits two cohesive, self-contained clusters into their own files within the same package (no visibility or import changes — MoonBit packages span all .mbt files in a directory). Pure code motion; behavior is unchanged.

  • log_graph.mbt (714 lines): the --graph renderer — GitGraph struct plus all graph_* functions, a faithful port of git's graph.c state machine. Driven by log_emit_commit_graph (still in log.mbt).
  • log_datefmt.mbt (150 lines): pure timestamp/calendar helpers (epoch↔calendar conversion, timezone offset parsing, the git --date output modes). The format_date_by_mode dispatcher stays in log.mbt.

log.mbt drops from 7586 → 6732 lines. Both new files are registered in moon.pkg as native-only.

Verification

  • moon check --target native: 0 errors (same 221 pre-existing deprecation warnings as baseline)
  • moon build --target native --release: exit 0, links bit.exe via /usr/bin/cc
  • Exercised the moved code paths on the real binary:
    • bit log --graph renders the merge graph art correctly (log_graph.mbt)
    • bit log --date=rfc2822 / --date=iso produce correct output (log_datefmt.mbt)

🤖 Generated with Claude Code


Generated by Claude Code

log.mbt had grown to ~7.6k lines. Extract two cohesive, self-contained
clusters into sibling files in the same package (no visibility changes):

- log_graph.mbt: the `--graph` renderer (GitGraph state machine, a faithful
  port of git's graph.c). Driven by log_emit_commit_graph, which stays in
  log.mbt.
- log_datefmt.mbt: pure timestamp/calendar helpers (epoch<->calendar,
  timezone offset parsing, git date output modes).

Pure code motion; behavior is unchanged. `moon check --target native`
passes with 0 errors and moonc codegen succeeds. log.mbt drops from
7586 to 6732 lines.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WHFC6qxKjqjrixgjFtGihM
@mizchi mizchi merged commit b403809 into main Jul 6, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants