Skip to content

Commit 67b6aff

Browse files
committed
Fix git commands failing with password-protected SSH keys
Fixes #642
1 parent ebb9acf commit 67b6aff

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

source/git-util.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,8 @@ const hasRemote = async () => {
162162
};
163163

164164
const hasUnfetchedChangesFromRemote = async () => {
165-
const {stdout: possibleNewChanges} = await execa('git', ['fetch', '--dry-run'], {timeout: gitNetworkTimeout});
165+
// Inherit stdin to allow SSH password prompts for password-protected keys
166+
const {stdout: possibleNewChanges} = await execa('git', ['fetch', '--dry-run'], {stdin: 'inherit', timeout: gitNetworkTimeout});
166167

167168
// There are unfetched changes if output is not empty.
168169
return Boolean(possibleNewChanges);
@@ -191,14 +192,16 @@ export const verifyRemoteHistoryIsClean = async () => {
191192

192193
export const verifyRemoteIsValid = async () => {
193194
try {
194-
await execa('git', ['ls-remote', 'origin', 'HEAD'], {timeout: gitNetworkTimeout});
195+
// Inherit stdin to allow SSH password prompts for password-protected keys
196+
await execa('git', ['ls-remote', 'origin', 'HEAD'], {stdin: 'inherit', timeout: gitNetworkTimeout});
195197
} catch (error) {
196198
throw new Error(error.stderr.replace('fatal:', 'Git fatal error:'));
197199
}
198200
};
199201

200202
export const fetch = async () => {
201-
await execa('git', ['fetch'], {timeout: gitNetworkTimeout});
203+
// Inherit stdin to allow SSH password prompts for password-protected keys
204+
await execa('git', ['fetch'], {stdin: 'inherit', timeout: gitNetworkTimeout});
202205
};
203206

204207
const hasLocalBranch = async branch => {
@@ -253,7 +256,8 @@ export const commitLogFromRevision = async revision => {
253256
};
254257

255258
const push = async (tagArgument = '--follow-tags') => {
256-
await execa('git', ['push', tagArgument], {timeout: gitNetworkTimeout});
259+
// Inherit stdin to allow SSH password prompts for password-protected keys
260+
await execa('git', ['push', tagArgument], {stdin: 'inherit', timeout: gitNetworkTimeout});
257261
};
258262

259263
export const pushGraceful = async remoteIsOnGitHub => {

0 commit comments

Comments
 (0)