Skip to content

bin/ fixes: terraform install, submodule scripts, shared fixture, tidy-ups - #141

Merged
harleypig merged 9 commits into
masterfrom
fix/scripts-round-2
Nov 4, 2026
Merged

harleypig merged 9 commits into
masterfrom
fix/scripts-round-2

Conversation

@harleypig

@harleypig harleypig commented Nov 3, 2026 •

Copy link
Copy Markdown
Owner

Summary

Fixes in the bin/ scripts, one commit each:

Closes #130
Closes #135
Refs #136
Refs #44
Refs #21
Refs #100
Refs #51

Decisions

Testing evaluation

Run by the author, to the qa-tester's standard (no delegation in this
run).

  1. Verdict: needs tests. They are written in this PR.
  2. Automatable: yes. bats, tests/shell/*.bats, with stubs on PATH
    and local bare remotes. Nothing reaches the network and nothing is
    really installed.
  3. Falsifiers. Each test was run red against the unfixed script, then
    green:
    • rmsubmodule "removes the submodule's git directory in a linked
      worktree": goes red if the script deletes .git/modules/NAME
      instead of the --git-path result.
    • set-submodule-branch "commits the branch it records, and nothing
      else": goes red if the commit is dropped, or if it commits
      everything that is staged.
    • set-submodule-branch "records no branch when the checkout fails":
      goes red if the checkout result is ignored.
    • post-clone "asks no package manager for terraform…" and "names the
      configured tools…": go red if terraform goes back into
      system_packages.
    • post-clone "installs the linters…": goes red if
      dockerfile-language-server-nodejs, vim-language-server or
      prettier goes back into npm_packages.
    • post-clone "apt-get installs a package that was removed but left
      its configuration": goes red when the check goes back to dpkg -l.
    • post-clone nvm tests (NVM_DIR, ~/.nvm, missing nvm.sh, "reports
      npm installed once"): go red when the script sources the
      dotfiles-only startup file.
    • update-coc-extensions XDG test: goes red with a hard-coded
      ~/.config. The parse test goes red when jq's failure is ignored.
    • mvsubmodule/rmsubmodule "says in its commit message only what it
      did": go red if "and updated readme" returns.
    • The shared fixture: pointing its protocol.file.allow at never
      turned 24 tests red.
    • Characterization, green on master: mvsubmodule "moves a submodule
      in a linked worktree".
  4. Disposition: written in this PR. The commented-out lines removed
    from mvsubmodule get no test, because removing a comment changes no
    behaviour.
  5. Entry-point reach: each script was exercised through its real
    entry point (the script run as a command). The set-submodule-branch
    failure path was run with a submodule that has neither a local nor a
    remote-tracking main.

Manual verification

  1. Where: a stock ubuntu:24.04 container with this branch copied
    in, plus sudo, git and curl installed.
  2. What: run bin/post-clone with no npm and no pipx.
  3. Success: the apt step reads "Installing missing packages: gawk jq
    shellcheck shfmt", with no terraform. Afterwards dpkg-query reports
    all four as install ok installed. nvm loads from ~/.nvm, and the
    script prints "npm installed successfully". The manual list names
    terraform and terraform-ls.
  4. Failure: apt aborts on an unknown terraform package and none of
    the four are installed. Or source reports a missing
    shell-startup/nodejs.
  5. What happened: every success line above appeared. The script
    still exited 1 and printed "Setup did not complete". The submodule
    step failed (fatal: not a git repository) because the copy of the
    worktree's .git file points at a path outside the container. That
    failure comes from how the test was set up, not from this change.
    The full failure list was not captured.

Locally: bats tests/shell passed 97 of 97 (and again after the #100 and #51 commits). It also passed run the way
CI runs it, with SIGPIPE ignored and GNU coreutils first on PATH, under
a fresh empty TMPDIR that was still empty afterwards. shfmt -d bin/
and shellcheck bin/* are clean, and the bats files are clean under
shfmt with bin/'s options. markdownlint is clean on
docs/scripts.md.

Review

opt-out: no review skill ran. The changes are small shell fixes,
each with a regression test that was seen to fail first. In place of a
review skill, the author reviewed the full diff by hand.

Self-review of the full diff (git diff origin/master). It found one
problem: the first docs wording missed the case where XDG_CONFIG_HOME
is set but is not a directory. That is fixed. No hook, and no rule or
skill that can refuse work, is changed.

Completion report

  1. Functionality works: met. Tests and the container run are above.
  2. Access model: not applicable. These are local developer scripts with
    no access surface.
  3. Permissions: not applicable, for the same reason. sudo use is
    unchanged.
  4. Audit logging: not applicable. The scripts log nothing, and git
    commits are their record.
  5. Validation: met. package.json parse failures and failed checkouts
    are now caught.
  6. Errors handled: met. A failed checkout, a missing nvm.sh and a
    malformed JSON file each give a clear message and a non-zero exit.
  7. Testing: met. See the testing evaluation.
  8. Documentation: met for docs/scripts.md and the scripts' --help.
    docs/hashicorp.md still says to install terraform "via package
    manager". That file is outside this change and is listed as a
    follow-up.
  9. Completion report: this section.

Co-Authored-By: AI Agent noreply@harleypig.com

harleypig and others added 7 commits November 3, 2026 15:45
The throwaway source repository, bare remotes and superproject were set
up the same way in four tests/shell files. They now load
tests/shell/helpers/git-fixture.bash and call git_fixture and
bare_remote.

Refs #136

Co-Authored-By: AI Agent <noreply@harleypig.com>
…orktree modules

set-submodule-branch now checks git checkout: a submodule whose checkout
fails is reported, gets no branch, and the script exits non-zero. Each
branch it records is committed straight away, .gitmodules alone, so a
later rmsubmodule no longer refuses over an unstaged .gitmodules.

rmsubmodule asked for .git/modules/NAME, which in a linked worktree is
not where git keeps the submodule (.git is a file there). It now asks
git rev-parse --git-path modules/NAME, which names the worktree's own
modules directory. --git-common-dir, which the issue suggested, would
name the main checkout's modules directory, the wrong one.

mvsubmodule never reads .git/modules; a new test pins that it already
works in a linked worktree.

Closes #135

Co-Authored-By: AI Agent <noreply@harleypig.com>
Neither Ubuntu's nor Fedora's repositories carry terraform or
terraform-ls; they are only in HashiCorp's own repository. Asking apt-get
for them aborted the whole install, so gawk, jq, shellcheck and shfmt
were not installed either. They now sit with hadolint, sqlint and tflint
in the closing "install by hand" message, with HashiCorp's install pages.
Adding HashiCorp's repository was not chosen: it would make this script
take a trust decision on the user's behalf.

Closes #130

Co-Authored-By: AI Agent <noreply@harleypig.com>
coc-docker depends on dockerfile-language-server-nodejs and runs its own
copy, so the global npm install served only the hand-written
languageserver.dockerfile block in coc-settings.json, which a sibling
change removes. The settings half lands there.

Refs #21

Co-Authored-By: AI Agent <noreply@harleypig.com>
Five lines differed from shfmt run with the options .editorconfig sets
for bin/ (bats files are not matched there, so pass them as flags).

Refs #44

Co-Authored-By: AI Agent <noreply@harleypig.com>
- mvsubmodule and rmsubmodule no longer say "and updated readme" in
  their commit messages; neither touches a readme. mvsubmodule loses its
  commented-out echo, mkreadme and README.md lines and the stray
  git config note at its top, none of which carried a reason.
- update-coc-extensions reads $XDG_CONFIG_HOME/coc/extensions when
  XDG_CONFIG_HOME names a directory, as CoC itself does, and says
  "Cannot parse" for a malformed package.json instead of claiming no
  extensions are installed.
- post-clone loads nvm from where its installer puts it (NVM_DIR, else
  $XDG_CONFIG_HOME/nvm, else ~/.nvm) instead of a dotfiles-only startup
  file, and reports a missing nvm.sh rather than a shell error.
- post-clone asks dpkg-query for a package's status, so a package removed
  with its configuration left behind, which dpkg -l still lists, is
  installed instead of skipped.

Refs #44

Co-Authored-By: AI Agent <noreply@harleypig.com>
rmsubmodule finds a linked worktree's modules, set-submodule-branch
commits .gitmodules (#135), and update-coc-extensions honours
XDG_CONFIG_HOME (#44).

Refs #135
Refs #44

Co-Authored-By: AI Agent <noreply@harleypig.com>
@harleypig harleypig added this to the Pre-improvement milestone Nov 3, 2026
harleypig and others added 2 commits November 3, 2026 15:54
ALE no longer runs vimls (#123), and coc-vimlsp builds
vim-language-server into its own bundle, so the global npm install was
used by nothing.

Refs #100

Co-Authored-By: AI Agent <noreply@harleypig.com>
prettier was installed only as ALE's Markdown fixer, which a sibling
change removes. Nothing else configured runs it. The ALE half lands
there.

Refs #51

Co-Authored-By: AI Agent <noreply@harleypig.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant