Skip to content

Commit

Permalink
Git: run detached
Browse files Browse the repository at this point in the history
This prevents git hanging for asking ssh passphrases
  • Loading branch information
wmertens committed Apr 23, 2020
1 parent e6fa906 commit ab6748f
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions source/git-promise.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ const gitExecutorProm = (args, retryCount) => {
let stderr = '';
let env = JSON.parse(JSON.stringify(process.env));
env['LC_ALL'] = 'C';
const procOpts = { cwd: args.repoPath, maxBuffer: 1024 * 1024 * 100, detached: false, env: env }
// Run git detached, so it doesn't try to request passwords from stdin
const procOpts = { cwd: args.repoPath, maxBuffer: 1024 * 1024 * 100, detached: true, env: env }
const gitProcess = child_process.spawn(gitBin, args.commands, procOpts);
if (args.timeout) {
setTimeout(() => {
Expand All @@ -59,9 +60,8 @@ const gitExecutorProm = (args, retryCount) => {
} else {
gitProcess.stdout.on('data', (data) => stdout += data.toString());
}
if (args.inPipe) {
gitProcess.stdin.end(args.inPipe);
}
// Always close stdin, even when there's no inPipe
gitProcess.stdin.end(args.inPipe);
gitProcess.stderr.on('data', (data) => stderr += data.toString());
gitProcess.on('error', (error) => { rejectedError = error; });

Expand Down

0 comments on commit ab6748f

Please sign in to comment.