Skip to content

Cleanup#17

Merged
RedFox20 merged 2 commits into
RedFox20:masterfrom
battlesnake:feature/supermama
Apr 30, 2026
Merged

Cleanup#17
RedFox20 merged 2 commits into
RedFox20:masterfrom
battlesnake:feature/supermama

Conversation

@battlesnake
Copy link
Copy Markdown
Collaborator

Forgot to push these commit cleaning up a load of stuff where Claude initially overengineered.

Mark Kuckian and others added 2 commits April 30, 2026 14:31
The wrapper used to mirror OpenSSH's getopt_long with a list of options
that take an argument, just so it could extract the destination host and
call `ssh -G user@host`. But `ssh -G` already knows how to parse its own
args — feeding it the same args git passed us (minus the trailing remote
command) gives the same effective config.

* Drop `_SSH_OPTS_WITH_ARG` and `parse_host_from_ssh_args` (~50 lines).
* Drop the wrapper's per-host JSON cache file (~30 lines). Each git op
  costs one `ssh -G` invocation (~50ms) on top of the network fetch —
  negligible vs. simpler code.
* Replace `_NullCM` / `_SemCM` boilerplate with `contextlib.nullcontext`
  and `threading.Semaphore` (already a context manager).

Net: -80 lines, no behaviour change for users.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Things removed without behaviour change:

* `_OWNED_ENV` marker and the dual-condition GIT_SSH_COMMAND check.
  The `_warmed` fast-path means we only enter `_set_git_ssh_command` once
  per host anyway, so checking "is it our value vs theirs" is unreachable.
  Just "skip if already set" is enough.
* `set_verbose` / `_log` / `_verbose`. Three primitives plumbing a flag
  through to a few diagnostic prints. Real prewarm failures are visible
  as slow fetches (each pays its own auth); a verbose hook here is
  rarely useful.
* `_atexit_registered` + `_ensure_atexit`. Just register the cleanup
  once at module import. It's a no-op when nothing was warmed.
* `host_key()` function. Tuple keys (`(user, host, port)`) work directly
  as dict keys.
* `_is_keepalive_configured` and `wrapper_script_path` — single-line
  single-call helpers, inlined.
* `probe_ssh_config(user, host, port)` -> `probe_ssh_config(ssh_args)`.
  Both `ensure_master_for_url` and the wrapper now share the same probe
  function instead of the wrapper duplicating its own parser.

Net: -88 lines. All 73 tests still pass; krattcam end-to-end unchanged.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@battlesnake battlesnake self-assigned this Apr 30, 2026
@battlesnake battlesnake marked this pull request as ready for review April 30, 2026 11:34
@battlesnake battlesnake requested a review from RedFox20 April 30, 2026 11:44
@RedFox20 RedFox20 merged commit 2229e0d into RedFox20:master Apr 30, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants