Skip to content

paths: key an ssh clone whose owner starts with a digit as its https clone - #203

Open
Muhammad Abdullah Butt (1AbdullahButt) wants to merge 1 commit into
microsoft:mainfrom
1AbdullahButt:fix/202-scp-remote-digit-owner
Open

Muhammad Abdullah Butt (1AbdullahButt) wants to merge 1 commit into
microsoft:mainfrom
1AbdullahButt:fix/202-scp-remote-digit-owner

Conversation

@1AbdullahButt

Copy link
Copy Markdown
Contributor

Fixes #202

normalize_remote changes the colon of an scp remote (git@github.com:owner/repo.git) into a slash, so an ssh clone and an https clone get one state key. It skipped that when a digit follows the colon, to keep a port such as ssh://git@host:2222/.... But a port can only come after a scheme. In git's scp form there is no port, and the path may start with a digit: GitHub owners such as 1Password, 42wim or 01-ai. For those, an ssh clone was keyed as github.com:42wim/widget and an https clone as github.com/42wim/widget. The two learned apart, and the ssh clone's label was github.com:42wim/widget.

This PR keeps the digit check only when the remote had a scheme. Without one, any colon that is not a Windows drive is the scp separator. Remotes with a scheme, Windows paths and host:/abs/path keep their old spelling, so no other key changes.

State that an affected ssh clone learned under its old key is not lost. repos.adopt already looks up the key that index.json last recorded for the checkout, and moves that state to the new key.

The test is in tests/test_live_repos.py, next to the test that clones and worktrees share one key. It checks that an ssh and an https clone of 42wim/widget get the same key and the label 42wim/widget, and that a URL with a scheme and a port keeps its port. It also writes state under the old key, records that key in index.json the way an earlier session would, and checks that repos.adopt carries the state over.

How it was produced: Claude Code, an AI coding agent, found the bug by reading plugin/paths.py. It also wrote the fix and the test. I directed the work.

What was checked, on Windows 11 with Python 3.10, on main at 81e32e5:

  • Without the fix, the new test fails: the ssh clone's key is widget-fdae18ebe0, not widget-ae7bad507a.
  • With the fix, tests/test_live_repos.py, tests/test_windows_identity.py, tests/test_repo_key_env.py, tests/test_live_config.py and tests/test_history_import.py pass.
  • Full tests run: python -m pytest tests reports 888 passed, 24 skipped and 0 failed (912 collected). The skips need tools this machine does not have, such as a real Codex, Hermes or opencode CLI. I did not run experiments/tests.

🤖 Generated with Claude Code

…s clone

`normalize_remote` kept the colon of `git@github.com:42wim/repo.git` because a digit
follows it, which it reads as a port. A port can only follow a scheme; in git's scp form
the path may start with a digit. So an ssh and an https clone of such a repository got
two state keys, and the ssh one the label `github.com:42wim/repo`.

Fixes microsoft#202

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.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

Development

Successfully merging this pull request may close these issues.

plugin: an ssh clone whose owner starts with a digit gets another repository key than its https clone

1 participant