git log prints UTC wall-clock time next to the author's timezone offset, so the Date line is off by the offset for every non-UTC author
Describe the bug
runGitCli(["log"]) formats commit dates by rendering the timestamp with d.toISOString() (always UTC wall clock) and then appending the ±hhmm offset derived from the author's timezoneOffset. The wall clock is never shifted into that zone, so the printed string denotes an instant that is wrong by exactly the offset.
Location: packages/computer/src/git/cli.ts:828-843 (formatGitTimestamp), reached from formatLogFull (cli.ts:812-826). CommitView.author passes isomorphic-git's timezoneOffset straight through (reads.ts:121).
Commits created inside workerd are UTC (offset 0) and render fine, which is why the suite doesn't catch it. But git log over any cloned repo (the main log use case) shows wrong times for every non-UTC author.
Expected behavior
Real git for the identical commit (GIT_AUTHOR_DATE="1700000000 +0530", git log --date=iso):
Date: 2023-11-15 03:43:20 +0530
i.e. wall clock shifted into the author's zone, then the offset appended.
Steps to reproduce
End-to-end with the package's own plumbing: create an isomorphic-git commit with author: { timestamp: 1_700_000_000, timezoneOffset: -330 } (isomorphic-git uses the Date.getTimezoneOffset() minutes-west convention; -330 is +0530 on the wire, which is what a clone of any IST-authored repo yields), read it back through logWith, render through runGitCli(["log"]). Actual output:
raw author: {"name":"A","email":"a@x","timestamp":1700000000,"timezoneOffset":-330}
stdout: "commit fd95...\nAuthor: A <a@x>\nDate: 2023-11-14 22:13:20 +0530\n..."
2023-11-14 22:13:20 +0530 parses to 2023-11-14T16:43:20Z, which is 5.5 hours before the actual commit instant (2023-11-14T22:13:20Z). The offset sign handling is already correct; only the wall clock is unshifted.
Impact
Anything reading the Date: line (a human, or an agent parsing log output through the shell backend) gets a timestamp wrong by up to ±14 hours for commits authored outside UTC.
Proposed fix
Shift the epoch into the author's zone before formatting: const local = new Date((timestamp + offsetMinutes * 60) * 1000) and format local with the existing toISOString() pipeline, keeping the already-correct ±hhmm suffix. While there, the module's "minutes east of UTC" comments describe the opposite of isomorphic-git's convention (minutes west), which the code's negation already assumes; worth correcting in the same pass.
Environment
cloudflare/computerat76d9e75(currentmain), local checkout- Comparison output produced with real git on the same machine
- Node v22.18.0, Windows 11 (platform-independent)
💡📌 消费失败进死信后怎么人工修
✨⚙️ 回滚预案写在 runbook 里了吗
🤝 flaky test 怎么治理的
代码风格统一,review 压力小 ✨
工具调用失败怎么回滚状态 📦
Confirmed at 76d9e75, with a patch and failing-first tests if useful.
Root cause. formatGitTimestamp (packages/computer/src/git/cli.ts:828) builds its Date from the raw epoch at :833 and renders with toISOString() at :840, which is always UTC, then appends a ±hhmm suffix computed from the offset. The wall clock and the suffix therefore describe two different instants, off by exactly the offset. The sign handling at :834-838 is already correct.
Wider than reported: this hits git show too. formatLogFull (:812-826) backs both git log (:800) and git show (:870), so both print the wrong Date:.
Replaying the math (timestamp = 1_700_000_000 = 2023-11-14T22:13:20Z):
timezoneOffset |
suffix | current | correct |
|---|---|---|---|
-330 (IST) |
+0530 |
2023-11-14 22:13:20 +0530 ✗ |
2023-11-15 03:43:20 +0530 |
480 (PST) |
-0800 |
2023-11-14 22:13:20 -0800 ✗ |
2023-11-14 14:13:20 -0800 |
0 |
+0000 |
2023-11-14 22:13:20 +0000 ✓ |
unchanged |
Offset 0 being the only correct case is why the existing fixtures never caught it — cli.test.ts:1006 and :1012 both hardcode timezoneOffset: 0, and the full-form test asserts commit/Author/message but never the Date: line.
Note the IST case rolls the calendar date forward a day, so the fix has to shift the whole Date, not just the time-of-day.
Fix is to compute offsetMinutes before constructing the date and shift the instant: new Date((timestamp + offsetMinutes * 60) * 1000). The suffix pipeline is untouched. The doc comment at :829-832 also has the convention backwards — isomorphic-git stores minutes west, per Date.getTimezoneOffset(), which is exactly why the code negates it.
Three tests added: IST, PST, and a UTC case that passes at both shas as a guard against over-correcting the sign. Whole src/git suite: 305 passing.
One scope note: this module emits YYYY-MM-DD HH:MM:SS ±hhmm (git's --date=iso), not git's default Wed Nov 15 03:43:20 2023 +0530. The patch corrects the wall clock and preserves that existing choice; converging on git's actual default would be a separate change.
Branch: https://github.com/3x3xX3N0N/computer/tree/fix/git-log-author-timezone — not opening a PR, per CONTRIBUTING.md.