Code hangs forever when cloning a private repo
batchor opened this issue · 2 comments
What's happening
When cloning a private repo, the code hangs forever waiting for credentials.
What do I expect
When cloning a remote repository, I want the process to terminate and return an error .
What did I try
According to https://stackoverflow.com/a/64319771/4095689, I tried both git config git config core.askpass true
and setting environmental variable via
const git: SimpleGit = simpleGit().clean(CleanOptions.FORCE).env({"GIT_TERMINAL_PROMPT": 0});
git.clone(https://github.com/private/repo, localPath) // this line hangs forever.
Both methods worked in the terminal, and the clone command immediately exited with an error message.
However, neither method worked for simple-git, and the code hung forever.
Why I need such functionality and what's the use case?
The remote repos are input from my users, and I cannot guarantee the repos are public or private. I wanted to give my users an error message when they provide a private repo.
When running this as a test:
import { simpleGit, GitError } from "simple-git";
import { promiseError } from '@kwsites/promise-result';
const repo = 'https://github.com/private/repo.git';
const git = simpleGit().env({ 'GIT_TERMINAL_PROMPT': 0 }).clone(repo);
console.log('is private repo failure', /could not read Username/.test(await promiseError(git)));
I successfully get through to the console log.
Please run a similar test, with the verbose logging enabled (ie DEBUG=simple-git:*
) and include the logs with this issue.
This issue has been automatically closed due to a lack of response. If your problem persists please open a new issue including any additional detail requested from this issue. For more detail on the issues/pull requests see ISSUES_AND_PULL_REQUESTS