Answer stability round 1: 2 🔴, 3 🟡; anchor .gitattributes to the root settings.json, sort the new imports, isolate the checkout tests from the host's git, start a new install's Update at git fetch, fix the filter's docstring
This commit is contained in:
+13
-5
@@ -3,22 +3,30 @@
|
||||
|
||||
Claude Code rewrites settings.json, in its own key order, whenever a model is
|
||||
picked or a plugin installed. Each machine owns its model, so git stores the
|
||||
file without it, and neither write shows as a change.
|
||||
file without it, and neither write reaches a commit.
|
||||
"""
|
||||
import json
|
||||
import sys
|
||||
|
||||
|
||||
def cleaned(written: str) -> str:
|
||||
"""settings.json as git stores it: without "model", every key sorted."""
|
||||
"""settings.json as git stores it: without "model", every key sorted. ValueError where it holds no JSON object."""
|
||||
settings = json.loads(written)
|
||||
if not isinstance(settings, dict):
|
||||
raise ValueError("settings.json holds no JSON object")
|
||||
settings.pop("model", None)
|
||||
return json.dumps(settings, ensure_ascii=False, indent=2, sort_keys=True) + "\n"
|
||||
|
||||
|
||||
def main() -> None:
|
||||
sys.stdout.write(cleaned(sys.stdin.read()))
|
||||
def main() -> int:
|
||||
# On a non-zero exit git warns and stores the file as written.
|
||||
try:
|
||||
sys.stdout.write(cleaned(sys.stdin.read()))
|
||||
except ValueError as error:
|
||||
print(f"settings_filter.py: {error}", file=sys.stderr)
|
||||
return 1
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
sys.exit(main())
|
||||
|
||||
Reference in New Issue
Block a user