build: sort.py: fix whitespace in entire profile (#6593)

Changes:

* Strip whitespace at the beginning
* Strip whitespace at the end
* Ensure exactly one newline at the end
* Strip extraneous newlines

Also, for clarity print the git diff in the sort.py ci job, since the
specific lines changed are not printed by the sort.py script in this
case (as whitespace is fixed in the entire profile at once).

Command used to search and replace:

    ./contrib/sort.py etc/inc/*.inc etc/profile*/*.profile

This is a follow-up to #6556.

Update contrib/sort.py
This commit is contained in:
Kelvin M. Klann 2024-12-28 16:00:14 +00:00 committed by GitHub
parent 9bd077b39c
commit c222b7f692
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 13 additions and 11 deletions

View file

@ -48,7 +48,9 @@ jobs:
- name: sort.py
run: >
./ci/check/profiles/sort.py
etc/inc/*.inc etc/{profile-a-l,profile-m-z}/*.profile
etc/inc/*.inc etc/{profile-a-l,profile-m-z}/*.profile;
echo;
git diff --exit-code
# Currently broken (see #5610)
# - name: private-etc-always-required.sh
# run: >

View file

@ -99,11 +99,20 @@ def check_profile(filename, overwrite):
)
fixed_profile.append(line)
fixed_profile_str = "\n".join(fixed_profile)
stripped_profile_str = fixed_profile_str.strip() + "\n"
while "\n\n\n" in stripped_profile_str:
stripped_profile_str = stripped_profile_str.replace("\n\n\n", "\n\n")
if stripped_profile_str != fixed_profile_str:
was_fixed = True
print(f"{filename}:(fixed whitespace)")
if was_fixed:
if overwrite:
profile.seek(0)
profile.truncate()
profile.write("\n".join(fixed_profile))
profile.write(stripped_profile_str)
profile.flush()
print(f"[ Fixed ] {filename}")
return 101

View file

@ -6,7 +6,6 @@ include devhelp.local
# Persistent global definitions
include globals.local
include disable-common.inc
include disable-devel.inc
include disable-exec.inc

View file

@ -5,6 +5,5 @@ include display-im6.q16.local
# Persistent global definitions
include globals.local
# Redirect
include display.profile

View file

@ -6,7 +6,6 @@ include empathy.local
# Persistent global definitions
include globals.local
include disable-common.inc
include disable-devel.inc
include disable-interpreters.inc

View file

@ -6,7 +6,6 @@ include gnome-font-viewer.local
# Persistent global definitions
include globals.local
include disable-common.inc
include disable-devel.inc
include disable-exec.inc

View file

@ -6,7 +6,6 @@ include gnome-recipes.local
# Persistent global definitions
include globals.local
noblacklist ${HOME}/.cache/gnome-recipes
noblacklist ${HOME}/.local/share/gnome-recipes

View file

@ -33,7 +33,6 @@ protocol unix,inet,inet6,netlink
seccomp
tracelog
#private-bin godot
private-cache
private-dev

View file

@ -6,7 +6,6 @@ include quassel.local
# Persistent global definitions
include globals.local
include disable-common.inc
include disable-devel.inc
include disable-interpreters.inc

View file

@ -6,7 +6,6 @@ include rtorrent.local
# Persistent global definitions
include globals.local
include disable-common.inc
include disable-devel.inc
include disable-interpreters.inc

View file

@ -5,7 +5,6 @@ include silentarmy.local
# Persistent global definitions
include globals.local
include disable-common.inc
#include disable-devel.inc
include disable-exec.inc