Skip to content
Snippets Groups Projects
format.sh 552 B
Newer Older
  • Learn to ignore specific revisions
  • #!/usr/bin/env sh
    
    
    # Runs the Clang Formatter
    # Return codes:
    #  - 1 there are files to be formatted
    #  - 0 everything looks fine
    
    
    Nicolas Werner's avatar
    Nicolas Werner committed
    FILES=$(find src -type f \( -iname "*.cpp" -o -iname "*.h" \))
    
    for f in $FILES
    do
    
        clang-format -i "$f"
    
    Joe Donofry's avatar
    Joe Donofry committed
    QMLFORMAT_PATH=$(command -v qmlformat || true)
    
    
    Joe Donofry's avatar
    Joe Donofry committed
    if [ -n "$QMLFORMAT_PATH" ]; then
    
    Joe Donofry's avatar
    Joe Donofry committed
        QML_FILES=$(find resources -type f -iname "*.qml")
    
        for f in $QML_FILES
        do
    
            $QMLFORMAT_PATH -i "$f"
    
    Joe Donofry's avatar
    Joe Donofry committed
        done;
    
    Joe Donofry's avatar
    Joe Donofry committed
    else
        echo "qmlformat not found; skipping qml formatting"
    
    Joe Donofry's avatar
    Joe Donofry committed
    fi
    
    
    git diff --exit-code