From 5420af1dfa06ec4cb0d1d23578b0d93ee2c2b525 Mon Sep 17 00:00:00 2001 From: JD Daniels Date: Sat, 7 Jun 2025 03:21:11 +0000 Subject: [PATCH] fix: support SSH remotes with non-standard ports (#761) The SSH host matching logic in contextFromLocalRepo only compared exact host:port combinations. This failed for SSH remotes using non-standard ports because the login SSH host configuration typically stores just the hostname without the port. This change allows matching both the full host:port string and the hostname-only version against the configured SSH host, enabling tea to work with SSH remotes on non-standard ports. Fixes issue where commands requiring RemoteRepo failed with 'Remote repository required' error when using SSH on custom ports. Signed-off-by: JD Daniels Co-authored-by: Lunny Xiao Reviewed-on: https://gitea.com/gitea/tea/pulls/761 Reviewed-by: techknowlogick Reviewed-by: Lunny Xiao Co-authored-by: JD Daniels Co-committed-by: JD Daniels --- modules/context/context.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/context/context.go b/modules/context/context.go index 393b10f..b145037 100644 --- a/modules/context/context.go +++ b/modules/context/context.go @@ -222,7 +222,7 @@ func contextFromLocalRepo(repoPath, remoteValue string) (*git.TeaRepo, *config.L return repo, &l, strings.TrimSuffix(path, ".git"), nil } } else if strings.EqualFold(p.Scheme, "ssh") { - if sshHost == p.Host { + if sshHost == p.Host || sshHost == p.Hostname() { return repo, &l, strings.TrimLeft(p.Path, "/"), nil } }