GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||
GeezerVison is showing github.com — Update pre-commit hook by FintasticMan · Pull Request #1511 · InfiniTimeOrg/InfiniTime Conversation
|
|
Detecting older and incompatible clang-format would be kinda nice. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
I could add a simple check that makes sure the version is at least 14.0.0. I could also add some slightly more complicated code that goes through all |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
I've just implemented the more complicated option. It isn't very elegant sadly, if someone can come up with a better way to do it, I would appreciate it a lot. It should work in basically all situations though (except if the user has a space in their PATH, which they really shouldn't have and will probably break other things as well). |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
842c26d to
8d2477c
Compare
8d2477c to
fcdf486
Compare
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
This should probably follow the same conventions regarding variable naming.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
fcdf486 to
3457040
Compare
There was an error while loading. Please reload this page.
|
Build size and comparison to main:
|
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
3457040 to
7c2fabb
Compare
There was an error while loading. Please reload this page.
8752c63 to
a3ec514
Compare
|
I've switched to a more robust method of getting the files that have changed. This doesn't rely on using human-readable output that could potentially be changed in an update. I have a git stash with a bit more logic that more conclusively finds the highest clang-format version, by using |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
I'd be interested to see your new clang-format finding code regardless, if you could post a patch. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
diff --git a/hooks/pre-commit b/hooks/pre-commit index e03b4217..60a01e34 100755 --- a/hooks/pre-commit +++ b/hooks/pre-commit @@ -1,23 +1,29 @@ #!/bin/sh +name="clang-format" + +if [ -z "$(command -v "git-$name")" ]; then + name="$(basename -a $(find $(echo "$PATH" | tr ':' ' ') -maxdepth 1 -type f -executable -name 'git-clang-format*') | sort | tail -n 1 | sed 's/^git-//')" +fi + minVersion="14.0.0" -for file in $(find $(echo "$PATH" | tr ':' ' ') -maxdepth 1 -type f -executable -name 'git-clang-format*'); do - curName="$(basename "$file" | sed 's/^git-//')" - curVersion="$("$curName" --version | cut -d ' ' -f 3)" +for file in $(find $(echo "$PATH" | tr ':' ' ') -maxdepth 1 -type f -executable -name 'clang-format*'); do + curBin="$file" + curVersion="$("$curBin" --version | cut -d ' ' -f 3)" if [ "$(printf '%s\n' "$curVersion" "$version" "$minVersion" | sort -V | tail -n 1)" = "$curVersion" ]; then - name="$curName" + bin="$curBin" version="$curVersion" fi done -if [ -z "$name" ]; then +if [ -z "$name" ] || [ -z "$bin" ]; then echo "Could not find a suitable clang-format installation. Install clang-format that includes the git-clang-format script, with at least version $minVersion" exit 1 fi -args='-q --extensions cpp,h --style file --staged -- :!src/FreeRTOS :!src/libs' +args="--binary $bin -q --extensions cpp,h --style file --staged -- :!src/FreeRTOS :!src/libs" changedFiles="$(git "$name" --diffstat $args)" git "$name" $args Here is a patch. The code for finding the clang-format binary is mostly the same, but the script now stores both the git-clang-format script name and the actual clang-format binary. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
a3ec514 to
5b3db43
Compare
5b3db43 to
77af275
Compare
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.