Skip to content

Commit 37a62a7

Browse files
committed
Git: run detached
This prevents git hanging for asking ssh passphrases
1 parent 80d9e9a commit 37a62a7

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

Diff for: source/git-promise.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ const gitExecutorProm = (args, retryCount) => {
4242
let stderr = '';
4343
let env = JSON.parse(JSON.stringify(process.env));
4444
env['LC_ALL'] = 'C';
45-
const procOpts = { cwd: args.repoPath, maxBuffer: 1024 * 1024 * 100, detached: false, env: env }
45+
// Run git detached, so it doesn't try to request passwords from stdin
46+
const procOpts = { cwd: args.repoPath, maxBuffer: 1024 * 1024 * 100, detached: true, env: env }
4647
const gitProcess = child_process.spawn(gitBin, args.commands, procOpts);
4748
if (args.timeout) {
4849
setTimeout(() => {
@@ -59,9 +60,8 @@ const gitExecutorProm = (args, retryCount) => {
5960
} else {
6061
gitProcess.stdout.on('data', (data) => stdout += data.toString());
6162
}
62-
if (args.inPipe) {
63-
gitProcess.stdin.end(args.inPipe);
64-
}
63+
// Always close stdin, even when there's no inPipe
64+
gitProcess.stdin.end(args.inPipe);
6565
gitProcess.stderr.on('data', (data) => stderr += data.toString());
6666
gitProcess.on('error', (error) => { rejectedError = error; });
6767

0 commit comments

Comments
 (0)