Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'workhorse/_support/fmt.sh')
-rwxr-xr-xworkhorse/_support/fmt.sh25
1 files changed, 25 insertions, 0 deletions
diff --git a/workhorse/_support/fmt.sh b/workhorse/_support/fmt.sh
new file mode 100755
index 00000000000..b319ac7e328
--- /dev/null
+++ b/workhorse/_support/fmt.sh
@@ -0,0 +1,25 @@
+#!/bin/sh
+
+FLAG=-w
+if [ "x$1" = xcheck ]; then
+ FLAG=-e
+fi
+
+IMPORT_RESULT=$(
+ goimports $FLAG -local "gitlab.com/gitlab-org/gitlab-workhorse" -l $(
+ find . -type f -name '*.go' | grep -v -e /_ -e /testdata/ -e '^\./\.'
+ )
+)
+
+case "x$1" in
+ xcheck)
+ if [ -n "${IMPORT_RESULT}" ]; then
+ echo >&2 "Formatting or imports need fixing: 'make fmt'"
+ echo "${IMPORT_RESULT}"
+ exit 1
+ fi
+ ;;
+ x)
+ echo "${IMPORT_RESULT}"
+ ;;
+esac