pulli 0.2.8__tar.gz → 0.2.9__tar.gz

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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: pulli
3
- Version: 0.2.8
3
+ Version: 0.2.9
4
4
  Summary: Walk a directory tree, show git repos with status, and fast-forward the ones that are behind upstream.
5
5
  Author: Stefan Waldherr
6
6
  License-Expression: MIT
@@ -1,2 +1,2 @@
1
1
  """pulli — discover git repos under a root and report their status."""
2
- __version__ = "0.2.8"
2
+ __version__ = "0.2.9"
@@ -166,15 +166,25 @@ def _ahead_behind(node: RepoNode, C=lambda s, *c: s) -> str:
166
166
  if not node.upstream:
167
167
  return "· ·"
168
168
  behind, ahead = node.behind or 0, node.ahead or 0
169
- # When the whole line is already cyan (behind repos get that in the
170
- # flat renderer), the count must not re-cyan a subset — nested SGR of
171
- # the same color makes the rest of the line render differently. Bold
172
- # alone is enough emphasis there.
173
- b = C(f"↓{behind}", _BOLD) if behind else f"↓{behind}"
174
- a = C(f"↑{ahead}", _BOLD) if ahead else f"↑{ahead}"
169
+ b = C(f"↓{behind}", _CYAN, _BOLD) if behind else f"↓{behind}"
170
+ a = C(f"↑{ahead}", _CYAN, _BOLD) if ahead else f"↑{ahead}"
175
171
  return f"{b} {a}"
176
172
 
177
173
 
174
+ def _highlight_line(line: str) -> str:
175
+ """Cyan-wrap a whole line, surviving nested SGR resets.
176
+
177
+ Inner resets (e.g. the count's own cyan+bold) would end the outer cyan
178
+ mid-line and make the line render two-tone; re-apply the cyan after
179
+ each reset so the line stays one color throughout. Returns the input
180
+ unchanged when it carries no ANSI codes (color off) — nothing to
181
+ highlight then.
182
+ """
183
+ if "\x1b[" not in line:
184
+ return line
185
+ return _CYAN + line.replace(_RESET, _RESET + _CYAN) + _RESET
186
+
187
+
178
188
  def _repo_tail_parts(node: RepoNode, C) -> list[str]:
179
189
  """The status columns for a repo node, as a list of aligned-able parts.
180
190
 
@@ -341,7 +351,7 @@ def _build_flat_lines(
341
351
  # it — so the whole line is highlighted (cyan) instead of just the
342
352
  # count. Everything up to date stays quiet: no news takes no color.
343
353
  if n.behind and not n.error:
344
- line = C(line, _CYAN)
354
+ line = _highlight_line(line)
345
355
  lines.append(line)
346
356
  repo_line[id(n)] = len(lines) - 1
347
357
  repo_base[id(n)] = padded
@@ -469,7 +479,7 @@ class LiveTree:
469
479
  # Same highlight rule as _build_flat_lines: the whole line goes
470
480
  # cyan when the repo is behind — that is the actionable state.
471
481
  if self._flat and node.behind and not node.error:
472
- text = self._C(text, _CYAN)
482
+ text = _highlight_line(text)
473
483
  text = _clip_ansi(text, self._width)
474
484
  with self._lock:
475
485
  self._rewrite(i, text)
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes