alibaba / git-repo-go

git-repo is a command-line tool for centralized workflow, can work with Gerrit, AGit-Flow compatible servers. It is written in Golang, and it can be installed easily without further dependency. It provides an easy-to-use solution for multiple repositories which is introduced by Android repo first, and it can also work with a single repository.
https://git-repo.info/
Apache License 2.0
262 stars 60 forks source link

remote appears to override sshinfo with 'git' user #13

Closed ratmice closed 3 years ago

ratmice commented 3 years ago

In proto-agit.go:38 I'm wondering if that is the wrong place for defaulting to the git user. This appears to override the User field from the ssh_info json with the user "git". It is also keeping these fallbacks from working in remote.go

Removing that line made it work how I would expect, but perhaps defaulting to the git user is part of the protocol?

jiangxin commented 3 years ago

Push using SSH protocol is recommended for some platforms, such as Gerrit. Host name, port number for SSH service are returned from ssh-info API. Login names for different Git over SSH protocol are quite different. For example, Gerrit uses email login name, while for our code platform, we use fixed the login name "git". That's the reason that we set the default login name in proto-agit.go (our implementation for the protocol interface). Maybe it is not necessary for our code platform, because git will use any protocol defined in remote.origin.url which has a username defined already.

ratmice commented 3 years ago

What I didn't understand was ssh-info also can specify a {..., "user":"git"} field, Which would achieve the same effect, but is more general protocol wise than hard coding it. I guess it makes sense though if there might be clients around that don't support the user field of ssh-info. Or if proto:agit is intended to be specific to your platform.

jiangxin commented 3 years ago

What I didn't understand was ssh-info also can specify a {..., "user":"git"} field, Which would achieve the same effect, but is more general protocol wise than hard coding it. I guess it makes sense though if there might be clients around that don't support the user field of ssh-info. Or if proto:agit is intended to be specific to your platform.

I get your point. Even though you can implement your own protocol by providing new adapter (protocol helper) in protocol-<name>.go or providing external executable (see section "git-repo is extensible" of this post: https://git-repo.info/en/2020/03/agit-flow-and-git-repo/), it would be better to make proto:agit a general protocol. I will clean unnecessary code in proto:agit. Thanks