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 Feb 1, 2021
1 parent de221a7 commit cdaebb7
Showing 1 changed file with 5 additions and 13 deletions.
18 changes: 5 additions & 13 deletions source/git-promise.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,13 @@ const gitExecutorProm = (args, retryCount) => {
let stderr = '';
const env = JSON.parse(JSON.stringify(process.env));
env['LC_ALL'] = 'C';
const procOpts = {
const gitProcess = child_process.spawn(gitBin, args.commands, {
cwd: args.repoPath,
maxBuffer: 1024 * 1024 * 100,
detached: false,
detached: true, // Make sure we don't present a TTY to git
env: env,
};
const gitProcess = child_process.spawn(gitBin, args.commands, procOpts);
stdio: [args.inPipe || 'ignore', args.outPipe || 'pipe', 'pipe'],
});
let timeoutTimer = setTimeout(() => {
if (!timeoutTimer) return;
timeoutTimer = null;
Expand All @@ -73,18 +73,10 @@ const gitExecutorProm = (args, retryCount) => {
gitProcess.kill('SIGINT');
}, args.timeout);

if (args.outPipe) {
gitProcess.stdout.pipe(args.outPipe);
} else {
if (!args.outPipe) {
gitProcess.stdout.on('data', (data) => (stdout += data.toString()));
}
if (args.inPipe) {
gitProcess.stdin.end(args.inPipe);
}
gitProcess.stderr.on('data', (data) => (stderr += data.toString()));
gitProcess.on('error', (error) => {
rejectedError = error;
});

gitProcess.on('close', (code) => {
if (!timeoutTimer) return;
Expand Down

0 comments on commit cdaebb7

Please sign in to comment.