git-watchtower 2.3.22 → 2.3.24

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": "2.3.22",
3
+ "version": "2.3.24",
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": {
package/src/git/pr.js CHANGED
@@ -8,12 +8,24 @@
8
8
  * @param {Array} prs - Array of PR objects from gh CLI
9
9
  * @returns {object|null} Normalized PR info
10
10
  */
11
+ // GitHub statusCheckRollup conclusions that mean "this check did not pass."
12
+ // FAILURE alone misses TIMED_OUT, CANCELLED, ACTION_REQUIRED, and STARTUP_FAILURE
13
+ // — a PR with any of those would render no CI badge in the action modal,
14
+ // leaving the user blind to a real CI break.
15
+ const FAILED_CONCLUSIONS = new Set([
16
+ 'FAILURE',
17
+ 'TIMED_OUT',
18
+ 'CANCELLED',
19
+ 'ACTION_REQUIRED',
20
+ 'STARTUP_FAILURE',
21
+ ]);
22
+
11
23
  function parseGitHubPr(prs) {
12
24
  if (!prs || prs.length === 0) return null;
13
25
  const pr = prs[0];
14
26
  const checks = pr.statusCheckRollup || [];
15
27
  const checksPass = checks.length > 0 && checks.every(c => c.conclusion === 'SUCCESS');
16
- const checksFail = checks.some(c => c.conclusion === 'FAILURE');
28
+ const checksFail = checks.some(c => FAILED_CONCLUSIONS.has(c.conclusion));
17
29
  return {
18
30
  number: pr.number,
19
31
  title: pr.title,
@@ -710,12 +710,21 @@ class Worker {
710
710
 
711
711
  this.socket.on('error', (err) => {
712
712
  this._connected = false;
713
- settleReject(err);
713
+ // Pre-registration: settleReject the connect-promise with the
714
+ // socket error. Post-registration: the promise has already
715
+ // resolved, so just maintain _connected. Without the `settled`
716
+ // guard we still passed the same Error into settleReject — a
717
+ // no-op on the already-settled promise, but the misleading
718
+ // "before registration" message would survive in any future
719
+ // change that logged it.
720
+ if (!settled) settleReject(err);
714
721
  });
715
722
 
716
723
  this.socket.on('close', () => {
717
724
  this._connected = false;
718
- settleReject(new Error('coordinator socket closed before registration'));
725
+ if (!settled) {
726
+ settleReject(new Error('coordinator socket closed before registration'));
727
+ }
719
728
  });
720
729
  });
721
730
  }
@@ -26,6 +26,32 @@ const { isBaseBranch } = require('../git/pr');
26
26
  const { detectInstallSource, getUpdateCommand } = require('../utils/install-source');
27
27
  const { version: PACKAGE_VERSION } = require('../../package.json');
28
28
 
29
+ // ---------------------------------------------------------------------------
30
+ // Branch-row layout helpers
31
+ // ---------------------------------------------------------------------------
32
+
33
+ /**
34
+ * Spaces to write after the (possibly truncated) branch name so the
35
+ * sparkline column lands at a consistent offset regardless of the
36
+ * branch name's actual byte count.
37
+ *
38
+ * Must measure in display columns, not UTF-16 code units. truncate()
39
+ * appends ansi.reset (4 bytes) on its long-string path; CJK / wide
40
+ * emoji span 1 code unit per 2 columns; ZWJ clusters render as 2
41
+ * columns from up to 8 units. Using raw .length would drift the
42
+ * sparkline by N columns per non-ASCII branch and by 4 for any
43
+ * truncated branch.
44
+ *
45
+ * Always returns at least 1 so consecutive writes never abut.
46
+ *
47
+ * @param {string} displayName - Already truncate()d branch name.
48
+ * @param {number} maxNameLen - Column budget the name was truncated to.
49
+ * @returns {number} Number of space characters to write.
50
+ */
51
+ function computeNamePadding(displayName, maxNameLen) {
52
+ return Math.max(1, maxNameLen - visibleLength(displayName) + 2);
53
+ }
54
+
29
55
  // ---------------------------------------------------------------------------
30
56
  // Compact number formatting
31
57
  // ---------------------------------------------------------------------------
@@ -239,7 +265,7 @@ function renderBranchList(state, write) {
239
265
  const fixedWidth = 27 + DIFF_TAG_FIXED_LEN;
240
266
  const maxNameLen = contentWidth - fixedWidth;
241
267
  const displayName = truncate(branch.name, maxNameLen);
242
- const namePadding = Math.max(1, maxNameLen - displayName.length + 2);
268
+ const namePadding = computeNamePadding(displayName, maxNameLen);
243
269
 
244
270
  if (isSelected) write(ansi.inverse);
245
271
  write(cursor);
@@ -1600,4 +1626,6 @@ module.exports = {
1600
1626
  renderStashConfirm,
1601
1627
  renderCleanupConfirm,
1602
1628
  renderUpdateModal,
1629
+ // Layout helpers — exported for unit testing
1630
+ computeNamePadding,
1603
1631
  };