feat(printer): redesign output as stacked completion lines + colorized summary table#29
Merged
feat(printer): redesign output as stacked completion lines + colorized summary table#29
Conversation
…n lines and summary table リポジトリごとに 4〜5 行を出力していた既存形式を、Homebrew 風のシンプルな 完了 1 行積み上げ + 末尾の整形テーブルサマリへ刷新。リポジトリ数が増えても スクロール量を抑え、全実行結果を俯瞰しやすくする。 変更内容: - printer: Outcome/Status 型と PrintHeader / PrintRepoLine / PrintSummaryTable / PrintFailureDetails を追加。`text/tabwriter` を 使わず標準ライブラリだけで罫線テーブルを描画する renderTable ヘルパ を実装。旧 Result / Print / Error / PrintCmd / PrintMsgErr / PrintRepoErr は削除。 - syncer: runStats に outcomes []printer.Outcome を追加し、execute 内で 各 goroutine が実行時間・stderr・status を Outcome に詰めて PrintRepoLine を 1 回呼ぶ形へ変更。displayName / firstLine ヘルパを 追加し、execCmd / printSummary は廃止。 - stdout/stderr 分離: 完了行とテーブルは stdout、失敗・タイムアウトの full git stderr と Err.Error() のみ stderr に出すことで、`2>/dev/null` でクリーンなダッシュボードが取り出せる。 - tests: PrintRepoLine / PrintSummaryTable / PrintFailureDetails / PrintHeader 用テスト、displayName のケース別テスト、failure 時に Outcome.Stderr に full stderr が保存されるリグレッションテストを 追加。共有 mutex 検証は PrintRepoLine + PrintFailureDetails 組み合わ せに更新。 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…table テーブル化された Summary 行の Message 列に既に git のエラー1行目 (`fatal: ...` 等) が出ているため、その後 stderr に絶対パス + full git stderr + Err.Error() を再掲する PrintFailureDetails の出力は重複・ 冗長で、リポジトリ数が多いほどスクロール量を増やすだけのノイズとなって いた。完全に廃止し、結果はテーブル + 完了行積み上げのみで完結させる。 変更内容: - printer: PrintFailureDetails メソッド本体を削除。Outcome.Stderr / Printer.errWriter フィールドの消費先がなくなるためまとめて削除し、 NewPrinter のシグネチャを `NewPrinter(writer io.Writer)` に簡略化。 - syncer: Run() からの PrintFailureDetails 呼び出しを 1 行削除。 execute() 内 `o.Stderr = errMsg` 代入 (timeout / failed の 2 箇所) を削除。 - gih: ローカル変数 errWriter を削除し NewGitter には os.Stderr を直接 渡す。NewPrinter は writer 単一引数で呼ぶ。 - tests: TestPrinter_PrintFailureDetails_HasFullStderr と TestPrinter_SharedMutex_AcrossWriterAndErrWriter を削除。 TestPrinter_MixedPrints_ConcurrentSafe の case 4 削除し switch を 4 ケースに。NewPrinter を呼んでいる全テスト (printer 側 + syncer/syncer_test.go の newSyncWithFake) を新シグネチャに追従。 TestSync_Execute の `failure preserves full stderr in Outcome.Stderr` サブテストも削除。 Exit code は summary.HasFailures() で 2 を返す挙動を維持。 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…mary table サマリテーブルで失敗/タイムアウト行を視覚的に識別しやすくするため、 fatih/color による行全体の着色を導入する。 実装: - rowColorFor(Status) を追加。StatusFailed → 赤、StatusTimeout → 黄、 StatusSuccess → nil (色付けなし) を返す。 - renderTable に rowColors []func(string) string 引数を追加。各行を buildRow で組み立てた後、対応する rowColors[i] が non-nil なら そのデコレータを適用してから writeLine。 - 色付けは padding/幅計算の後に適用するため ANSI エスケープが utf8.RuneCountInString に混入せず、テーブル整列は崩れない。 - 行全体(罫線 `|` 含む)に色を適用する方式を採用。失敗・タイムアウト 行が一目で識別でき、成功行は通常色のまま。 テスト: - TestRowColorFor を追加。Success → nil / Failed/Timeout → non-nil で 原文字列が保持されることを検証。ANSI バイト列に依存しないため、 fatih/color の TTY 検出 (NoColor) のグローバル状態に左右されない。 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR redesigns gih's user-facing output flow: repository execution now streams as one completion line per repo, then ends with a compact summary table. The change fits the codebase by moving more presentation logic into printer while syncer now builds structured per-repo outcomes.
Changes:
- Replaced the old multi-line per-repo printer API with
Outcome/Summary-based rendering, including a bordered summary table. - Changed
syncerto collect per-repo execution metadata (status, duration, message) and print the new header/summary flow. - Simplified printer construction to a single output writer and updated tests around the new output model.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
syncer/syncer.go |
Refactors execution to build printer.Outcome values, print one-line repo results, and emit the final summary table. |
syncer/syncer_test.go |
Updates syncer tests for outcome collection and adds coverage for displayName. |
printer/print.go |
Replaces template-based printing with structured line/table rendering, status coloring, and duration/message formatting helpers. |
printer/print_test.go |
Rewrites printer tests around the new API and concurrent rendering behavior. |
gih/main.go |
Adapts CLI wiring to the simplified printer constructor while keeping stderr for git execution errors. |
…isplayName Co-Authored-By: Claude Opus 4.7 (1M context) <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
なし(運用フィードバックから派生した出力フォーマットの再設計)
Overview
gih <git-cmd>の出力をリポジトリごとに 4〜5 行出すスタイルから、Homebrew 風の「完了 1 行積み上げ + 末尾のテーブルサマリ」に再設計しました。29 リポジトリ規模での実行時のスクロール量を大幅に削減し、結果の俯瞰と失敗の視覚的識別を改善します。3 つのコミットで段階的に実装:
1. テーブル化 (
19b8c59)リポジトリごとに
path / message / Success: / Done: N/Mの 4〜5 行を出していた既存形式を、Homebrew 風の✓ <repo> <message> <duration>1 行 + 末尾の整形テーブルサマリに刷新しました。printerパッケージにOutcome/Status/Summary型と新メソッド (PrintHeader/PrintRepoLine/PrintSummaryTable/PrintFailureDetails) を追加text/tabwriter不使用) で+----+|の罫線テーブルを描画するrenderTableを実装syncer側で goroutine ごとに実行時間を計測しOutcomeを構築する形に変更Result/Print/Error/PrintCmd/PrintMsgErr/PrintRepoErrは削除2. 冗長な失敗詳細出力の排除 (
cfc6753)テーブル直後に stderr へ出ていた
==> Failed: <絶対パス>+ full git stderr + Err.Error() のブロックは、Message 列に既に出ているエラー 1 行目と重複しスクロールを増やすだけだったため完全に廃止しました。PrintFailureDetailsメソッドを削除Outcome.Stderr/Printer.errWriterフィールドも削除NewPrinter(writer io.Writer)に第 2 引数を削除しシグネチャ簡略化3. 失敗・タイムアウト行の着色 (
db33597)サマリテーブルで失敗行を赤、タイムアウト行を黄色に着色し、視覚的な識別性を向上させました。
rowColorFor(Status)を追加(StatusFailed → 赤、StatusTimeout → 黄、StatusSuccess → nil)renderTableにrowColors []func(string) string引数を追加期待される出力
動作確認
make build/make test(-race) /make lint全 passpull origin masterを実行し、19 失敗ケースで出力が完了行 + テーブルのみで完結することを確認script -q経由で pty 強制実行し、失敗行に\x1b[31m、タイムアウト行に\x1b[33mの ANSI エスケープが適用されアラインメントが保たれることを確認summary.HasFailures()経由で 0 / 2 を返す挙動を維持🤖 Generated with Claude Code