Skip to content

Ensure goimports formatting job works with submodules

Adam Cohen requested to merge 340780-fix-goimports-job into master

What does this MR do?

This MR fixes an issue with the goimports formatting job introduced by Add a formatting check for Go projects which was preventing code with updated submodules from passing the formatting check.

What are the relevant issue numbers?

gitlab-org/gitlab#340780 (closed)

Tests

Before change:

goimports formatting job fails:

$ GO111MODULE=off go get golang.org/x/tools/cmd/goimports
$ FMT_CMD='goimports -w -local gitlab.com/gitlab-org .'
$ eval "$FMT_CMD"
$ if ! git diff --exit-code; then # collapsed multi-line command
diff --git a/gemnasium b/gemnasium
--- a/gemnasium
+++ b/gemnasium
@@ -1 +1 @@
-Subproject commit c268a938eb3589bd6916963db63b9c4f0c4d09ab
+Subproject commit c268a938eb3589bd6916963db63b9c4f0c4d09ab-dirty
Some files are not formatted. Please format with `goimports -w -local gitlab.com/gitlab-org .`
See https://docs.gitlab.com/ee/development/go_guide/#code-style-and-format-1 for more information
Cleaning up project directory and file based variables
00:00
ERROR: Job failed: exit code 1

After change:

goimports formatting job passes:

$ GO111MODULE=off go get golang.org/x/tools/cmd/goimports
$ FMT_CMD='goimports -w -local gitlab.com/gitlab-org .'
$ eval "$FMT_CMD"
$ if ! git diff --ignore-submodules=dirty --exit-code; then # collapsed multi-line command
Cleaning up project directory and file based variables
00:01
Job succeeded

Does this MR meet the acceptance criteria?

Edited by Adam Cohen

Merge request reports