ci_template: Use git diff --quiet for checking for changes
authorJan Alexander Steffens (heftig) <jan.steffens@gmail.com>
Wed, 5 Dec 2018 21:12:09 +0000 (22:12 +0100)
committerJan Alexander Steffens (heftig) <jan.steffens@gmail.com>
Wed, 5 Dec 2018 21:26:07 +0000 (22:26 +0100)
Checking the exit code of git diff --quiet is preferred over looking
whether git diff produces any output.

gitlab/ci_template.yml

index 380343f..7052006 100644 (file)
@@ -46,12 +46,12 @@ gst indent:
     - chmod +x gst-indent
     - find . -name '*.c' -exec ./gst-indent {} +
     - |
-      if [[ $(git diff) ]]; then
+      if git diff --quiet; then
+          echo "Code is properly formatted"
+      else
           git diff --color=always
           echo 'style diverges, please run gst-indent first'
           exit 1
-      else
-          echo "Code is properly formatted"
       fi
   except:
     variables: