maxitg / SetReplace

C++/Wolfram Language package for exploring set and graph rewriting systems
MIT License
216 stars 43 forks source link

Custom files and formatting only in lint.sh #634

Closed maxitg closed 3 years ago

maxitg commented 3 years ago

Changes

Comments

Examples

$ ./lint.sh lint.sh
lint.sh
--- lint.sh.orig
+++ lint.sh
@@ -91,7 +91,7 @@
   formatWithCommand clang-format "$file"
 done

-for file in "${bashFiles[@]}"; do 
+for file in "${bashFiles[@]}"; do
   if [ $formatInPlace -eq 1 ]; then
     shfmt -w -i 2 "$file"
   else

Found formatting errors. Run ./lint.sh -i to automatically fix by applying the printed patch.

In lint.sh line 102:
for file in ${remainingFiles[@]}; do
            ^------------------^ SC2068: Double quote array expansions to avoid re-splitting elements.

For more information:
  https://www.shellcheck.net/wiki/SC2068 -- Double quote array expansions to ...
$ git add . && git commit -m "Test commit."
[feature/formatOnly 62a2b931] Test commit.
 1 file changed, 1 insertion(+), 1 deletion(-)
$ ./lint.sh lint.sh

In lint.sh line 102:
for file in ${remainingFiles[@]}; do
            ^------------------^ SC2068: Double quote array expansions to avoid re-splitting elements.

For more information:
  https://www.shellcheck.net/wiki/SC2068 -- Double quote array expansions to ...
$ git reset --hard @~1
HEAD is now at 28e1d5ae Format all files in pre-commit hook.

This change is Reviewable

maxitg commented 3 years ago

Hi, @aokellermann, could you take a look at this with your bash wisdom when you have a chance? Not urgent, though.

aokellermann commented 3 years ago

Something interesting I learned is that you can create an empty git commit (without specifying --allow-empty) if you only have illegal formatting changes staged.