Skip to content

Commit

Permalink
fix(git-spawn): Set GIT_SSH_VARIANT (yarnpkg#4806)
Browse files Browse the repository at this point in the history
**Summary**

Fixes yarnpkg#4729.
Previous version in yarnpkg#4805.

Manually specify `GIT_SSH_VARIANT` in order to get package download via `git+ssh` with a non-standard port when using `plink.exe` working.

Without `GIT_SSH_VARIANT` set properly, Git won't convert `-p` into `-P` and `plink.exe` will throw an error about unknown `-p` parameter.

**Test plan**

*Before:*
![virtualbox_msedge_-_win10_30_10_2017_16_35_24](https://user-images.githubusercontent.com/5042328/32179804-9a87c676-bd90-11e7-86d0-09380d61eadf.png)

*After:*
![virtualbox_msedge_-_win10_30_10_2017_19_07_15](https://user-images.githubusercontent.com/5042328/32187512-9bcb980e-bda5-11e7-96ea-27a513837d6e.png)

Also got `git-spawn.js` test suite updated for testing `GIT_SSH_VARIANT`.
  • Loading branch information
neonowy authored and terra-incognita committed Nov 9, 2017
1 parent c4201eb commit 0266424
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
2 changes: 2 additions & 0 deletions __tests__/util/git/git-spawn.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ describe('spawn', () => {
GIT_ASKPASS: '',
GIT_TERMINAL_PROMPT: 0,
GIT_SSH_COMMAND: '"ssh" -oBatchMode=yes',
GIT_SSH_VARIANT: 'ssh',
...process.env,
});
});
Expand All @@ -53,6 +54,7 @@ describe('spawn', () => {
GIT_ASKPASS: '',
GIT_TERMINAL_PROMPT: 0,
GIT_SSH_COMMAND: `"${plinkPath}" -batch`,
GIT_SSH_VARIANT: 'plink',
...process.env,
});
});
Expand Down
4 changes: 4 additions & 0 deletions src/util/git/git-spawn.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ const sshExecutable = path.basename(sshCommand.toLowerCase(), '.exe');
const sshBatchArgs = BATCH_MODE_ARGS.get(sshExecutable);

if (!env.GIT_SSH_COMMAND && sshBatchArgs) {
// We have to manually specify `GIT_SSH_VARIANT`,
// because it's not automatically set when using `GIT_SSH_COMMAND` instead of `GIT_SSH`
// See: https://github.com/yarnpkg/yarn/issues/4729
env.GIT_SSH_VARIANT = sshExecutable;
env.GIT_SSH_COMMAND = `"${sshCommand}" ${sshBatchArgs}`;
}

Expand Down

0 comments on commit 0266424

Please sign in to comment.