Skip to content

Commit 6cdf1eb

Browse files
authored
Closes #84: Strip a lot of newlines in configs (#85)
1 parent a57aead commit 6cdf1eb

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

docs/colliecting-diffs.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ If you have configs in NetBox DataSource, you can define it, the script instead
4242
!!! note
4343
Only synced DataSources are acceptable
4444

45+
!!! note
46+
Diff replaces sequences of 3 or more empty lines with one empty line
47+
4548
If in your DataSource config names are different from the hostnames of the devices, you can specify config name with Jinja2 template in `Name template` field.
4649
Reference device with `{{ object }}` variable.
4750

netbox_config_diff/compliance/utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ def __init__(self, choices, *args, **kwargs):
4040

4141
def get_unified_diff(rendered_config: str, actual_config: str, device: str) -> str:
4242
diff = unified_diff(
43-
actual_config.splitlines(),
44-
rendered_config.strip().splitlines(),
43+
re.sub("\n{3,}", "\n", actual_config).splitlines(),
44+
re.sub("\n{3,}", "\n", rendered_config).strip().splitlines(),
4545
fromfiledate=device,
4646
tofiledate=device,
4747
lineterm="",

0 commit comments

Comments
 (0)