Skip to content

refactor(ansible): compare the version of the installed command - #152

Merged
soblin merged 2 commits into
mainfrom
fix/compare-command-version
Aug 21, 2026
Merged

soblin merged 2 commits into
mainfrom
fix/compare-command-version

Conversation

@soblin

@soblin soblin commented Aug 21, 2026

Copy link
Copy Markdown
Owner

変更

install済みcommandのversionをversion stamp fileで管理するのをやめ、command自身の --version の出力と versions.yaml を直接比較するようにした。stampはplaybookが「installしたと思っているversion」でしかなく、実際に置かれているものとdriftしうる(#151 がまさにそれ)。

command --version の出力 pin 取り出し方
difft Difftastic 0.70.0 (複数行の1行目) 0.70.0 semverをregex_search
act act version 0.2.89 v0.2.89 semverをregex_search
ghq ghq version 1.10.1 (rev:f600896) v1.10.1 semverをregex_search
lsd lsd 1.2.0 v1.2.0 semverをregex_search
btm bottom 0.14.8 0.14.8 semverをregex_search
wezterm wezterm 20240203-110809-5046fc22 同左 semverではないので最終fieldを使う
  • ghqは末尾にrevが付くので単純な最終field取得では壊れる。difftは複数行なので1行目に限定する。
  • v 付きでpinしているものだけ regex_replace('^v', '') してから比較する。
  • commandが無い場合は stdout が空になり比較が一致しないのでinstallが走る。which によるcheckは不要になったので削除した。
  • verify taskも which ではなくversionの一致をcheckする。installしたのに版が合わない場合はその場でplaybookが失敗するので、fix(ansible): download the archive of the pinned version #151 のような「静かに古いまま」が起きない。
  • stamp機構を使うものが無くなったので、version_stamp_dir 変数と xdg_base_directory のstamp dir作成taskを削除した。READMEも更新。

確認

difftで3ケース:

1. 既に最新          -> changed=0, install blockがskip
2. 古いversionを指定 -> 0.70.0 から 0.67.0 へ入れ替わる
3. commandを消す     -> installが走り 0.70.0 が入る

lsd / btm / wezterm は一致時にskipされること、および不一致時にinstall blockへ入ることを確認(実際のinstallはdowngrade/存在しないtagなので想定通り失敗する)。

🤖 Generated with Claude Code

https://claude.ai/code/session_018aVdWSLTWB8VmHUBKgBVcN

Base automatically changed from fix/stale-download-cache to main August 21, 2026 17:54
soblin and others added 2 commits August 22, 2026 02:55
difft, act and ghq print their version, so ask the command itself
instead of keeping a version stamp file. A stamp records what the
playbook believed it installed, which can drift from what is actually
on disk.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018aVdWSLTWB8VmHUBKgBVcN
lsd, btm and wezterm also print their version, so the version stamp
mechanism is no longer used by anything and is removed.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018aVdWSLTWB8VmHUBKgBVcN
@soblin
soblin force-pushed the fix/compare-command-version branch from 28cd5af to 3aaa1c0 Compare August 21, 2026 17:55
@soblin
soblin enabled auto-merge (squash) August 21, 2026 17:58
@soblin
soblin merged commit 15cc1a6 into main Aug 21, 2026
6 checks passed
@soblin
soblin deleted the fix/compare-command-version branch August 21, 2026 18:02
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.

1 participant