git-watchtower 1.14.17 → 1.14.18

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "git-watchtower",
3
- "version": "1.14.17",
3
+ "version": "1.14.18",
4
4
  "description": "Terminal-based Git branch monitor with activity sparklines and optional dev server with live reload",
5
5
  "main": "bin/git-watchtower.js",
6
6
  "bin": {
@@ -15,6 +15,43 @@ const FETCH_TIMEOUT = 60000;
15
15
  // Short timeout for quick local operations (5 seconds)
16
16
  const SHORT_TIMEOUT = 5000;
17
17
 
18
+ /**
19
+ * Environment overrides applied to every git child process.
20
+ *
21
+ * LANG=C / LC_ALL=C force git into the C locale so parseable summary
22
+ * lines — e.g. "X files changed, Y insertions(+), Z deletions(-)" —
23
+ * don't get localized into the user's language. Without this,
24
+ * parseDiffStats() returns (0, 0) on systems with a non-English LANG
25
+ * and certain git builds, silently zeroing sparklines and hiding
26
+ * activity from the user.
27
+ *
28
+ * GIT_TERMINAL_PROMPT=0 prevents git from blocking on a credential
29
+ * prompt when auth is needed — we never run interactively, so a prompt
30
+ * would just hang until the timeout fires.
31
+ *
32
+ * Spread `...process.env` first so callers can still override these
33
+ * per-call if needed, and so the child inherits everything else
34
+ * (critically PATH so `git` resolves on Windows).
35
+ */
36
+ const GIT_ENV_OVERRIDES = {
37
+ LANG: 'C',
38
+ LC_ALL: 'C',
39
+ GIT_TERMINAL_PROMPT: '0',
40
+ };
41
+
42
+ /**
43
+ * Build the child-process env for a git call.
44
+ *
45
+ * Exported for tests. Accepts a base env (defaults to process.env) so
46
+ * tests can pin behaviour without relying on the runner's shell.
47
+ *
48
+ * @param {NodeJS.ProcessEnv} [base] - Base env; defaults to process.env.
49
+ * @returns {NodeJS.ProcessEnv}
50
+ */
51
+ function buildGitEnv(base) {
52
+ return { ...(base || process.env), ...GIT_ENV_OVERRIDES };
53
+ }
54
+
18
55
  /**
19
56
  * Execute a git command safely using execFile (no shell).
20
57
  * @param {string[]} args - Git arguments as an array (e.g. ['log', '--oneline'])
@@ -37,6 +74,7 @@ async function execGit(args, options = {}) {
37
74
  const result = await new Promise((resolve, reject) => {
38
75
  execFile('git', args, {
39
76
  cwd,
77
+ env: buildGitEnv(),
40
78
  maxBuffer: 10 * 1024 * 1024, // 10MB buffer for large outputs
41
79
  timeout, // kill child process after timeout ms
42
80
  killSignal: 'SIGTERM',
@@ -482,6 +520,8 @@ module.exports = {
482
520
  deleteLocalBranch,
483
521
  getAheadBehind,
484
522
  getDiffShortstat,
523
+ buildGitEnv,
524
+ GIT_ENV_OVERRIDES,
485
525
  DEFAULT_TIMEOUT,
486
526
  FETCH_TIMEOUT,
487
527
  };