Commit graph

35 commits

Author SHA1 Message Date
Gilles Peskine
163ec4090e Handle deleted files correctly
Don't attempt to run on a file that isn't present now.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-06-25 22:18:40 +02:00
Gilles Peskine
43838b8a24 Add --since option to check files modified since a given commit
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-06-22 20:31:02 +02:00
Gilles Peskine
22eb82cb8d Clean up subprocess invocation in get_src_files
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-06-22 19:45:01 +02:00
Pengyu Lv
10f41444a0 Fix CI failure
Signed-off-by: Pengyu Lv <pengyu.lv@arm.com>
2023-02-15 16:58:09 +08:00
Pengyu Lv
c36743f4e0 Only check files known to git
Signed-off-by: Pengyu Lv <pengyu.lv@arm.com>
2023-02-15 10:20:40 +08:00
Pengyu Lv
e19b51bc53 Improve readability
Signed-off-by: Pengyu Lv <pengyu.lv@arm.com>
2023-02-14 10:29:53 +08:00
Pengyu Lv
b10cf0dd39 adjust help message
Signed-off-by: Pengyu Lv <pengyu.lv@arm.com>
2023-02-10 11:06:36 +08:00
Pengyu Lv
a4e1eece3d print skipped file names to stdout
Signed-off-by: Pengyu Lv <pengyu.lv@arm.com>
2023-02-10 10:55:29 +08:00
Pengyu Lv
acbeb7fa30 code_style.py: Add helpers to print warning and skipped files
Signed-off-by: Pengyu Lv <pengyu.lv@arm.com>
2023-02-08 09:59:40 +08:00
Pengyu Lv
8c6325cc8e code_style.py: Apply exclusions to the file list
This commit rename `--files` options to `--subset` and
it means to check a subset of the files known to git.

Signed-off-by: Pengyu Lv <pengyu.lv@arm.com>
2023-02-08 09:59:27 +08:00
David Horstmann
04bdbe3ee0 Remove unnecessary '\' linebreak characters
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-01-25 11:39:04 +00:00
David Horstmann
6b3ce309ad Don't wrap stdout and stderr in UTF-8 wrapper
This is no longer needed as we only print ASCII text directly

Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-01-24 18:40:34 +00:00
David Horstmann
ce42cc24d1 Output diff without capturing it
Instead of capturing the output of diff and printing it, let diff do its
own outputting and se the return code to decide what to do.

This also means that the conversion of stdout to UTF-8 is not necessary,
as the reason it was needed was for printing diffs of files with UTF-8
characters in them.

Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-01-24 18:19:42 +00:00
David Horstmann
089d0d08a0 Add basic output on success
Whilst it is true that "silence is golden", no output at all could be
disconcerting and it makes searching in a CI log more difficult.

Add a simple status message that says "Checked N files, style ok".

Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-01-24 16:56:18 +00:00
David Horstmann
c9f90aaf5a Remove overly verbose output on success
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-01-24 16:00:01 +00:00
David Horstmann
28d2157002 Change print to print_err for an error message
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-01-24 15:53:36 +00:00
David Horstmann
8b5a449c82 Document that the script must be run from the root
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-01-24 15:53:36 +00:00
David Horstmann
995a7c0de0 Remove provisional notice on code style script
Since code style is now enforced, the notice is wrong. Remove it to
avoid confusion.

Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-01-24 15:53:36 +00:00
Gilles Peskine
52a7aeebf3
Merge pull request #6834 from gilles-peskine-arm/code-style-files
code_style.py: Support restyling only the specified files
2023-01-19 12:26:01 +01:00
Gilles Peskine
d449cedd3a Fix example command
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2023-01-12 15:45:32 +01:00
David Horstmann
78d566b216 Fix pylint warnings about comparison to True
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-01-05 10:02:09 +00:00
David Horstmann
8d1d6edb0b Fix incorrect typing of function in code_style.py
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-01-05 09:59:35 +00:00
David Horstmann
c571c5b1f0 Check Uncrustify returncode in code_style.py
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2023-01-04 18:44:00 +00:00
Gilles Peskine
9d34cf3f0b Documentation improvements
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-12-23 18:15:19 +01:00
Gilles Peskine
59803dba2b Support restyling only the specified files
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-12-22 16:36:53 +01:00
Gilles Peskine
9a3771e1b3 Don't touch the style of generated files
Ideally the result of the generator would conform to the code style, but
this would be difficult, especially with respect to the placement of line
breaks in long logical lines. So, to avoid surprises when checking the style
of generated files (which happens in releases and in long-time support
branches), systematically skip generated files.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2022-12-19 00:52:39 +01:00
David Horstmann
c6b604e842 Reindent line continuations for pylint
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2022-12-08 17:38:27 +00:00
David Horstmann
ae93a3f984 Fixup: Config file name in code style script
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2022-12-08 17:03:01 +00:00
David Horstmann
0ebc12ea41 Add spaces around '+'
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2022-12-08 15:05:53 +00:00
David Horstmann
190041d2b1 Explain that the script is only for the future
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2022-12-08 15:05:53 +00:00
David Horstmann
2cf779ceff Use constant for supported Uncrustify version
Define and report the supported Uncrustify version (and remove extra
newlines from version output).

Signed-off-by: David Horstmann <david.horstmann@arm.com>
2022-12-08 15:05:53 +00:00
David Horstmann
9711f4eeb4 Fix typo in code style script
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2022-12-08 15:05:53 +00:00
David Horstmann
ca13c4f59f Use helper function for error printing
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2022-12-08 15:05:53 +00:00
David Horstmann
b7dab41315 Miscellaneous improvements to code style script
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2022-12-08 15:05:53 +00:00
David Horstmann
fa928f1c44 Add script to run Uncrustify
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2022-12-06 15:04:37 +00:00