Skip to content

Commit 10075ad

Browse files
committed
Handle invalid data in COLUMNS env var when determining console width
1 parent ee43699 commit 10075ad

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

lib/tools/patching.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,15 @@
444444
from rich.syntax import Syntax
445445

446446
# console width is COLUMNS env var minus 12, or just 160 if GITHUB_ACTIONS env is not empty
447-
console_width = (int(os.environ.get("COLUMNS", 160)) - 12) if os.environ.get("GITHUB_ACTIONS", "") == "" else 160
447+
if os.environ.get("GITHUB_ACTIONS", "") == "":
448+
try:
449+
console_width = int(os.environ.get("COLUMNS", 160))
450+
console_width = max(console_width, 120)
451+
except ValueError:
452+
console_width = 160
453+
console_width -= 12
454+
else:
455+
console_width = 160
448456
console = Console(color_system="standard", width=console_width, highlight=False)
449457

450458
# Use Rich to print a summary of the patches

0 commit comments

Comments
 (0)