Skip to content

refactor(gih): clean up version handling and arg formatting#28

Merged
takecy merged 1 commit into
masterfrom
feat/main-cleanup
Apr 26, 2026
Merged

refactor(gih): clean up version handling and arg formatting#28
takecy merged 1 commit into
masterfrom
feat/main-cleanup

Conversation

@takecy
Copy link
Copy Markdown
Owner

@takecy takecy commented Apr 26, 2026

Issue

tasks/improvements-review-2026-04-26.md 残課題 #13(13 項目中 12 完了の最後の 1 項目)。gih/main.go の軽微なクリーンアップ。

Overview

gih/main.go の 3 サブ項目に対応。ユーザー機能影響ゼロの純粋な保守性向上。

変更内容

  1. goversionruntime.Version()

    • ハードコードされた goversion = "1.26.2" 変数を削除
    • gih version の go バージョン表示を runtime.Version() の戻り値に変更
    • 手動更新で腐るリスクを排除し、実行している Go ランタイムのバージョンを正確に表示
  2. 出力フォーマットの 2 スペースを 1 スペースに統一

    • args: 出力行の concurrency: / timeout: 前の 2 スペースを 1 スペースに統一
    • 旧: targetDir: %s ignoreDir: %s concurrency: %d timeout: %v
    • 新: targetDir: %s ignoreDir: %s concurrency: %d timeout: %v
  3. subcommand を if から switch + printVersion() 関数に整理

    • if flag.Arg(0) == "version"switch 文に変更
    • version 表示処理を printVersion() 関数に切り出し
    • 将来 subcommand を追加する際の差分が case "X": runX() の 1 行で済む形に

検証

  • make build && make test && make lint すべてグリーン
  • E2E:
    • gih_dev versiongit-here '0.0.1-test' + go version go1.26.2
    • gih_dev --target "^x" --ignore "^y" statusargs: targetDir: ^x ignoreDir: ^y concurrency: N timeout: 20s(1 スペース統一)
    • 通常 git command(gih_dev fetch 等)は switch を通過して syncer に正常委譲
    • 引数なし → flag.Usage() 表示で exit 1

🤖 Generated with Claude Code

Co-Authored-By: Claude <noreply@anthropic.com>
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Refactors gih/main.go to make version reporting and argument logging less error-prone and easier to extend with future subcommands, without changing the core sync behavior.

Changes:

  • Remove the hardcoded goversion variable and print the Go runtime version via runtime.Version().
  • Normalize the args: log line spacing to single spaces.
  • Replace the if subcommand check with a switch and extract version printing into printVersion().

@takecy takecy marked this pull request as ready for review April 26, 2026 08:18
@takecy takecy merged commit 8a1eb4f into master Apr 26, 2026
6 checks passed
@takecy takecy deleted the feat/main-cleanup branch April 26, 2026 08:18
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