File: reformat.sh

package info (click to toggle)
proj 9.7.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 43,800 kB
  • sloc: sh: 218,851; cpp: 171,440; sql: 83,614; python: 8,422; ansic: 6,254; yacc: 1,349; makefile: 33
file content (17 lines) | stat: -rwxr-xr-x 441 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#!/bin/sh
set -eu

# Refuse to reformat nn.hpp: this is third-party code
if test $(basename $1) = "nn.hpp"; then
    exit 0
fi

clang-format-15 -style="{BasedOnStyle: llvm, IndentWidth: 4}"  $1 > $1.reformatted
if diff -u $1.reformatted $1; then
    # No reformatting: remove temporary file
    rm $1.reformatted
else
    # Differences. Backup original file, and use reformatted file
    cp $1 $1.before_reformat
    mv $1.reformatted $1
fi