Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow creating a local git client with either SSH or HTTPS cloning #18

Open
mobyvb opened this issue Nov 3, 2023 · 0 comments
Open

Comments

@mobyvb
Copy link
Collaborator

mobyvb commented Nov 3, 2023

Allow a user to configure either "SSH" or "HTTPS" for cloning git repositories when creating a new LocalGitClient


files:vc/git.go

@mobyvb 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
black-crowned-night-heron added a commit that referenced this issue 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants