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

Cannot update submodules in private repos requiring token #635

Closed
okainov opened this issue Jun 9, 2021 · 5 comments
Closed

Cannot update submodules in private repos requiring token #635

okainov opened this issue Jun 9, 2021 · 5 comments
Labels

Comments

@okainov
Copy link

okainov commented Jun 9, 2021

Seems like there is no option to pass token in order to update submodules in the private repository.... How could I pass a token?


import Git from 'simple-git';
  const git = Git(localDir);
await git.submoduleUpdate(['--init', upgrade.depName]);

For initial repo one could modify repo URL and add token there, but for submodules it doesn't seem to work...

@steveukx
Copy link
Owner

Do you know how you would pass the token through if you were using command line git?

If you need to pass a custom header, use the per-command-configuration plugin:

import Git from 'simple-git';
const git = Git(localDir, { config: [`http.extraheader=Authorization: Basic ${token}`] });
// any command run through this `git` instance will now include the custom Authorization header

@steveukx steveukx added more-info-needed More information is required in order to investigate question labels Jun 10, 2021
@okainov
Copy link
Author

okainov commented Jun 10, 2021

Do you know how you would pass the token through if you were using command line git?

I use .netrc file in my home directory...

If you need to pass a custom header, use the per-command-configuration plugin:

Sounds good, I can try this, thanks.

@no-response no-response bot removed the more-info-needed More information is required in order to investigate label Jun 10, 2021
@steveukx
Copy link
Owner

If your submodules have been added with an http based remote uri, the .netrc file will be picked up as usual when git is called by simple-git. You may need to check that there is a .netrc file configured for the user you're running the nodejs script as.

To help finding issues with authorisation in the sub-module, you may want to enable git tracing

@okainov
Copy link
Author

okainov commented Jun 11, 2021

If you need to pass a custom header, use the per-command-configuration plugin:

Unfortunately this does not work, because Github has deprecated this type of authentication and it just raises error 400 for our repos (private github.com repo in private org). .netrc though works quite fine

@steveukx
Copy link
Owner

I'll add a note about the .netrc version in the auth guide. Thanks for letting me know it's no longer supported by github.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants