Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions spec/command_line.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ try https://github.com/tobi/try.git

try clone git@github.com:tobi/try.git
# SSH URL also works: 2025-11-30-tobi-try

try clone deploy@git.example.com:src/team/project.git
# SCP-style SSH URLs with nested paths also work: 2025-11-30-deploy-project
```

### worktree
Expand Down
8 changes: 8 additions & 0 deletions spec/tests/test_32_git_uri.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,14 @@ else
fail "SSH gitlab.com should parse user/repo" "user-sshrepo" "$output" "git_uri"
fi

# Test: SCP-style SSH host with custom user and nested path
output=$(try_run --path="$TEST_TRIES" exec clone deploy@git.example.com:src/team/project.git 2>&1)
if echo "$output" | grep -q "deploy-project"; then
pass
else
fail "SCP-style SSH URL should parse nested repo path" "deploy-project" "$output" "git_uri"
fi

# Test: Unparseable URI produces error
output=$(try_run --path="$TEST_TRIES" exec clone not-a-valid-uri 2>&1)
exit_code=$?
Expand Down
5 changes: 5 additions & 0 deletions try.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1057,6 +1057,11 @@ def parse_git_uri(uri)
# git@host:user/repo
host, user, repo = $1, $2, $3
return { user: user, repo: repo, host: host }
elsif uri.match(%r{^([^@/:]+)@([^:]+):(.+)})
# SCP-style SSH: user@host:path/to/repo
user, host, path = $1, $2, $3
repo = File.basename(path)
return { user: user, repo: repo, host: host }
else
return nil
end
Expand Down