提交记录修改agent-vm.setup.sh+2 −1看文件
修改lib/git.sh+10 −10看文件
修改lib/mounts.sh+2 −2看文件
修改tests/06-help-and-setup-script.sh+4 −2看文件
修改tests/14-git-protection.sh+16 −5看文件
修改tests/18-windows.sh+3 −0看文件
| @@ -404,7 +404,8 @@ code_server_schemas() { | ||
| 404 | 404 | continue |
| 405 | 405 | fi |
| 406 | 406 | cat "$f.entry" >> "$dir/entries" |
| 407 | 删除: base="$(jq -r '(."$id" // .id // empty) | strings | select(test("^https?://"))' "$f")" | |
| 407 | 新增: # A schema may be true or false, which has no $id to read. | |
| 408 | 新增: base="$(jq -r 'objects | (."$id" // .id // empty) | strings | select(test("^https?://"))' "$f")" | |
| 408 | 409 | [[ -n "$base" ]] || base="$u" |
| 409 | 410 | while IFS= read -r r; do |
| 410 | 411 | r="$(schema_url_resolve "$base" "$r")" && next+=("$r") |
| @@ -313,23 +313,23 @@ _agent_vm_scan_risk() { | ||
| 313 | 313 | } |
| 314 | 314 | |
| 315 | 315 | # The risk lines of the config of the repository <at> of kind <kind>, whose |
| 316 | 删除:# work tree is <top> (see _agent_vm_git_at): its own config, or git's global | |
| 317 | 删除:# and system config for G. Config files in a share, included ones whether | |
| 318 | 删除:# they exist yet or not (git skips a missing one, and the VM can create it). | |
| 319 | 删除:# Settings whose command a share holds: a path in their value, relative to | |
| 320 | 删除:# the top of the repository, where git runs most of them (git's own config | |
| 321 | 删除:# has none to take them from). awk sorts the config first, so the shell only | |
| 316 | 新增:# work tree is <top> (see _agent_vm_git_at): every scope git reads there | |
| 317 | 新增:# (system, global, local, worktree), or git's global and system config alone | |
| 318 | 新增:# for G. Config files in a share, included ones whether they exist yet or not | |
| 319 | 新增:# (git skips a missing one, and the VM can create it). Settings whose command | |
| 320 | 新增:# a share holds: a path in their value, relative to the top of the | |
| 321 | 新增:# repository, where git runs most of them, a global alias included (G has no | |
| 322 | 新增:# repository to take them from). awk sorts the config first, so the shell only | |
| 322 | 323 | # sees each file once and the settings that hold a command (section and key |
| 323 | 324 | # names lowercased, as `git config --list` prints them) with a path in their |
| 324 | 325 | # value: a start runs this, and a fork per line would show. |
| 325 | 326 | _agent_vm_scan_config() { |
| 326 | 删除: local kind="$1" at="$2" cmd_base="$3" base=/ scope=--local k a b c w shown | |
| 327 | 新增: local kind="$1" at="$2" cmd_base="$3" base=/ k a b c w shown | |
| 327 | 328 | case "$kind" in |
| 328 | 329 | W) base="$(_agent_vm_git_spelling "$at")" || return 0 ;; |
| 329 | 330 | B) cmd_base="$at" ;; |
| 330 | 删除: *) scope="" ;; | |
| 331 | 331 | esac |
| 332 | 删除: _agent_vm_git_at "$kind" "$at" config --list ${scope:+"$scope"} --show-origin --includes 2>/dev/null \ | |
| 332 | 新增: _agent_vm_git_at "$kind" "$at" config --list --show-origin --includes 2>/dev/null \ | |
| 333 | 333 | | awk -F '\t' ' |
| 334 | 334 | { |
| 335 | 335 | origin = $1; kv = substr($0, length($1) + 2); f = "" |
| @@ -593,7 +593,7 @@ _agent_vm_sha256_sums_check() { | ||
| 593 | 593 | echo "Error: no checksum listed for $f." >&2 |
| 594 | 594 | return 1 |
| 595 | 595 | fi |
| 596 | 删除: actual="$(_agent_vm_sha256 < "$dir/$f" 2>/dev/null | cut -d' ' -f1)" | |
| 596 | 新增: actual="$( { _agent_vm_sha256 < "$dir/$f"; } 2>/dev/null | cut -d' ' -f1)" | |
| 597 | 597 | if [[ -z "$actual" || "$actual" != "$expected" ]]; then |
| 598 | 598 | echo "Error: checksum mismatch for $f (expected $expected, got ${actual:-unreadable})." >&2 |
| 599 | 599 | return 1 |
| @@ -438,7 +438,7 @@ _agent_vm_protection_why() { | ||
| 438 | 438 | _agent_vm_hostagent_is_limactl() { |
| 439 | 439 | local pid="" exe="" run="" mine |
| 440 | 440 | _agent_vm_on_windows && return 0 |
| 441 | 删除: read -r pid < "$(_agent_vm_lima_home)/$1/ha.pid" 2>/dev/null | |
| 441 | 新增: { read -r pid < "$(_agent_vm_lima_home)/$1/ha.pid"; } 2>/dev/null | |
| 442 | 442 | [[ "$pid" =~ ^[0-9]+$ ]] || return 0 |
| 443 | 443 | if [[ -e "/proc/$pid/exe" ]]; then |
| 444 | 444 | exe="$(readlink "/proc/$pid/exe" 2>/dev/null)" |
| @@ -468,7 +468,7 @@ _agent_vm_sshfs_cache_mode() { | ||
| 468 | 468 | # by _agent_vm_apply_shares). |
| 469 | 469 | _agent_vm_mounts_sshfs_current() { |
| 470 | 470 | local mode="" |
| 471 | 删除: read -r mode < "$AGENT_VM_STATE_DIR/.agent-vm-sshfs-cache-$1" 2>/dev/null | |
| 471 | 新增: { read -r mode < "$AGENT_VM_STATE_DIR/.agent-vm-sshfs-cache-$1"; } 2>/dev/null | |
| 472 | 472 | [[ "$mode" == "$(_agent_vm_sshfs_cache_mode)" ]] |
| 473 | 473 | } |
| 474 | 474 | |
| @@ -240,7 +240,9 @@ else | ||
| 240 | 240 | # a: an absolute ref, a relative one with ./ and a fragment, a local one, |
| 241 | 241 | # and one to the editor's own schemas. |
| 242 | 242 | echo '{"$ref":"#/definitions/x","definitions":{"x":{"$ref":"https://h.test/abs.json"},"y":{"$ref":"./rel.json#/z"},"z":{"$ref":"vscode://schemas/settings"},"w":{"properties":{"$ref":{"type":"string"}}}}}' > "$SCH/web/$(web https://h.test/s/a)" |
| 243 | 删除: echo '{"type":"object"}' > "$SCH/web/$(web https://h.test/abs.json)" | |
| 243 | 新增: # abs refers to a schema that is no object: true is a valid schema. | |
| 244 | 新增: echo '{"type":"object","properties":{"t":{"$ref":"https://h.test/true.json"}}}' > "$SCH/web/$(web https://h.test/abs.json)" | |
| 245 | 新增: echo 'true' > "$SCH/web/$(web https://h.test/true.json)" | |
| 244 | 246 | echo '{"$ref":"../top.json"}' > "$SCH/web/$(web https://h.test/s/rel.json)" |
| 245 | 247 | echo '{"type":"string"}' > "$SCH/web/$(web https://h.test/top.json)" |
| 246 | 248 | echo '{"type":"number"}' > "$SCH/web/$(web https://www.schemastore.org/b)" |
| @@ -273,7 +275,7 @@ else | ||
| 273 | 275 | code_server_schemas "$SCH/ext" "$SCH/machine/settings.json"; echo "rc=$?" ) 2>&1)" |
| 274 | 276 | check "every schema named, and every one they refer to, by the URL the editor asks" \ |
| 275 | 277 | "$(jq -r '."json.schemas"[].url' "$SCH/machine/settings.json" 2>/dev/null | sort | tr '\n' ' ')" \ |
| 276 | 删除: "https://h.test/abs.json https://h.test/s/a https://h.test/s/a/b/d.json https://h.test/s/c.json https://h.test/s/rel.json https://h.test/top.json https://json.schemastore.org/b https://json.schemastore.org/eslintrc.json https://www.schemastore.org/package " | |
| 278 | 新增: "https://h.test/abs.json https://h.test/s/a https://h.test/s/a/b/d.json https://h.test/s/c.json https://h.test/s/rel.json https://h.test/top.json https://h.test/true.json https://json.schemastore.org/b https://json.schemastore.org/eslintrc.json https://www.schemastore.org/package " | |
| 277 | 279 | check "a level of references fetched in one call" "$(wc -l < "$SCH/calls" | tr -d ' ')" "3" |
| 278 | 280 | check "each with its content" \ |
| 279 | 281 | "$(jq -r '."json.schemas"[] | select(.url == "https://h.test/top.json") | .schema.type' "$SCH/machine/settings.json" 2>/dev/null)" "string" |
| @@ -344,7 +344,7 @@ rm -f "$CACHE_MODE" | ||
| 344 | 344 | out="$(rec run true)" |
| 345 | 345 | rec_has "edit $PV" && fail "cache: a running VM was changed" || pass "cache: a running VM is left as it is" |
| 346 | 346 | rec_has "stop $PV" && fail "cache: a running VM was stopped" || pass "cache: and not stopped" |
| 347 | 删除:case "$out" in *Warning*) fail "cache: a running VM warned about: $out" ;; *) pass "cache: and nothing said" ;; esac | |
| 347 | 新增:case "$out" in *Warning*|*"No such file"*) fail "cache: a running VM warned about: $out" ;; *) pass "cache: and nothing said" ;; esac | |
| 348 | 348 | AGENT_VM_TEST_STOPPED=1 rec run true >/dev/null |
| 349 | 349 | rec_has "edit $PV --set .mountType = \"reverse-sshfs\" | .mounts = [{$(mnt "$PROJ"), \"writable\": true, $SSHFS_RO}]" \ |
| 350 | 350 | && pass "cache: a stopped VM gets its shares with the cache off" || fail "cache: not updated: $(grep '^edit' "$REC")" |
| @@ -433,7 +433,7 @@ else | ||
| 433 | 433 | fi |
| 434 | 434 | rm -f "$(_agent_vm_lima_home)/$PV/ha.pid" "$(_agent_vm_lima_home)/$PV/lima.yaml" |
| 435 | 435 | out="$(rec run true)" |
| 436 | 删除: case "$out" in *"another limactl"*) fail "hostagent: no pid file, warned anyway" ;; *) pass "hostagent: when it cannot tell, nothing is said" ;; esac | |
| 436 | 新增: case "$out" in *"another limactl"*|*"No such file"*) fail "hostagent: no pid file, warned anyway: $out" ;; *) pass "hostagent: when it cannot tell, nothing is said" ;; esac | |
| 437 | 437 | fi |
| 438 | 438 | |
| 439 | 439 | # core.hooksPath in the project: its first component joins the names. |
| @@ -493,10 +493,10 @@ if command -v git >/dev/null 2>&1; then | ||
| 493 | 493 | ( _agent_vm_fs_nocase() { return 1; }; _agent_vm_rel_in /Work/Proj/x /work/proj ) >/dev/null \ |
| 494 | 494 | && fail "a path in other capitals counted as inside where case matters" \ |
| 495 | 495 | || pass "and not where case matters" |
| 496 | 删除: # The same through a whole scan. | |
| 497 | 删除: hp "$(printf '%s' "$PROJ" | tr '[:lower:]' '[:upper:]')/.husky/_" | |
| 496 | 新增: # The same through a whole scan, as macOS (Windows ignores case already). | |
| 497 | 新增: hp "$(_agent_vm_git_spelling "$PROJ" | tr '[:lower:]' '[:upper:]')/.husky/_" | |
| 498 | 498 | check "hooks: a hooks path in other capitals is named, where case is ignored" \ |
| 499 | 删除: "$( uname() { echo Darwin; }; names )" '[".git", ".hg", ".husky"]' | |
| 499 | 新增: "$( if ! _agent_vm_on_windows; then uname() { echo Darwin; }; fi; names )" '[".git", ".hg", ".husky"]' | |
| 500 | 500 | hp .husky/_ |
| 501 | 501 | |
| 502 | 502 | # A repository below the project has hooks of its own. |
| @@ -726,6 +726,17 @@ if command -v git >/dev/null 2>&1; then | ||
| 726 | 726 | ( git -C "$PROJ" config --unset-all includeIf.gitdir:/.path |
| 727 | 727 | git -C "$PROJ" config --unset-all include.path |
| 728 | 728 | git -C "$PROJ" config include.path ../.gitconfig ) |
| 729 | 新增: # The other scopes git reads in the repository: a global alias run from the | |
| 730 | 新增: # top of the project, and the worktree's config. | |
| 731 | 新增: ( git config --global alias.g '!./g.sh' | |
| 732 | 新增: git -C "$PROJ" config extensions.worktreeConfig true | |
| 733 | 新增: git -C "$PROJ" config --worktree core.editor ./ed.sh ) | |
| 734 | 新增: risks="$(_agent_vm_share_config_risks "$PROJ")" | |
| 735 | 新增: case "$risks" in *"alias.g = !./g.sh"*) pass "config: a global alias naming a file of the project" ;; *) fail "config: global: $risks" ;; esac | |
| 736 | 新增: case "$risks" in *"core.editor = ./ed.sh"*) pass "config: the worktree's config" ;; *) fail "config: worktree: $risks" ;; esac | |
| 737 | 新增: ( git config --global --unset alias.g | |
| 738 | 新增: git -C "$PROJ" config --worktree --unset core.editor | |
| 739 | 新增: git -C "$PROJ" config --unset extensions.worktreeConfig ) | |
| 729 | 740 | names_rec '[".git", ".hg"]' |
| 730 | 741 | out="$( unset AGENT_VM_UNSAFE_DISABLE_SECURITY_PROMPTS; _agent_vm_can_ask() { return 1; }; AGENT_VM_TEST_STOPPED=1 rec run true )" |
| 731 | 742 | case "$out" in *"git on this machine uses these"*".gitconfig"*"Aborted."*) pass "config: a start stops on it" ;; *) fail "config: start: $out" ;; esac |
| @@ -369,3 +369,6 @@ if _agent_vm_sha256_sums_check "$(sums)" "$SB/sums" missing.zip >/dev/null 2>&1; | ||
| 369 | 369 | else |
| 370 | 370 | pass "an unlisted file is refused" |
| 371 | 371 | fi |
| 372 | 新增:rm "$SB/sums/c.zip" | |
| 373 | 新增:check "a listed file missing: agent-vm's error only" \ | |
| 374 | 新增: "$(_agent_vm_sha256_sums_check "$(sums)" "$SB/sums" c.zip 2>&1 | grep -c 'No such file')" "0" | |

