forked from webfactory/ssh-agent
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.js
More file actions
30 lines (28 loc) · 710 Bytes
/
utils.js
File metadata and controls
30 lines (28 loc) · 710 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
const core = require("@actions/core");
module.exports = {
alterGitConfigWithRetry,
};
const wait = (msec) =>
new Promise((resolve, _) => {
setTimeout(resolve, msec);
});
async function alterGitConfigWithRetry(alterFunction, maxTries = 3) {
let tries = 0;
while (tries < maxTries) {
try {
return alterFunction();
} catch (error) {
if (!error.message.includes("could not lock config file")) {
throw error;
}
core.debug(error.message);
tries++;
if (tries === maxTries) {
throw error;
}
const delay = 2000 + Math.floor(Math.random() * 2000);
core.debug(`Retrying in ${delay}ms...`);
await wait(delay);
}
}
}