Skip to content

Commit

Permalink
build: sort.py: ignore empty files
Browse files Browse the repository at this point in the history
Currently it adds a newline to empty files.

Before:

    $ : >foo.profile
    $ contrib/sort.py foo.profile
    sort.py: checking 1 profile(s)...
    foo.profile:(fixed whitespace)
    [ Fixed ] foo.profile
    $ od -A n -t x1 foo.profile
     0a

After:

    $ : >foo.profile
    $ contrib/sort.py foo.profile
    sort.py: checking 1 profile(s)...
    $

This amends commit c222b7f ("build: sort.py: fix whitespace in entire
profile (#6593)", 2024-12-28).
  • Loading branch information
kmk3 committed Jan 4, 2025
1 parent 8c28f0e commit 7b47c82
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion contrib/sort.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,11 @@ def sort_protocol(original_protocols):

def check_profile(filename, overwrite):
with open(filename, "r+") as profile:
lines = profile.read().split("\n")
original_profile_str = profile.read()
if not original_profile_str:
return

lines = original_profile_str.split("\n")
was_fixed = False
fixed_profile = []
for lineno, original_line in enumerate(lines, 1):
Expand Down

0 comments on commit 7b47c82

Please sign in to comment.