Skip to content

Commit 28e823b

Browse files
committed
build: sort.py: fix whitespace in entire profile
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 netblue30#6556. Update contrib/sort.py
1 parent 028d236 commit 28e823b

11 files changed

+13
-11
lines changed

.github/workflows/check-profiles.yml

+3-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,9 @@ jobs:
4848
- name: sort.py
4949
run: >
5050
./ci/check/profiles/sort.py
51-
etc/inc/*.inc etc/{profile-a-l,profile-m-z}/*.profile
51+
etc/inc/*.inc etc/{profile-a-l,profile-m-z}/*.profile;
52+
echo;
53+
git diff --exit-code
5254
# Currently broken (see #5610)
5355
# - name: private-etc-always-required.sh
5456
# run: >

contrib/sort.py

+10-1
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,20 @@ def check_profile(filename, overwrite):
9999
)
100100
fixed_profile.append(line)
101101

102+
fixed_profile_str = "\n".join(fixed_profile)
103+
stripped_profile_str = fixed_profile_str.strip() + "\n"
104+
while "\n\n\n" in stripped_profile_str:
105+
stripped_profile_str = stripped_profile_str.replace("\n\n\n", "\n\n")
106+
107+
if stripped_profile_str != fixed_profile_str:
108+
was_fixed = True
109+
print(f"{filename}:(fixed whitespace)")
110+
102111
if was_fixed:
103112
if overwrite:
104113
profile.seek(0)
105114
profile.truncate()
106-
profile.write("\n".join(fixed_profile))
115+
profile.write(stripped_profile_str)
107116
profile.flush()
108117
print(f"[ Fixed ] {filename}")
109118
return 101

etc/profile-a-l/devhelp.profile

-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ include devhelp.local
66
# Persistent global definitions
77
include globals.local
88

9-
109
include disable-common.inc
1110
include disable-devel.inc
1211
include disable-exec.inc

etc/profile-a-l/display-im6.q16.profile

-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,5 @@ include display-im6.q16.local
55
# Persistent global definitions
66
include globals.local
77

8-
98
# Redirect
109
include display.profile

etc/profile-a-l/empathy.profile

-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ include empathy.local
66
# Persistent global definitions
77
include globals.local
88

9-
109
include disable-common.inc
1110
include disable-devel.inc
1211
include disable-interpreters.inc

etc/profile-a-l/gnome-font-viewer.profile

-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ include gnome-font-viewer.local
66
# Persistent global definitions
77
include globals.local
88

9-
109
include disable-common.inc
1110
include disable-devel.inc
1211
include disable-exec.inc

etc/profile-a-l/gnome-recipes.profile

-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ include gnome-recipes.local
66
# Persistent global definitions
77
include globals.local
88

9-
109
noblacklist ${HOME}/.cache/gnome-recipes
1110
noblacklist ${HOME}/.local/share/gnome-recipes
1211

etc/profile-a-l/godot.profile

-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ protocol unix,inet,inet6,netlink
3333
seccomp
3434
tracelog
3535

36-
3736
#private-bin godot
3837
private-cache
3938
private-dev

etc/profile-m-z/quassel.profile

-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ include quassel.local
66
# Persistent global definitions
77
include globals.local
88

9-
109
include disable-common.inc
1110
include disable-devel.inc
1211
include disable-interpreters.inc

etc/profile-m-z/rtorrent.profile

-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ include rtorrent.local
66
# Persistent global definitions
77
include globals.local
88

9-
109
include disable-common.inc
1110
include disable-devel.inc
1211
include disable-interpreters.inc

etc/profile-m-z/silentarmy.profile

-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ include silentarmy.local
55
# Persistent global definitions
66
include globals.local
77

8-
98
include disable-common.inc
109
#include disable-devel.inc
1110
include disable-exec.inc

0 commit comments

Comments
 (0)