Skip to content

Commit

Permalink
Add clang formatting for submodule as well.
Browse files Browse the repository at this point in the history
  • Loading branch information
lindsayad committed Apr 19, 2017
1 parent 38613be commit 8f75aa7
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 1 deletion.
29 changes: 29 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
BasedOnStyle: LLVM

TabWidth: 2
ColumnLimit: 100
UseTab: Never

CommentPragmas: '^/'
ReflowComments: true
AlignTrailingComments: true
SpacesBeforeTrailingComments: 1

SpaceBeforeParens: ControlStatements
SpacesInSquareBrackets: false
BreakBeforeBraces: Allman
PointerAlignment: Middle

BinPackParameters: false
BinPackArguments: false
ConstructorInitializerAllOnOneLineOrOnePerLine: true
AllowShortBlocksOnASingleLine: false
AllowShortFunctionsOnASingleLine: true
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false

SortIncludes: false
IndentCaseLabels: true
ConstructorInitializerIndentWidth: 2
AlwaysBreakAfterDefinitionReturnType: TopLevel
AlwaysBreakTemplateDeclarations: true
50 changes: 50 additions & 0 deletions scripts/install-format-hook.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#!/bin/bash

# Main repo hook file

REPO_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/../"
hookfile="$REPO_DIR/.git/hooks/pre-commit"

if [[ -f $hookfile ]]; then
echo "'$hookfile' already exists - aborting" 1>&2
else
echo '#!/bin/bash
patch=$(git clang-format --diff)
if [[ "$patch" =~ "no modified files to format" || "$patch" =~ "clang-format did not modify any files" ]]; then
echo "" > /dev/null
else
echo ""
echo "Your code has bad style." >&2
echo "Run 'git clang-format' to resolve the following issues:" >&2
echo ""
echo "$patch"
exit 1
fi
' > $hookfile
chmod a+x $hookfile
fi

# Squirrel submodule hook file

squirrel_hookfile="$REPO_DIR/.git/modules/squirrel/hooks/pre-commit"

if [[ -f $squirrel_hookfile ]]; then
echo "'$squirrel_hookfile' already exists - aborting" 1>&2
exit 1
fi

echo '#!/bin/bash
patch=$(git clang-format --diff)
if [[ "$patch" =~ "no modified files to format" || "$patch" =~ "clang-format did not modify any files" ]]; then
echo "" > /dev/null
else
echo ""
echo "Your code has bad style." >&2
echo "Run 'git clang-format' to resolve the following issues:" >&2
echo ""
echo "$patch"
exit 1
fi
' > $squirrel_hookfile

chmod a+x $squirrel_hookfile
2 changes: 1 addition & 1 deletion squirrel
Submodule squirrel updated 35 files
+2 −3 include/auxkernels/Density.h
+1 −1 include/base/SquirrelApp.h
+2 −15 include/bcs/ExampleShapeSideIntegratedBC.h
+2 −4 include/bcs/InflowBC.h
+2 −3 include/bcs/MatINSTemperatureNoBCBC.h
+2 −2 include/bcs/OutflowBC.h
+2 −17 include/bcs/RobinBC.h
+4 −5 include/bcs/TemperatureInflowBC.h
+4 −4 include/bcs/TemperatureOutflowBC.h
+2 −2 include/dgkernels/DGTemperatureAdvection.h
+3 −3 include/kernels/ConservativeTemperatureAdvection.h
+4 −4 include/kernels/MatINSTemperatureTimeDerivative.h
+1 −2 include/kernels/NonConservativeAdvection.h
+2 −15 include/kernels/PotentialAdvection.h
+3 −17 include/userobjects/DenomShapeSideUserObject.h
+3 −17 include/userobjects/NumShapeSideUserObject.h
+6 −5 src/auxkernels/Density.C
+3 −1 src/auxkernels/FunctionDerivativeAux.C
+20 −10 src/base/SquirrelApp.C
+24 −26 src/bcs/ExampleShapeSideIntegratedBC.C
+9 −7 src/bcs/InflowBC.C
+16 −21 src/bcs/MatINSTemperatureNoBCBC.C
+5 −5 src/bcs/OutflowBC.C
+7 −19 src/bcs/RobinBC.C
+5 −4 src/bcs/TemperatureInflowBC.C
+5 −4 src/bcs/TemperatureOutflowBC.C
+5 −4 src/dgkernels/DGTemperatureAdvection.C
+10 −6 src/kernels/ConservativeTemperatureAdvection.C
+7 −6 src/kernels/MatINSTemperatureTimeDerivative.C
+7 −7 src/kernels/NonConservativeAdvection.C
+10 −23 src/kernels/PotentialAdvection.C
+2 −1 src/main.C
+7 −18 src/userobjects/DenomShapeSideUserObject.C
+7 −18 src/userobjects/NumShapeSideUserObject.C
+7 −19 unit/src/main.C

0 comments on commit 8f75aa7

Please sign in to comment.