Debian Codegraph @

script/fmt

raw
1 #!/usr/bin/env bash
2
3 set -exuo pipefail
4
5 repo="github.com/mmcloughlin/addchain"
6
7 # Find files.
8 mapfile -t files < <(find . -name '*.go' -print0 | xargs -0 grep -L '// Code generated')
9
10 # Go formatting.
11 sed -i.fmtbackup '/^import (/,/)/ { /^$$/ d; }' "${files[@]}"
12 find . -name '*.fmtbackup' -delete
13
14 gofumports -w -local "${repo}" "${files[@]}"
15
16 # Math formatting.
17 mathfmt -w "${files[@]}"
18
19 # Bibliography references.
20 bib process -bib doc/references.bib -w "${files[@]}"
21
22 # Format the bibliography itself.
23 bib fmt -bib doc/references.bib -w