Commit Graph

9 Commits

Author SHA1 Message Date
Jeff Epler dfa7c3d32d codeformat: Fix handling of `**`
After discussing with danh, I noticed that `a/**/b` would not match `a/b`.

After correcting this and re-running "pre-commit run --all", additional
files were reindented, including the codeformat script itself.
2021-04-30 15:30:13 -05:00
Jeff Epler e95e921ca1 codeformat: Fix filename matching
In #4683, tannewt noticed that uncrustify was not running on some
file in common-hal.

I investigated and found that it was not being run on a bunch of paths.

Rather than make incremental changes, I rewrote list_files to work
bsaed on regular expressions; these regular expressions are created from
the same git-style glob patterns.

I spot-checked some specific filenames after this change, and all looks good:

```
$ python3 tools/codeformat.py -v --dry-run tests/basics/int_small.py ports/raspberrypi/common-hal/pulseio/PulseIn.c extmod/virtpin.c tests/thread/thread_exit1.py  ports/raspberrypi/background.h extmod/re1.5/recursiveloop.c
tools/codeformat.py -v --dry-run tests/basics/int_small.py ports/raspberrypi/common-hal/pulseio/PulseIn.c extmod/virtpin.c tests/thread/thread_exit1.py ports/raspberrypi/background.h extmod/re1.5/recursiveloop.c
uncrustify -c /home/jepler/src/circuitpython/tools/uncrustify.cfg -lC --no-backup extmod/virtpin.c ports/raspberrypi/background.h ports/raspberrypi/common-hal/pulseio/PulseIn.c
black --fast --line-length=99 -v tests/thread/thread_exit1.py
```
recursiveloop and int_small are excluded, while PulseIn, virtpin,
and background are included.

Testing running from a subdirectory (not _specifically_ supported though):
```
(cd ports && python3 ../tools/codeformat.py -v --dry-run raspberrypi/common-hal/pulseio/PulseIn.c ../extmod/virtpin.c)
../tools/codeformat.py -v --dry-run raspberrypi/common-hal/pulseio/PulseIn.c ../extmod/virtpin.c
uncrustify -c /home/jepler/src/circuitpython/tools/uncrustify.cfg -lC --no-backup ../extmod/virtpin.c raspberrypi/common-hal/pulseio/PulseIn.
```

As a side-effect, a bunch more files are re-formatted now. :-P
2021-04-30 10:48:08 -05:00
Jeff Epler b9a973c8e0 codeformat: Do search&replace without sed 2021-03-15 19:23:16 -05:00
Jeff Epler 253385d9b7 codeformat: use pathlib for correct(-er) processing of * vs ** in globs 2021-03-15 18:10:43 -05:00
Jeff Epler 0403a2cca5 codeformat: Run sed only on requested files
When running from pre-commit, we believe the different invocations of
sed were racing with each other, sometimes leaving zero-byte files in
the filesystem (ow)
2021-03-15 18:10:43 -05:00
Jeff Epler ed61e8955d codeformat: require filenames, filter them by include/exclude lists 2021-03-15 18:10:43 -05:00
Jeff Epler d0e3848b24 codeformat: Exclude specified files even from commandline, for pre-commit 2021-03-15 18:10:43 -05:00
microDev a52eb88031
run code formatting script 2021-03-15 19:27:36 +05:30
microDev 090b6ba42f
update pre-commit
- add formatting check
- add translations check
2021-03-15 19:26:29 +05:30