fluxcd / go-git-providers

Git provider client for Go
https://fluxcd.io
Apache License 2.0
72 stars 34 forks source link

`GetCloneURL` returns the wrong url if `UserRef.UserLogin` is incorrect #227

Closed somtochiama closed 1 year ago

somtochiama commented 1 year ago

Describe the bug

UserRepositories().Create() returns a UserRepository and the URL for the repository can be gotten by calling GetCloneUrl on the repository ref. A different URL from the created repository is gotten when the wrong string is set as UserLogin. This is because it makes a create request to the API (which doesn't need the UserLogin) and it succeeds. It then uses what's set as UserLogin to construct the URL string which is different from what is returned from the API (edited)

This causes this issue https://github.com/fluxcd/flux2/issues/3867 in flux2 when a user sets the personal flag when creating an org repository. While this is a user error, the output from Flux isn't helpful since it creates a repository and tries to clone a different one.

To Reproduce

Call UserRepositories().Create() and pass a UserRef.UserLogin that is wrong.

Expected behavior

Create should return the URL of the repository that it created.

Additional context

makkes commented 1 year ago

We should be able to get regression tests in place for this behaviour.