Skip to content

Commit eb4c237

Browse files
authored
Merge pull request #3246 from mashehu/add-diff-seperator
Modules: add a panel around diff previews when updating
2 parents 354311d + 29f6765 commit eb4c237

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515

1616
### Modules
1717

18+
- add a panel around diff previews when updating ([#3246](https://github.com/nf-core/tools/pull/3246))
19+
1820
### Subworkflows
1921

2022
### General

nf_core/modules/modules_differ.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@
66
from pathlib import Path
77
from typing import Dict, List, Union
88

9-
from rich.console import Console
9+
from rich import box
10+
from rich.console import Console, Group, RenderableType
11+
from rich.panel import Panel
1012
from rich.syntax import Syntax
1113

1214
import nf_core.utils
@@ -276,6 +278,7 @@ def print_diff(
276278
else:
277279
log.info(f"Changes in module '{Path(repo_path, module)}'")
278280

281+
panel_group: list[RenderableType] = []
279282
for file, (diff_status, diff) in diffs.items():
280283
if diff_status == ModulesDiffer.DiffEnum.UNCHANGED:
281284
# The files are identical
@@ -293,7 +296,18 @@ def print_diff(
293296
# The file has changed
294297
log.info(f"Changes in '{Path(module, file)}':")
295298
# Pretty print the diff using the pygments diff lexer
296-
console.print(Syntax("".join(diff), "diff", theme="ansi_dark", padding=1))
299+
syntax = Syntax("".join(diff), "diff", theme="ansi_dark", line_numbers=True)
300+
panel_group.append(Panel(syntax, title=str(file), title_align="left", padding=0))
301+
console.print(
302+
Panel(
303+
Group(*panel_group),
304+
title=f"[white]{str(module)}[/white]",
305+
title_align="left",
306+
padding=0,
307+
border_style="blue",
308+
box=box.HEAVY,
309+
)
310+
)
297311

298312
@staticmethod
299313
def per_file_patch(patch_fn: Union[str, Path]) -> Dict[str, List[str]]:

0 commit comments

Comments
 (0)