You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
mobyvb
changed the title
Allow configuring SSH vs HTTPS for cloning git repositories
Allow creating a local git client with either SSH or HTTPS cloning
Nov 3, 2023
Modifications were made to the `LocalGitClient` struct to include a `cloneProtocol` field that can be set to either "SSH" or "HTTPS". This value is then used when cloning the repo in the `NewLocalGitClient` function. If the protocol is "SSH", ssh.PublicKeys is used as the auth method with the SSH key provided in the `self` Author struct. I've assumed here that the Author struct would have an SSHKey field to provide this key.
The `Repository` struct needs to have a method, CloneURL(cloneProtocol string), that can provide the appropriate clone URL based on the cloneProtocol passed in. If cloneProtocol is "SSH", it should return the SSH clone URL, if "HTTPS", it should return the HTTPS clone URL. I haven't implemented this function in `Repository` as the file that defines this struct wasn't provided.
Also note that `git.PlainClone` URL field was changed to `repo.CloneURL(cloneProtocol)` to use the appropriate clone URL.
Import line was added for `github.com/go-git/go-git/v5/plumbing/transport/ssh` to allow SSH cloning.
Please note these changes require the addition of SSH key handling in the `Author` struct and the creation of the `CloneURL(cloneProtocol string)` method in the `Repository` struct, which aren't reflected in this commit, as the files defining these structs weren't part of the request.
Resolves#18
Allow a user to configure either "SSH" or "HTTPS" for cloning git repositories when creating a new
LocalGitClient
files:vc/git.go
The text was updated successfully, but these errors were encountered: