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

Fix private repo cloning #76

Merged
merged 2 commits into from
May 20, 2022

Conversation

syphernl
Copy link
Contributor

@syphernl syphernl commented Mar 9, 2022

I separated the private repo check & https cloning as it made no sense (to me) to combine these two checks. On GitLab the repo.Private always seems to be false which prevented the useHttpsClone from being applied.

Tested locally on Gitlab.com and cloning private repos works fine now.

syphernl added 2 commits March 9, 2022 10:47
On GitLab for some reason the `repo.Private` always returns false even if the repo is actually private, which means this code is never executed and the `git` client asks for a username and password to clone. 

It would make sense to use the token for cloning any type of repo, as it would prevent the need for asking these details.

Tested on my local build with gitlab.com and it works as expected.
@amitsaha
Copy link
Owner

Thank you for your contribution.

I separated the private repo check & https cloning as it made no sense (to me) to combine these two checks.

The reason they are together (or, were) is that when the https cloning was added, it was added to support private repositories. But, perhaps that's not necessary.

On GitLab the repo.Private always seems to be false which prevented the useHttpsClone from being applied.

Interesting, i will have a look at this.

@amitsaha
Copy link
Owner

amitsaha commented Apr 4, 2022

Thank you for your contribution.

I separated the private repo check & https cloning as it made no sense (to me) to combine these two checks.

The reason they are together (or, were) is that when the https cloning was added, it was added to support private repositories. But, perhaps that's not necessary.

On GitLab the repo.Private always seems to be false which prevented the useHttpsClone from being applied.

Interesting, i will have a look at this.

The Public field populated by the Go GitLab SDK doesn't seem to be working correctly. Here's an example of two projects which I created (one is private, the other is public):

$ GITLAB_TOKEN=glpat-W9wmBwqVeXWoyHyZgbT3 ./gitlab-go-demo  | grep "test-project"
NameWithNamespace: Amit Saha / test-project-1-public => Public field: false  => Visiblity => public
NameWithNamespace: Amit Saha / test-project-1-private => Public field: false  => Visiblity => private

The value of the Public field in both cases is false which is the bug here and i believe that leads to erroneous behavior in gitbackup too. I will get back to this.

@amitsaha
Copy link
Owner

Stop using the Public attribute for GitLab repositories: #78

@amitsaha
Copy link
Owner

Thanks @syphernl once again for the fix. I will merge this shortly along with the above PR which stops using the Public attribute.

@amitsaha amitsaha merged commit d8c1598 into amitsaha:master May 20, 2022
@syphernl syphernl deleted the fix/private_repo_cloning branch May 20, 2022 06:02
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 this pull request may close these issues.

2 participants