fix(printer,syncer): address Copilot review feedback from PR #26#27
Merged
fix(printer,syncer): address Copilot review feedback from PR #26#27
Conversation
PrintMsgErr and PrintRepoErr were writing to p.writer (stdout)
despite their names and despite the parallel Error method routing
its output to p.errWriter. That meant the gih CLI's error notices
("Failed: <repo>", "Timeout: <repo>") and the final failed/timed-out
repository list landed on stdout — indistinguishable from successful
results when the caller used `2>` to capture errors or `>` to
capture results.
Switch both methods to p.errWriter to match the Error method and the
implicit contract suggested by the *Err naming. Existing tests use
NewPrinter(&buf, &buf) so they keep passing; the new behaviour shows
up only when callers wire distinct writers, which is the use case
this fix enables.
Reported by GitHub Copilot on PR #26.
Co-Authored-By: Claude <noreply@anthropic.com>
failedRepo carried both the repo path and the error returned by the
git invocation, but the error field was never read after assignment.
The per-repo failure reason is already streamed to stderr at execution
time via PrintMsgErr ("Failed: <repo>\n<err>"), and printSummary only
needs the repo path to print the trailing failed-repo list.
Replace the failedRepo struct with a plain []string and update
addFailed and the summary printer accordingly. The test that asserted
on stats.failed[0].Repo becomes stats.failed[0] — same coverage,
slightly cleaner.
Reported by GitHub Copilot on PR #26.
Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
…k line The Success message used "Success: %s\n" while Timeout and Failed used the trailing-newline-free form. Combined with msgTpl's own "\n", the explicit \n in the format string produced an empty line right after every successful repo. The output already includes a visible separator from the Print template, so the extra blank line was pure noise. Drop the \n from the format string. Output now matches the Timeout and Failed shapes: a single line ending in the template's trailing newline. Reported by GitHub Copilot on PR #26. Co-Authored-By: Claude <noreply@anthropic.com>
…doutSideEffect os.Pipe returns two file descriptors. The test was already closing the writer to signal EOF for io.ReadAll, but the read end was leaked on every invocation. One leak per run is harmless on its own; under go test -count=N or as the suite grows it can exhaust the open-file ulimit, especially in CI containers with low limits. Add a deferred Close on the reader. Wrap it in a closure to discard the error explicitly so the errcheck linter stays happy — the close result has no diagnostic value in this test, only the fd release matters. Reported by GitHub Copilot on PR #26. Co-Authored-By: Claude <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Follow-up fixes to address review feedback from PR #26, focusing on output stream correctness (stdout vs stderr), simplifying run failure bookkeeping in the syncer summary, and tightening a small test resource-leak issue. Also adds a repository-wide contributor guideline document (AGENTS.md).
Changes:
- Route error-oriented printer helpers (
PrintMsgErr,PrintRepoErr) toerrWriter(stderr) and align output newline behavior. - Simplify sync execution stats to store only failed repo paths (removing the unused per-repo error field) and update tests accordingly.
- Close the read end of an
os.Pipe()in a test to avoid FD leaks; add AGENTS.md with repo guidelines.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
printer/print.go |
Ensures error printing uses errWriter (stderr) and updates related comments. |
syncer/syncer.go |
Removes dead failedRepo error retention, normalizes success output formatting, and simplifies summary printing. |
syncer/syncer_test.go |
Adapts assertions to the simplified failed []string stats structure. |
syncer/git_test.go |
Fixes an FD leak by closing the pipe read end. |
AGENTS.md |
Adds repository guidelines for structure, workflow, testing, and PR conventions. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Reported by GitHub Copilot on PR #27. Co-Authored-By: Claude <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue
PR #26 (#26) への GitHub Copilot レビューで挙がった 5 件の指摘を解消する follow-up PR。
Overview
PR #26 は既にマージ済みだが、Copilot レビューが 5 件の改善点を指摘しており、いずれも妥当だったため follow-up として対応する。すべて 1 行〜数行レベルの小修正で、スコープは
printer/print.goとsyncer/syncer.go/syncer/git_test.goに閉じる。加えて、コードベース全体に対する AGENTS.md(CLAUDE.md /
.github/copilot-instructions.mdの symlink 元)の追加を別 worktree から cherry-pick で取り込んだ。A. stdout / stderr の振り分け修正(
b852302)Printer.PrintMsgErr/Printer.PrintRepoErrは名前と赤色テンプレートに反してp.writer(stdout) に書いていたPrinter.Errorの挙動と整合させ、両者をp.errWriter経由に変更gih ... 2>err.log >out.logでログ分離が可能に。E2E で stdout にSuccess/Done/Summary、stderr にFailed/Failed repositories:が振り分けられることを確認B. dead code の整理(
ef5be01)failedRepo.ErrフィールドはaddFailedで保存される一方、printSummaryで参照されない dead fieldPrintMsgErr("Failed: %s\n%v", r, err)で stderr に出力済みfailed []stringに簡素化。addFailed(r, err)→addFailed(r)で API も縮小C. 出力フォーマットの整合性(
70ccedc)"Success: %s\n"の末尾\nがmsgTpl末尾の\nと二重で空行を発生させていたTimeout/Failedフォーマットと同じく末尾\nを削除し 1 行で閉じる形に統一Success: r1の直後に空行が無いことをawkで機械的に検証D. テストの fd leak 対策(
f6bea28)TestExistGit_NoStdoutSideEffectのos.Pipe()でr(read 端) が Close されず fd leakdefer func() { _ = r.Close() }()を追加(errcheck回避のため明示的にエラー無視)go test -count=100で "too many open files" 等が起きないことを確認E. AGENTS.md の追加(
7d420ad)AGENTS.mdとして追加CLAUDE.mdと.github/copilot-instructions.mdをそれぞれ symlink にして単一の真実の情報源に集約検証結果
make test(-race): 全テスト PASSgolangci-lint run: 0 issuesmake build: 成功🤖 Generated with Claude Code