This commit is contained in:
1 parent
92fbcc8114
commit
7c6d7c610f
2 files changed
+14
-4
No files matched your search
@@ -86,6 +86,7 @@ sync_managed_destination() {
|
|||||||
if [ "$relative" = config.toml ] && [ -f "$target" ]; then
|
if [ "$relative" = config.toml ] && [ -f "$target" ]; then
|
||||||
local plugin_tables local_settings setting_name
|
local plugin_tables local_settings setting_name
|
||||||
local_settings=$(awk '
|
local_settings=$(awk '
|
||||||
|
NR == 1 { sub(/^\357\273\277/, "") }
|
||||||
/^[ \t]*\[/ { exit }
|
/^[ \t]*\[/ { exit }
|
||||||
/^[ \t]*(model|model_reasoning_effort)[ \t]*=/ { print }
|
/^[ \t]*(model|model_reasoning_effort)[ \t]*=/ { print }
|
||||||
' "$target")
|
' "$target")
|
||||||
@@ -95,7 +96,14 @@ sync_managed_destination() {
|
|||||||
setting_name=${setting_name//[[:space:]]/}
|
setting_name=${setting_name//[[:space:]]/}
|
||||||
content=$(printf '%s\n' "$content" | sed "/^[[:space:]]*$setting_name[[:space:]]*=/d")
|
content=$(printf '%s\n' "$content" | sed "/^[[:space:]]*$setting_name[[:space:]]*=/d")
|
||||||
done <<< "$local_settings"
|
done <<< "$local_settings"
|
||||||
content="$content"$'\n'"$local_settings"$'\n'
|
if printf '%s\n' "$content" | grep -qE '^[[:blank:]]*\['; then
|
||||||
|
content=$(printf '%s\n' "$content" | awk -v settings="$local_settings" '
|
||||||
|
!inserted && /^[ \t]*\[/ { print settings; inserted = 1 }
|
||||||
|
{ print }
|
||||||
|
')
|
||||||
|
else
|
||||||
|
content="$content"$'\n'"$local_settings"
|
||||||
|
fi
|
||||||
needs_sub=true
|
needs_sub=true
|
||||||
new_hash=$(sha256_of_string "$content")
|
new_hash=$(sha256_of_string "$content")
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -58,8 +58,8 @@ plugin_state=' [marketplaces.ponytail]
|
|||||||
enabled = true
|
enabled = true
|
||||||
[plugins."disabled@market"]
|
[plugins."disabled@market"]
|
||||||
enabled = false'
|
enabled = false'
|
||||||
printf "model = 'new'\nmodel_reasoning_effort = 'low'\napprovals_reviewer = 'auto_review'\n" > "$source_dir/config.toml"
|
printf "approvals_reviewer = 'auto_review'\n\n[tui]\n" > "$source_dir/config.toml"
|
||||||
printf "model = 'old'\nmodel_reasoning_effort = 'high'\napprovals_reviewer = 'user'\n%s\n[other]\nvalue = true\n" "$plugin_state" > "$destination/config.toml"
|
printf "\357\273\277model = 'old'\nmodel_reasoning_effort = 'high'\napprovals_reviewer = 'user'\n%s\n[other]\nvalue = true\n" "$plugin_state" > "$destination/config.toml"
|
||||||
original_config=$(cat "$destination/config.toml")
|
original_config=$(cat "$destination/config.toml")
|
||||||
sync_managed_destination "$source_dir" "$destination" plugins-dry "" "" "" true > /dev/null
|
sync_managed_destination "$source_dir" "$destination" plugins-dry "" "" "" true > /dev/null
|
||||||
[ "$(cat "$destination/config.toml")" = "$original_config" ] || { printf 'Dry run changed plugin configuration.\n' >&2; exit 1; }
|
[ "$(cat "$destination/config.toml")" = "$original_config" ] || { printf 'Dry run changed plugin configuration.\n' >&2; exit 1; }
|
||||||
@@ -68,7 +68,9 @@ merged_config=$(cat "$destination/config.toml")
|
|||||||
merged_config_normalized=${merged_config//$'\r'/}
|
merged_config_normalized=${merged_config//$'\r'/}
|
||||||
plugin_state_normalized=${plugin_state//$'\r'/}
|
plugin_state_normalized=${plugin_state//$'\r'/}
|
||||||
[[ "$merged_config_normalized" == *"$plugin_state_normalized"* ]] || { printf 'Updating config.toml must preserve local marketplace and plugin tables, including disabled plugins.\n' >&2; exit 1; }
|
[[ "$merged_config_normalized" == *"$plugin_state_normalized"* ]] || { printf 'Updating config.toml must preserve local marketplace and plugin tables, including disabled plugins.\n' >&2; exit 1; }
|
||||||
[[ "$merged_config" == *"model = 'old'"* && "$merged_config" == *"model_reasoning_effort = 'high'"* && "$merged_config" == *"approvals_reviewer = 'auto_review'"* && "$merged_config" != *"model = 'new'"* && "$merged_config" != *"model_reasoning_effort = 'low'"* && "$merged_config" != *"approvals_reviewer = 'user'"* && "$merged_config" != *'[other]'* ]] || { printf 'Updating config.toml must preserve local model settings and enforce automatic review.\n' >&2; exit 1; }
|
[[ "$merged_config" == *"model = 'old'"* && "$merged_config" == *"model_reasoning_effort = 'high'"* && "$merged_config" == *"approvals_reviewer = 'auto_review'"* && "$merged_config" != *"approvals_reviewer = 'user'"* && "$merged_config" != *'[other]'* ]] || { printf 'Updating config.toml must preserve local model settings and enforce automatic review.\n' >&2; exit 1; }
|
||||||
|
[ "$(printf '%s\n' "$merged_config" | grep -n "model = 'old'" | cut -d: -f1)" -lt "$(printf '%s\n' "$merged_config" | grep -n '^\[tui\]$' | cut -d: -f1)" ] || { printf 'Model must remain in TOML root table.\n' >&2; exit 1; }
|
||||||
|
[ "$(printf '%s\n' "$merged_config" | grep -n "model_reasoning_effort = 'high'" | cut -d: -f1)" -lt "$(printf '%s\n' "$merged_config" | grep -n '^\[tui\]$' | cut -d: -f1)" ] || { printf 'Model effort must remain in TOML root table.\n' >&2; exit 1; }
|
||||||
[ "$(cat "$destination/backups/plugins/config.toml")" = "$original_config" ] || { printf 'Original plugin configuration must be backed up.\n' >&2; exit 1; }
|
[ "$(cat "$destination/backups/plugins/config.toml")" = "$original_config" ] || { printf 'Original plugin configuration must be backed up.\n' >&2; exit 1; }
|
||||||
sync_managed_destination "$source_dir" "$destination" plugins-repeat "" "" "" false > /dev/null
|
sync_managed_destination "$source_dir" "$destination" plugins-repeat "" "" "" false > /dev/null
|
||||||
[ "$(cat "$destination/config.toml")" = "$merged_config" ] && [ ! -d "$destination/backups/plugins-repeat" ] || { printf 'Preserving plugin configuration must be idempotent.\n' >&2; exit 1; }
|
[ "$(cat "$destination/config.toml")" = "$merged_config" ] && [ ! -d "$destination/backups/plugins-repeat" ] || { printf 'Preserving plugin configuration must be idempotent.\n' >&2; exit 1; }
|
||||||
|
|||||||
Reference in new issue
Block a user