File: format

package info (click to toggle)
golang-github-gophercloud-gophercloud 0.0~git20180917.45f1c769-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 7,768 kB
  • sloc: sh: 98; makefile: 14
file content (41 lines) | stat: -rwxr-xr-x 1,010 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/usr/bin/env bash

goimports="goimports"

find_files() {
  find . -not \( \
      \( \
        -wholename './output' \
        -o -wholename './_output' \
        -o -wholename './_gopath' \
        -o -wholename './release' \
        -o -wholename './target' \
        -o -wholename '*/third_party/*' \
        -o -wholename '*/vendor/*' \
      \) -prune \
    \) -name '*.go'
}

ignore_files=(
  "./openstack/compute/v2/extensions/quotasets/testing/fixtures.go"
  "./openstack/networking/v2/extensions/vpnaas/ikepolicies/testing/requests_test.go"
)

bad_files=$(find_files | xargs ${goimports} -l)

final_files=()
for bad_file in $bad_files; do
  found=
  for ignore_file in "${ignore_files[@]}"; do
    [[ "${bad_file}" == "${ignore_file}" ]] && { found=1; break; }
  done
  [[ -n $found ]] || final_files+=("$bad_file")
done

if [[ "${#final_files[@]}" -gt 0 ]]; then
  diff=$(echo "${final_files[@]}" | xargs ${goimports} -d -e 2>&1)
  if [[ -n "${diff}" ]]; then
    echo "${diff}"
    exit 1
  fi
fi