Whole file
slomkowski/nginx-config-formatter
The author described this change as “Fix error with brackets in comments.”. It counts as a record because the checks below fail on the code as it stood at 73f01a74e and pass on 0c28d599c, with nothing else changed between the two runs.
Fix saved2016-06-16
Sharing licenceApache-2.0 · LICENSE
Change size+6 −3
What the code was meant to do, written into the code itself as a save note
Fix error with brackets in comments.
The change
| 35 | 35 | cleaned_lines.append("") | |
| 36 | 36 | continue | |
| 37 | 37 | else: | |
| 38 | - | cleaned_lines.extend([l.strip() for l in re.split("([\\{\\}])", line) if l != ""]) | |
| 38 | + | if line.startswith("#"): | |
| 39 | + | cleaned_lines.append(line) | |
| 40 | + | else: | |
| 41 | + | cleaned_lines.extend([l.strip() for l in re.split("([\\{\\}])", line) if l != ""]) | |
| 39 | 42 | ||
| 40 | 43 | return cleaned_lines | |
| 41 | 44 | ||
| ⋯ | |||
| 56 | 59 | indented_lines = [] | |
| 57 | 60 | current_indent = 0 | |
| 58 | 61 | for line in lines: | |
| 59 | - | if line.endswith('}') and current_indent > 0: | |
| 62 | + | if not line.startswith("#") and line.endswith('}') and current_indent > 0: | |
| 60 | 63 | current_indent -= 1 | |
| 61 | 64 | ||
| 62 | 65 | indented_lines.append(current_indent * INDENTATION + line) | |
| 63 | 66 | ||
| 64 | - | if line.endswith('{'): | |
| 67 | + | if not line.startswith("#") and line.endswith('{'): | |
| 65 | 68 | current_indent += 1 | |
| 66 | 69 | ||
| 67 | 70 | return indented_lines | |
The check that tells the two apart
fail→pass·test_nginxfmt.py::TestFormatter::test_clear_lines
fail→pass·test_nginxfmt.py::TestFormatter::test_perform_indentation
Check file test_nginxfmt.py, taken without changes from the fix and copied onto the older code, so the exact same check runs against both versions.
Origin and history
The code before it73f01a74ec370ba78db50c065938f1ced9dcbd28
Broken version dated2016-06-16
Modulenginxfmt
Units changedclean_lines, perform_indentation
Fingerprintb0bbb7f356e6fc94
Checked2026-08-18 by goldset/0.1
Every field above is generated by our program. None of it is written by hand.