steveukx/git-js

Git clone using HTTP access token in header doesn't work

tabramczyk opened this issue · 2 comments

Hello,

I'm trying achieve something like this:

this.client = simpleGit();
await this.client.raw(['clone', '-c', `http.extraHeader=Authorization: Bearer ${this.bitbucketAccessToken}`, repoPath, localPath])

using your native API:

this.client = simpleGit();
await this.client.clone(repoPath, localPath, {'-c': `http.extraHeader=Authorization: Bearer ${this.bitbucketAccessToken}`});

but in second code i've got error:
error: bogus config parameter: =http.extraHeader=Authorization: Bearer *************************

I see that there is additional = in message and this is probably reason of the error.

Am I doing something wrong or there is a bug?

PS: Thank you for the lib :)

Hello, the usual way to include -c style config options is to add them to the simple-git instance rather than to the task itself:

https://github.com/steveukx/git-js#per-command-configuration

const git: SimpleGit = simpleGit('/some/path', { config: [`http.extraHeader=Authorization: Bearer ${token}`] });

OK, thanks. It works now.