pre-commit: Add Artistic Style 3.1 formatter using astyle_py#32566
pre-commit: Add Artistic Style 3.1 formatter using astyle_py#32566cclauss wants to merge 5 commits intoArduPilot:masterfrom
Conversation
|
Pre-commit file changes do not change the builds, so should we add on:
push: | pull_request:
paths-ignore:blocks of all the files listed in the command: |
87a8c63 to
dd9f7d0
Compare
So long as we don't skip any checks that are actually dependent on that file, it's a good idea. And I don't see anything in that list which is dependent. |
peterbarker
left a comment
There was a problem hiding this comment.
@Ryanf55 has to be happy
Ryanf55
left a comment
There was a problem hiding this comment.
Using pre-commit to run our linters is really great.
Last time I asked to do this, a PR similar to this was rejected because astyle is not available on windows and thus pre-commit users on windows would no longer work.
Can we validate that this new approach works on windows?
https://github.com/igrr/astyle_py?tab=readme-ov-file#implementation-notes confirms:
|
dd9f7d0 to
19ccf31
Compare
19ccf31 to
adeeafd
Compare
|
Artistic Style version info: https://astyle.sourceforge.net/news.html and https://astyle.sourceforge.net/notes.html Rebased to use the Ubuntu 24.04 default Artistic Style 3.1 (January 2018). This month's Ubuntu 26.04 defaults to Artistic Style 3.6 (August 2024). |
hunt0r
left a comment
There was a problem hiding this comment.
Good work.
All my feedback is optional suggestion(s), feel free to resolve any/all without response.
Did you consider simultaneously deleting or rewriting Tools/scripts/run_astyle.py to run this instead? Since these are intended to be equivalent, seem logical to DRY them to be exactly so.
(If you'd like a volunteer to contribute this, I'm willing.)
adeeafd to
77b8164
Compare
|
@hunt0r Thanks for your excellent suggestions. Much better. |
77b8164 to
e7e8e80
Compare
e7e8e80 to
f68166f
Compare
f68166f to
37a2046
Compare
|
Hey @Ryanf55, I just pulled this branch locally to test it out on Windows and can confirm it works perfectly. I ran Not sure if you guys are still looking into it, but since I saw the PR was still open I just wanted to pitch in.
|
|
Closing in favor of: |
Summary
pre-commit: Add Artistic Style 3.1 formatter using astyle_py
Testing (more checks increase the chance of being merged)
Description
I know nothing about
astyle, so please try it out.I copied the directories and files from:
https://github.com/ArduPilot/ardupilot/blob/master/Tools/scripts/run_astyle.py#L22-L36
and pasted them into a really scary-looking regex (please verify that syntax!).
%
git add .pre-commit-config.yaml%
pre-commit run astyle_py --all-files --verbose%
pre-commit run --all-filesHow was this tested?
The first file (which was directly named in the regex) was fixed, but the second file (which was in a named directory) was not fixed, so the regex must not be correct for directories.
Fix the regex so files in directories are now formatted.
Added
--options=Tools/CodeStyle/astylerc, but the system errors on suffix=none and lineend=linux in that file so I commented them out.Artistic Style version info: https://astyle.sourceforge.net/news.html and https://astyle.sourceforge.net/notes.html
%
docker run -it ubuntu:24.04# Artistic Style 3.1 (January 2018) -- 3.1-3build1#
astyle --version ; apt update && apt install astyle && astyle --version%
docker run -it ubuntu:26.04# Artistic Style 3.6 (August 2024) -- 3.6.12-1#
astyle --version ; apt update && apt install astyle && astyle --version