提交记录修改CHANGELOG.md+1 −1看文件
修改agent-vm.sh+1 −1看文件
修改lib/git.sh+4 −3看文件
修改lib/mounts.sh+4 −3看文件
修改tests/13-volumes-and-readonly.sh+7 −0看文件
修改tests/14-git-protection.sh+20 −9看文件
| @@ -1,6 +1,6 @@ | ||
| 1 | 1 | # Changelog |
| 2 | 2 | |
| 3 | 删除:## Unreleased | |
| 3 | 新增:## 0.2.1 | |
| 4 | 4 | |
| 5 | 5 | ### Added |
| 6 | 6 | |
| @@ -21,7 +21,7 @@ fi | ||
| 21 | 21 | |
| 22 | 22 | # Semantic version of this file. Bumped by hand on release. Integrators gate on |
| 23 | 23 | # it via `agent-vm version`; a build with no `version` command predates it. |
| 24 | 删除:AGENT_VM_VERSION="0.2.0" | |
| 24 | 新增:AGENT_VM_VERSION="0.2.1" | |
| 25 | 25 | |
| 26 | 26 | AGENT_VM_TEMPLATE="agent-vm-base" |
| 27 | 27 | # Overridable, for a test or a second install, without moving HOME (and |
| @@ -393,9 +393,10 @@ _agent_vm_git_scan() { | ||
| 393 | 393 | _agent_vm_git_scan_lines() { |
| 394 | 394 | local shares proj home s kind at i n=0 hooks hp top h f t in_repo name shown |
| 395 | 395 | local hit_share hit_rel top_share top_rel names="$_AGENT_VM_BASE_NAMES" |
| 396 | 删除: local _agent_vm_windows_memo=0 _agent_vm_nocase_memo=0 kinds=() ats=() hookss=() tops=() | |
| 397 | 删除: _agent_vm_on_windows && _agent_vm_windows_memo=1 | |
| 398 | 删除: _agent_vm_fs_nocase && _agent_vm_nocase_memo=1 | |
| 396 | 新增: # Empty while asked: the memos are what the two functions read first. | |
| 397 | 新增: local _agent_vm_windows_memo="" _agent_vm_nocase_memo="" kinds=() ats=() hookss=() tops=() | |
| 398 | 新增: _agent_vm_on_windows && _agent_vm_windows_memo=1 || _agent_vm_windows_memo=0 | |
| 399 | 新增: _agent_vm_fs_nocase && _agent_vm_nocase_memo=1 || _agent_vm_nocase_memo=0 | |
| 399 | 400 | shares="$(_agent_vm_writable_shares "$1")" |
| 400 | 401 | [[ -n "$shares" ]] || return 0 |
| 401 | 402 | proj="${shares%%$'\n'*}" |
| @@ -92,9 +92,10 @@ _agent_vm_project_mountpoint() { | ||
| 92 | 92 | _agent_vm_volume_entries() { |
| 93 | 93 | local host_dir="$1" raw line mounts_file="$AGENT_VM_STATE_DIR/volumes" why mp proj_mp seen_mps=$'\n' |
| 94 | 94 | [[ -f "$mounts_file" ]] || return 0 |
| 95 | 删除: local _agent_vm_unsafe_refs _agent_vm_windows_memo=0 _agent_vm_nocase_memo=0 | |
| 96 | 删除: _agent_vm_on_windows && _agent_vm_windows_memo=1 | |
| 97 | 删除: _agent_vm_fs_nocase && _agent_vm_nocase_memo=1 | |
| 95 | 新增: # Empty while asked: the memos are what the two functions read first. | |
| 96 | 新增: local _agent_vm_unsafe_refs _agent_vm_windows_memo="" _agent_vm_nocase_memo="" | |
| 97 | 新增: _agent_vm_on_windows && _agent_vm_windows_memo=1 || _agent_vm_windows_memo=0 | |
| 98 | 新增: _agent_vm_fs_nocase && _agent_vm_nocase_memo=1 || _agent_vm_nocase_memo=0 | |
| 98 | 99 | _agent_vm_unsafe_refs="$(_agent_vm_unsafe_ref_dirs)" |
| 99 | 100 | proj_mp="$(_agent_vm_path_join / "$host_dir")" |
| 100 | 101 | while IFS= read -r raw || [[ -n "$raw" ]]; do |
| @@ -307,6 +307,13 @@ check "volumes: covering the project or merged with another, whatever the spelli | ||
| 307 | 307 | "$(printf '%s\n' "$vols_err" | grep -c 'covers the project')/$(printf '%s\n' "$vols_err" | grep -c 'as an entry before it')" "3/1" |
| 308 | 308 | check "volumes: the first at a place is kept, its destination normalized" "$vols" "$SB/vol-ok|/mnt/d|ro|$SB/vol-ok:/mnt/d:ro" |
| 309 | 309 | rm -rf "$SB/vol-ok" "$SB/vol-ok2" "$SB/cov" "$HOME/.agent-vm/volumes" |
| 310 | 新增:# Where case is ignored, a volume holding the home directory spelled with | |
| 311 | 新增:# other capitals is refused all the same. | |
| 312 | 新增:mkdir -p "$SB/CaseVol" | |
| 313 | 新增:printf '%s:/mnt/c:ro\n' "$SB/CaseVol" > "$HOME/.agent-vm/volumes" | |
| 314 | 新增:out="$( HOME="$SB/casevol/home"; uname() { echo Darwin; }; _agent_vm_volume_entries "$PROJ" 2>&1 )" | |
| 315 | 新增:case "$out" in *"is, or contains, your home directory"*) pass "volumes: the home directory in other capitals, where case is ignored: refused" ;; *) fail "volumes: case: $out" ;; esac | |
| 316 | 新增:rm -rf "$SB/CaseVol" "$HOME/.agent-vm/volumes" | |
| 310 | 317 | # A repository's own folder: refused writable, where the VM would write its |
| 311 | 318 | # hooks and config, not read-only. |
| 312 | 319 | mkdir -p "$SB/bare.git/objects" "$SB/bare.git/refs" && : > "$SB/bare.git/HEAD" |
| @@ -493,6 +493,11 @@ 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/_" | |
| 498 | 新增: check "hooks: a hooks path in other capitals is named, where case is ignored" \ | |
| 499 | 新增: "$( uname() { echo Darwin; }; names )" '[".git", ".hg", ".husky"]' | |
| 500 | 新增: hp .husky/_ | |
| 496 | 501 | |
| 497 | 502 | # A repository below the project has hooks of its own. |
| 498 | 503 | mkdir -p "$PROJ/lib/inner" |
| @@ -584,7 +589,7 @@ if command -v git >/dev/null 2>&1; then | ||
| 584 | 589 | && git -C "$VREPO" config core.fsmonitor ./fsmon.sh ) |
| 585 | 590 | printf '%s:/mnt/vrepo:rw\n' "$VREPO" > "$HOME/.agent-vm/volumes" |
| 586 | 591 | check "volumes: a writable volume's hooks folder joins the names" "$(names)" '[".git", ".hg", ".husky", "tools"]' |
| 587 | 删除: case "$(_agent_vm_share_hooks "$PROJ")" in *"$VREPO/tools/hooks"*) pass "volumes: named by the volume's path" ;; *) fail "volumes: hooks: $(_agent_vm_share_hooks "$PROJ")" ;; esac | |
| 592 | 新增: case "$(_agent_vm_share_hooks "$PROJ")" in *"$(_agent_vm_git_spelling "$VREPO")/tools/hooks"*) pass "volumes: named by the volume's path" ;; *) fail "volumes: hooks: $(_agent_vm_share_hooks "$PROJ")" ;; esac | |
| 588 | 593 | case "$(_agent_vm_share_config_risks "$PROJ")" in |
| 589 | 594 | *"core.fsmonitor = ./fsmon.sh"*) pass "volumes: its config naming a command in it is a risk" ;; |
| 590 | 595 | *) fail "volumes: risks: $(_agent_vm_share_config_risks "$PROJ")" ;; |
| @@ -599,9 +604,11 @@ if command -v git >/dev/null 2>&1; then | ||
| 599 | 604 | VOL="$SB/teamtools" |
| 600 | 605 | mkdir -p "$VOL/hooks" |
| 601 | 606 | printf '%s:/mnt/teamtools:rw\n' "$VOL" > "$HOME/.agent-vm/volumes" |
| 602 | 删除: ( git -C "$PROJ" config core.fsmonitor "$VOL/fsmon.sh" && git -C "$PROJ" config include.path "$VOL/gitconfig" ) | |
| 607 | 新增: # Paths as git spells them: Git Bash hands git C:/... for /c/... | |
| 608 | 新增: VOLG="$(_agent_vm_git_spelling "$VOL")" | |
| 609 | 新增: ( git -C "$PROJ" config core.fsmonitor "$VOLG/fsmon.sh" && git -C "$PROJ" config include.path "$VOLG/gitconfig" ) | |
| 603 | 610 | case "$(_agent_vm_share_config_risks "$PROJ")" in |
| 604 | 删除: *"core.fsmonitor = $VOL/fsmon.sh"*"config file $VOL/gitconfig"*|*"config file $VOL/gitconfig"*"core.fsmonitor = $VOL/fsmon.sh"*) | |
| 611 | 新增: *"core.fsmonitor = $VOLG/fsmon.sh"*"config file $VOLG/gitconfig"*|*"config file $VOLG/gitconfig"*"core.fsmonitor = $VOLG/fsmon.sh"*) | |
| 605 | 612 | pass "volumes: the project's config naming a command and a file in a volume" ;; |
| 606 | 613 | *) fail "volumes: cross: $(_agent_vm_share_config_risks "$PROJ")" ;; |
| 607 | 614 | esac |
| @@ -612,15 +619,19 @@ if command -v git >/dev/null 2>&1; then | ||
| 612 | 619 | mkdir -p "$VOL/git" |
| 613 | 620 | printf '[core]\n\tfsmonitor = %s/fsmon.sh\n' "$VOL" > "$VOL/git/config" |
| 614 | 621 | case "$( XDG_CONFIG_HOME="$VOL" _agent_vm_share_config_risks "$PROJ" )" in |
| 615 | 删除: *"config file $VOL/git/config"*) pass "volumes: git's own config kept in a volume" ;; | |
| 622 | 新增: *"config file $VOLG/git/config"*) pass "volumes: git's own config kept in a volume" ;; | |
| 616 | 623 | *) fail "volumes: global: $( XDG_CONFIG_HOME="$VOL" _agent_vm_share_config_risks "$PROJ" )" ;; |
| 617 | 624 | esac |
| 618 | 625 | # A volume reached through a symlink is searched all the same. |
| 619 | 删除: mkdir -p "$SB/data/code/app" | |
| 620 | 删除: ln -s "$SB/data/code" "$SB/code-link" | |
| 621 | 删除: ( git -C "$SB/data/code/app" init -q && git -C "$SB/data/code/app" config core.hooksPath .husky/_ ) | |
| 622 | 删除: printf '%s:/mnt/code:rw\n' "$SB/code-link" > "$HOME/.agent-vm/volumes" | |
| 623 | 删除: case "$(_agent_vm_share_hooks "$PROJ")" in *"$SB/data/code/app/.husky/_"*) pass "volumes: a volume through a symlink is searched" ;; *) fail "volumes: symlinked: $(_agent_vm_share_hooks "$PROJ")" ;; esac | |
| 626 | 新增: if [ -n "$AGENT_VM_HAS_SYMLINKS" ]; then | |
| 627 | 新增: mkdir -p "$SB/data/code/app" | |
| 628 | 新增: ln -s "$SB/data/code" "$SB/code-link" | |
| 629 | 新增: ( git -C "$SB/data/code/app" init -q && git -C "$SB/data/code/app" config core.hooksPath .husky/_ ) | |
| 630 | 新增: printf '%s:/mnt/code:rw\n' "$SB/code-link" > "$HOME/.agent-vm/volumes" | |
| 631 | 新增: case "$(_agent_vm_share_hooks "$PROJ")" in *"$(_agent_vm_git_spelling "$SB/data/code/app")/.husky/_"*) pass "volumes: a volume through a symlink is searched" ;; *) fail "volumes: symlinked: $(_agent_vm_share_hooks "$PROJ")" ;; esac | |
| 632 | 新增: else | |
| 633 | 新增: printf ' skip a volume through a symlink (no symlinks here)\n' | |
| 634 | 新增: fi | |
| 624 | 635 | # The project inside a writable volume: each folder once, named from the |
| 625 | 636 | # project. |
| 626 | 637 | mkdir -p "$SB/up/app" |

