Repository navigation
fix: 読めない・UTF-8 でないグローバル設定も警告して既定値を使う - #136
Merged
Merged
Conversation
グローバル設定ファイルが UTF-8 として読めない (例: Windows PowerShell 5.1 の > で書いた UTF-16) と、depup は警告を出さずにファイルを無視し、既定の 設定で動いていた。age を既定より長くしていても、警告なしに既定の age で 更新先を選んでいた。読み込みに失敗したとき (権限がないなど) も同じだった。 global_config.rs の GlobalConfig::load_from は read_to_string(path).ok()? で 読み、読めない内容を「設定がない」と同じに扱っていた。TOML として解釈できない ときは警告を出すのに、UTF-8 として読めないときと、読み込みに失敗したときは 警告がなかった。 - 読み込みと解釈を GlobalConfig::read_from に分け、読み込めない・UTF-8 で ない・TOML として解釈できないときは、どれも警告の文言を返す。load_from は これまでどおり警告して組み込みの既定値を使う。UTF-8 でないときの警告には、 UTF-8 で保存するよう書く。 - docs/configuration (英語・日本語) と AGENTS.md に書いた。 テスト: UTF-16 の設定と、読み込めないパス (ディレクトリ) は警告の文言を返す こと。同じ内容の UTF-8 (BOM 付き) は読めること。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars.
|
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.
概要
グローバル設定ファイルが UTF-8 として読めない (例: Windows PowerShell 5.1 の
>で書いた UTF-16) と、depup は警告を出さずにファイルを無視し、既定の設定で動いていました。ageを既定より長くしていても、警告なしに既定の age で更新先を選んでいました。読み込みに失敗したとき (権限がないなど) も同じでした。解釈できないときと同じく警告します。原因
global_config.rsのGlobalConfig::load_fromはstd::fs::read_to_string(path).ok()?で読み、読めない内容を「設定がない」と同じに扱っていました。TOML として解釈できないときは警告を出すのに、UTF-8 として読めないときと、読み込みに失敗したときは警告がありませんでした。変更内容
GlobalConfig::read_fromに分け、読み込めない・UTF-8 でない・TOML として解釈できないときは、どれも警告の文言を返す。load_fromはこれまでどおり警告して組み込みの既定値を使う。UTF-8 でないときの警告には、UTF-8 で保存するよう書く。検証
global_config::tests::unreadable_or_non_utf8_global_config_is_reported(UTF-16 の設定と、読み込めないパス (ディレクトリ) は警告の文言を返し、同じ内容の UTF-8 (BOM 付き) は読める。新しい関数を使うので、修正前のコードではコンパイルできない。修正前はread_to_string(...).ok()?がNoneを返し、警告なしに既定値を使っていた)cargo fmt --all -- --check: passcargo clippy --locked --all-targets -- -D warnings: passcargo test --locked(Windows): passCloses #123
🤖 Generated with Claude Code