File: test.sh

package info (click to toggle)
golang-go.uber-mock 0.5.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,176 kB
  • sloc: sh: 37; makefile: 3
file content (41 lines) | stat: -rwxr-xr-x 712 bytes parent folder | download
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
#!/bin/bash
# This script is used to ensure that the go.mod file is up to date.

set -euo pipefail

for i in $(find $PWD -name go.mod); do
  pushd $(dirname $i)
  go mod tidy
  popd
done

if [ ! -z "$(git status --porcelain)" ]; then
  git status
  git diff
  echo
  echo "The go.mod is not up to date."
  exit 1
fi

BASE_DIR="$PWD"
TEMP_DIR=$(mktemp -d)
function cleanup() {
  rm -rf "${TEMP_DIR}"
}
trap cleanup EXIT

cp -r . "${TEMP_DIR}/"
cd $TEMP_DIR

for i in $(find $PWD -name go.mod); do
  pushd $(dirname $i)
  go generate ./...
  popd
done

if ! diff -r . "${BASE_DIR}"; then
  echo
  echo "The generated files aren't up to date."
  echo "Update them with the 'go generate ./...' command."
  exit 1
fi