Use cygpath to convert socket filename on windows

This commit is contained in:
Nick Sieger 2022-11-09 16:49:06 -06:00
parent 4512be8010
commit 895b4cdbf2
No known key found for this signature in database
GPG key ID: 222EA328BD6E402A
4 changed files with 16 additions and 5 deletions

3
dist/cleanup.js vendored
View file

@ -2835,7 +2835,8 @@ module.exports = (process.env['OS'] != 'Windows_NT') ? {
homePath: os.homedir(),
sshAgentCmd: 'c://progra~1//git//usr//bin//ssh-agent.exe',
sshAddCmd: 'c://progra~1//git//usr//bin//ssh-add.exe',
gitCmd: 'c://progra~1//git//bin//git.exe'
gitCmd: 'c://progra~1//git//bin//git.exe',
pathsCmd: 'c://progra~1//git//usr//bin//cygpath.exe'
};

9
dist/index.js vendored
View file

@ -322,7 +322,7 @@ const core = __webpack_require__(470);
const child_process = __webpack_require__(129);
const fs = __webpack_require__(747);
const crypto = __webpack_require__(417);
const { homePath, sshAgentCmd, sshAddCmd, gitCmd } = __webpack_require__(972);
const { homePath, sshAgentCmd, sshAddCmd, gitCmd, pathsCmd } = __webpack_require__(972);
try {
const privateKey = core.getInput('ssh-private-key');
@ -353,6 +353,10 @@ try {
const matches = /^(SSH_AUTH_SOCK|SSH_AGENT_PID)=(.*); export \1/.exec(line);
if (matches && matches.length > 0) {
// use pathsCmd to convert socket file to a windows path
if (pathsCmd && matches[1] === "SSH_AUTH_SOCK") {
matches[2] = child_process.execFileSync(pathsCmd, ['-m', matches[2]]).toString().trim()
}
// This will also set process.env accordingly, so changes take effect for this script
core.exportVariable(matches[1], matches[2])
console.log(`${matches[1]}=${matches[2]}`);
@ -2914,7 +2918,8 @@ module.exports = (process.env['OS'] != 'Windows_NT') ? {
homePath: os.homedir(),
sshAgentCmd: 'c://progra~1//git//usr//bin//ssh-agent.exe',
sshAddCmd: 'c://progra~1//git//usr//bin//ssh-add.exe',
gitCmd: 'c://progra~1//git//bin//git.exe'
gitCmd: 'c://progra~1//git//bin//git.exe',
pathsCmd: 'c://progra~1//git//usr//bin//cygpath.exe'
};

View file

@ -2,7 +2,7 @@ const core = require('@actions/core');
const child_process = require('child_process');
const fs = require('fs');
const crypto = require('crypto');
const { homePath, sshAgentCmd, sshAddCmd, gitCmd } = require('./paths.js');
const { homePath, sshAgentCmd, sshAddCmd, gitCmd, pathsCmd } = require('./paths.js');
try {
const privateKey = core.getInput('ssh-private-key');
@ -33,6 +33,10 @@ try {
const matches = /^(SSH_AUTH_SOCK|SSH_AGENT_PID)=(.*); export \1/.exec(line);
if (matches && matches.length > 0) {
// use pathsCmd to convert socket file to a windows path
if (pathsCmd && matches[1] === "SSH_AUTH_SOCK") {
matches[2] = child_process.execFileSync(pathsCmd, ['-m', matches[2]]).toString().trim()
}
// This will also set process.env accordingly, so changes take effect for this script
core.exportVariable(matches[1], matches[2])
console.log(`${matches[1]}=${matches[2]}`);

View file

@ -12,5 +12,6 @@ module.exports = (process.env['OS'] != 'Windows_NT') ? {
homePath: os.homedir(),
sshAgentCmd: 'c://progra~1//git//usr//bin//ssh-agent.exe',
sshAddCmd: 'c://progra~1//git//usr//bin//ssh-add.exe',
gitCmd: 'c://progra~1//git//bin//git.exe'
gitCmd: 'c://progra~1//git//bin//git.exe',
pathsCmd: 'c://progra~1//git//usr//bin//cygpath.exe'
};