From a03c277f8d9860c8a091ebb8695d021edfd32281 Mon Sep 17 00:00:00 2001 From: openhands Date: Sun, 22 Mar 2026 15:54:35 +0000 Subject: [PATCH] =?UTF-8?q?fix:=20address=20review=20=E2=80=94=20auto-upda?= =?UTF-8?q?te=20TOML=20in=20--yes=20mode,=20use=20python3=20for=20safe=20w?= =?UTF-8?q?rite?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - When --yes is passed with a differing --repo-root, auto-apply the TOML update instead of silently skipping. Prevents stale repo_root in TOML. - Replace sed with python3+re for updating repo_root to avoid delimiter injection from user-supplied paths. Co-Authored-By: Claude Opus 4.6 (1M context) --- bin/disinto | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/bin/disinto b/bin/disinto index aa03dc2..4849b01 100755 --- a/bin/disinto +++ b/bin/disinto @@ -293,15 +293,27 @@ print(cfg.get('primary_branch', '')) repo_root="${existing_root:-/home/${USER}/${project_name}}" elif [ -n "$existing_root" ] && [ "$repo_root" != "$existing_root" ]; then echo "Note: --repo-root (${repo_root}) differs from TOML (${existing_root})" - if [ "$auto_yes" = false ] && [ -t 0 ]; then + local update_toml=false + if [ "$auto_yes" = true ]; then + update_toml=true + elif [ -t 0 ]; then read -rp "Update repo_root in TOML to ${repo_root}? [y/N] " confirm if [[ "$confirm" =~ ^[Yy] ]]; then - sed -i "s|^repo_root.*=.*|repo_root = \"${repo_root}\"|" "$toml_path" - echo "Updated: repo_root in ${toml_path}" + update_toml=true else repo_root="$existing_root" fi fi + if [ "$update_toml" = true ]; then + python3 -c " +import sys, re, pathlib +p = pathlib.Path(sys.argv[1]) +text = p.read_text() +text = re.sub(r'^repo_root\s*=\s*.*$', 'repo_root = \"' + sys.argv[2] + '\"', text, flags=re.MULTILINE) +p.write_text(text) +" "$toml_path" "$repo_root" + echo "Updated: repo_root in ${toml_path}" + fi fi fi