Skip to content

Commit

Permalink
build: sort.py: fix whitespace in entire profile (#6593)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
kmk3 authored Dec 28, 2024
1 parent 9bd077b commit c222b7f
Show file tree
Hide file tree
Showing 11 changed files with 13 additions and 11 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/check-profiles.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: >
Expand Down
11 changes: 10 additions & 1 deletion contrib/sort.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion etc/profile-a-l/devhelp.profile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion etc/profile-a-l/display-im6.q16.profile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,5 @@ include display-im6.q16.local
# Persistent global definitions
include globals.local


# Redirect
include display.profile
1 change: 0 additions & 1 deletion etc/profile-a-l/empathy.profile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion etc/profile-a-l/gnome-font-viewer.profile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion etc/profile-a-l/gnome-recipes.profile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 0 additions & 1 deletion etc/profile-a-l/godot.profile
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ protocol unix,inet,inet6,netlink
seccomp
tracelog


#private-bin godot
private-cache
private-dev
Expand Down
1 change: 0 additions & 1 deletion etc/profile-m-z/quassel.profile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion etc/profile-m-z/rtorrent.profile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion etc/profile-m-z/silentarmy.profile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit c222b7f

Please sign in to comment.