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

GHE to public submodules fail on auth #943

Open
samimb opened this issue Nov 27, 2023 · 2 comments
Open

GHE to public submodules fail on auth #943

samimb opened this issue Nov 27, 2023 · 2 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@samimb
Copy link

samimb commented Nov 27, 2023

Hello!

I am using go-git for cloning from a GitHub enterprise instance, I.e, not public GitHub, which is the default behavior for my code base.

These clones are authenticated with ssh keys as such:

	_, err := git.PlainClone("/opt/github/"+path, false, &git.CloneOptions{
		Auth:     publicKeys,
		URL:      url,
       RecurseSubmodules: git.DefaultSubmoduleRecursionDepth,
		Progress: os.Stdout,
	})

When one of the repos has a submodule from public GitHub and I have the setting to recursively clone, it fails based on auth. The main repository gets cloned but the submodule itself fails as it tried to auth.

Simply having conditionals to remove Auth from options based on URL would not work as it’s part of the original clone and would recursively go a level deeper.

@pjbgf pjbgf added enhancement New feature or request help wanted Extra attention is needed labels Dec 5, 2023
@pjbgf
Copy link
Member

pjbgf commented Dec 5, 2023

@samimb A work around may be to pull the main repo (NoRecurseSubmodules) then pull the submodules with:

	s, err := w.Submodules()
	if err != nil {
		return err
	}
	err = s.Update(&SubmoduleUpdateOptions{
			Init: true,
			Auth:              nil,
		})
	...

Alternatively, you could propose an API change to set auth for submodules as part of CloneOptions.

@samimb
Copy link
Author

samimb commented Dec 5, 2023

@samimb A work around may be to pull the main repo (NoRecurseSubmodules) then pull the submodules with:

	s, err := w.Submodules()
	if err != nil {
		return err
	}
	err = s.Update(&SubmoduleUpdateOptions{
			Init: true,
			Auth:              nil,
		})
	...

Alternatively, you could propose an API change to set auth for submodules as part of CloneOptions.

Thanks, will try this as a workaround. Curious, what would happen if a repo does not have a submodule in it in this case?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants