no-mistakes(test): Fix no-mistakes agent:auto to [pi] migration using sed
This commit is contained in:
1 parent
258dc2afa1
commit
65adb4cceb
1 file changed
+2
-9
@@ -312,16 +312,9 @@ in
|
|||||||
fi
|
fi
|
||||||
# Ensure global config uses Pi (idempotent - only writes if missing or still `agent: auto`)
|
# Ensure global config uses Pi (idempotent - only writes if missing or still `agent: auto`)
|
||||||
cfg="$HOME/.no-mistakes/config.yaml"
|
cfg="$HOME/.no-mistakes/config.yaml"
|
||||||
if [ -f "$cfg" ] && grep -qE '^\s*agent:\s*auto\s*$' "$cfg"; then
|
if [ -f "$cfg" ] && grep -qE '^[[:space:]]*agent:[[:space:]]*auto[[:space:]]*$' "$cfg"; then
|
||||||
tmp="$(mktemp)"
|
tmp="$(mktemp)"
|
||||||
awk '
|
sed 's|^[[:space:]]*agent:[[:space:]]*auto[[:space:]]*$|# Managed by dotfiles/home.nix home.activation.noMistakes\nagent: [pi]|' "$cfg" > "$tmp" && mv "$tmp" "$cfg"
|
||||||
/^\s*agent:\s*auto\s*$/ {
|
|
||||||
print "# Managed by dotfiles/home.nix home.activation.noMistakes";
|
|
||||||
print "agent: [pi]";
|
|
||||||
next
|
|
||||||
}
|
|
||||||
{ print }
|
|
||||||
' "$cfg" > "$tmp" && mv "$tmp" "$cfg"
|
|
||||||
fi
|
fi
|
||||||
if [ ! -f "$cfg" ]; then
|
if [ ! -f "$cfg" ]; then
|
||||||
mkdir -p "$(dirname "$cfg")"
|
mkdir -p "$(dirname "$cfg")"
|
||||||
|
|||||||
Reference in new issue
Block a user