I've migrated my git repositories from Gitlab to Gogs and I've taken the opportunity to change some organization/group names and reorganize repositories.
I'd like to maintain the current Git+SSH URLs working however for projects using composer or other packagers.
I've looked for a way to do it inside Gogs but nothing seems to exist to this purpose so I had another idea (which could also be useful in other contexts): rewriting the SSH path on the server, like Apache does with mod_rewrite. Is there a way to do just that with SSH? Note that adding a command in the .authorized_keys
is a bit tricky since Gogs already uses it to mediate access to the repositories through a command.
git config --global url.ssh://[email protected]/.insteadOf [email protected]:
git
user on Gogs server works, ie. what command does it run when one doesgit
over SSH. IIUCgit
over SSH is just callinggit
in the end with some args. If you see github.com/gogs/gogs/blob/main/internal/ssh/ssh.go then you can see that in trace log level you could see what was called from SSH client (a git user). Basically if Gogs doesn't have any feature for this, you could write a wrapper which would get "old" path from SSH_ORIGINAL_COMMAND and rewrite it and then callgit
as Gogs does by default.git
hooks could be used, I have no experience with that.