git-watchtower 1.10.12 → 1.10.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/git/commands.js +5 -14
package/package.json
CHANGED
package/src/git/commands.js
CHANGED
|
@@ -5,7 +5,6 @@
|
|
|
5
5
|
|
|
6
6
|
const { execFile } = require('child_process');
|
|
7
7
|
const { GitError } = require('../utils/errors');
|
|
8
|
-
const { withTimeout } = require('../utils/async');
|
|
9
8
|
|
|
10
9
|
// Default timeout for git operations (30 seconds)
|
|
11
10
|
const DEFAULT_TIMEOUT = 30000;
|
|
@@ -44,10 +43,12 @@ async function execGit(args, options = {}) {
|
|
|
44
43
|
const command = `git ${args.join(' ')}`;
|
|
45
44
|
|
|
46
45
|
try {
|
|
47
|
-
const
|
|
46
|
+
const result = await new Promise((resolve, reject) => {
|
|
48
47
|
execFile('git', args, {
|
|
49
48
|
cwd,
|
|
50
49
|
maxBuffer: 10 * 1024 * 1024, // 10MB buffer for large outputs
|
|
50
|
+
timeout, // kill child process after timeout ms
|
|
51
|
+
killSignal: 'SIGTERM',
|
|
51
52
|
}, (error, stdout, stderr) => {
|
|
52
53
|
if (error) {
|
|
53
54
|
error.stderr = stderr;
|
|
@@ -58,23 +59,13 @@ async function execGit(args, options = {}) {
|
|
|
58
59
|
});
|
|
59
60
|
});
|
|
60
61
|
|
|
61
|
-
const result = await withTimeout(
|
|
62
|
-
promise,
|
|
63
|
-
timeout,
|
|
64
|
-
`Git command timed out after ${timeout}ms: ${command}`
|
|
65
|
-
);
|
|
66
|
-
|
|
67
62
|
return {
|
|
68
63
|
stdout: result.stdout.trim(),
|
|
69
64
|
stderr: result.stderr.trim(),
|
|
70
65
|
};
|
|
71
66
|
} catch (error) {
|
|
72
|
-
//
|
|
73
|
-
|
|
74
|
-
throw new GitError(error.message, 'GIT_TIMEOUT', { command });
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
// Handle exec error
|
|
67
|
+
// execFile sets error.killed = true when the process is killed due to
|
|
68
|
+
// timeout. GitError.fromExecError already maps killed → GIT_TIMEOUT.
|
|
78
69
|
throw GitError.fromExecError(error, command, error.stderr);
|
|
79
70
|
}
|
|
80
71
|
}
|