Repository: goreleaser/goreleaser
Pull request #2135 (2021-03-23 02:56:59)

feat: fail on shallow clone
closes https://github.com/goreleaser/goreleaser/issues/2134

vercel[bot]: This pull request is being automatically deployed with Vercel ([learn more](https://vercel.link/github-learn-more)).  
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: [https://vercel.com/goreleaser/goreleaser/4NjBRN998eMhxAg84Th18EnGrsXj](https://vercel.com/goreleaser/goreleaser/4NjBRN998eMhxAg84Th18EnGrsXj)  
✅ Preview: [https://goreleaser-git-shallow-goreleaser.vercel.app](https://goreleaser-git-shallow-goreleaser.vercel.app)


codecov[bot]: # [Codecov](https://codecov.io/gh/goreleaser/goreleaser/pull/2135?src=pr&el=h1) Report
> Merging [#2135](https://codecov.io/gh/goreleaser/goreleaser/pull/2135?src=pr&el=desc) (4100ead) into [master](https://codecov.io/gh/goreleaser/goreleaser/commit/251e4486ed0607aed0bf577c6ff87e0679e5dc86?el=desc) (251e448) will **increase** coverage by `0.00%`.
> The diff coverage is `100.00%`.

[![Impacted file tree graph](https://codecov.io/gh/goreleaser/goreleaser/pull/2135/graphs/tree.svg?width=650&height=150&src=pr&token=3bJvv6b7hN)](https://codecov.io/gh/goreleaser/goreleaser/pull/2135?src=pr&el=tree)

```diff
@@           Coverage Diff           @@
##           master    #2135   +/-   ##
=======================================
  Coverage   82.80%   82.81%           
=======================================
  Files          75       75           
  Lines        4037     4039    +2     
=======================================
+ Hits         3343     3345    +2     
  Misses        566      566           
  Partials      128      128           
```


| [Impacted Files](https://codecov.io/gh/goreleaser/goreleaser/pull/2135?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [internal/pipe/git/errors.go](https://codecov.io/gh/goreleaser/goreleaser/pull/2135/diff?src=pr&el=tree#diff-aW50ZXJuYWwvcGlwZS9naXQvZXJyb3JzLmdv) | `100.00% <ø> (ø)` | |
| [internal/pipe/git/git.go](https://codecov.io/gh/goreleaser/goreleaser/pull/2135/diff?src=pr&el=tree#diff-aW50ZXJuYWwvcGlwZS9naXQvZ2l0Lmdv) | `86.86% <100.00%> (+0.27%)` | :arrow_up: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/goreleaser/goreleaser/pull/2135?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/goreleaser/goreleaser/pull/2135?src=pr&el=footer). Last update [251e448...4100ead](https://codecov.io/gh/goreleaser/goreleaser/pull/2135?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).


Patch:
diff --git a/internal/builders/golang/build.go b/internal/builders/golang/build.go
index dae09f26..515c3be3 100644
--- a/internal/builders/golang/build.go
+++ b/internal/builders/golang/build.go
@@ -227,7 +227,7 @@ func checkMain(build config.Build) error {
 	}
 	stat, ferr := os.Stat(main)
 	if ferr != nil {
-		return ferr
+		return fmt.Errorf("couldn't find main file: %w", ferr)
 	}
 	if stat.IsDir() {
 		packs, err := parser.ParseDir(token.NewFileSet(), main, nil, 0)
diff --git a/internal/pipe/git/errors.go b/internal/pipe/git/errors.go
index e4360f5a..f0331215 100644
--- a/internal/pipe/git/errors.go
+++ b/internal/pipe/git/errors.go
@@ -33,3 +33,7 @@ var ErrNotRepository = errors.New("current folder is not a git repository")
 
 // ErrNoGit happens when git is not present in PATH.
 var ErrNoGit = errors.New("git not present in PATH")
+
+// ErrShallowClone happens when goreleaser runs against a shallow copy of a repo.
+// You'll need to setup your clone step to clone the whole repo instead.
+var ErrShallowClone = errors.New("refusing to run against a shallow clone, please make sure to clone the whole tree")
diff --git a/internal/pipe/git/git.go b/internal/pipe/git/git.go
index 2d2ba64a..4fa8ec30 100644
--- a/internal/pipe/git/git.go
+++ b/internal/pipe/git/git.go
@@ -116,6 +116,9 @@ func validate(ctx *context.Context) error {
 	if ctx.SkipValidate {
 		return pipe.ErrSkipValidateEnabled
 	}
+	if _, err := os.Stat(".git/shallow"); err == nil {
+		return ErrShallowClone
+	}
 	out, err := git.Run("status", "--porcelain")
 	if strings.TrimSpace(out) != "" || err != nil {
 		return ErrDirty{status: out}
diff --git a/www/docs/customization/homebrew.md b/www/docs/customization/homebrew.md
index 215877b0..866446fd 100644
--- a/www/docs/customization/homebrew.md
+++ b/www/docs/customization/homebrew.md
@@ -132,6 +132,13 @@ brews:
     install: |
       bin.install "program"
       ...
+      
+    # Custom post_install script for brew.
+    # Could be used to do any additional work after the "install" script
+    # Default is empty.
+    post_install: |
+    	etc.install "app-config.conf"
+    	...
 ```
 
 !!! tip
@@ -171,6 +178,10 @@ class Program < Formula
   def install
     bin.install "program"
   end
+  
+  def post_install
+  	etc.install "app-config.conf"
+  end
 end
 ```
 
diff --git a/www/docs/install.md b/www/docs/install.md
index cb233373..8e9759d1 100644
--- a/www/docs/install.md
+++ b/www/docs/install.md
@@ -7,7 +7,7 @@ Here are the steps for each of them:
 
 ## Install the pre-compiled binary
 
-**homebrew tap** (only on macOS for now):
+**homebrew tap**:
 
 ```sh
 brew install goreleaser/tap/goreleaser
@@ -32,17 +32,22 @@ scoop bucket add goreleaser https://github.com/goreleaser/scoop-bucket.git
 scoop install goreleaser
 ```
 
-**deb/rpm**:
+**deb/rpm/apk**:
 
-Download the `.deb` or `.rpm` from the [releases page][releases] and
-install with `dpkg -i` and `rpm -i` respectively.
+Download the `.deb`, `.rpm` or `.apk` from the [releases page][releases] and install them with the appropriate tools.
 
-**Shell script**:
+**shell script**:
 
 ```sh
 curl -sfL https://install.goreleaser.com/github.com/goreleaser/goreleaser.sh | sh
 ```
 
+**go install**:
+
+```sh
+go install github.com/goreleaser/goreleaser
+```
+
 **manually**:
 
 Download the pre-compiled binaries from the [releases page][releases] and
@@ -90,26 +95,26 @@ steps on our [contributing guide](/contributing).
 
 If you just want to build from source for whatever reason, follow these steps:
 
-**Clone:**
+**clone:**
 
 ```sh
 git clone https://github.com/goreleaser/goreleaser
 cd goreleaser
 ```
 
-**Get the dependencies:**
+**get the dependencies:**
 
 ```sh
-go get ./...
+go mod tidy
 ```
 
-**Build:**
+**build:**
 
 ```sh
 go build -o goreleaser .
 ```
 
-**Verify it works:**
+**verify it works:**
 
 ```sh
 ./goreleaser --version


Test patch:
diff --git a/internal/builders/golang/build_test.go b/internal/builders/golang/build_test.go
index 10cae9ae..fb8d3002 100644
--- a/internal/builders/golang/build_test.go
+++ b/internal/builders/golang/build_test.go
@@ -89,12 +89,12 @@ func TestWithDefaults(t *testing.T) {
 		},
 	} {
 		t.Run(name, func(t *testing.T) {
-			var config = config.Project{
+			config := config.Project{
 				Builds: []config.Build{
 					testcase.build,
 				},
 			}
-			var ctx = context.New(config)
+			ctx := context.New(config)
 			ctx.Git.CurrentTag = "5.6.7"
 			build, err := Default.WithDefaults(ctx.Config.Builds[0])
 			require.NoError(t, err)
@@ -138,12 +138,12 @@ func TestInvalidTargets(t *testing.T) {
 		},
 	} {
 		t.Run(s, func(t *testing.T) {
-			var config = config.Project{
+			config := config.Project{
 				Builds: []config.Build{
 					tc.build,
 				},
 			}
-			var ctx = context.New(config)
+			ctx := context.New(config)
 			_, err := Default.WithDefaults(ctx.Config.Builds[0])
 			require.EqualError(t, err, tc.expectedErr)
 		})
@@ -151,9 +151,9 @@ func TestInvalidTargets(t *testing.T) {
 }
 
 func TestBuild(t *testing.T) {
-	var folder = testlib.Mktmp(t)
+	folder := testlib.Mktmp(t)
 	writeGoodMain(t, folder)
-	var config = config.Project{
+	config := config.Project{
 		Builds: []config.Build{
 			{
 				ID:     "foo",
@@ -175,11 +175,11 @@ func TestBuild(t *testing.T) {
 			},
 		},
 	}
-	var ctx = context.New(config)
+	ctx := context.New(config)
 	ctx.Env["GO_FLAGS"] = "-v"
 	ctx.Git.CurrentTag = "5.6.7"
 	ctx.Version = "v" + ctx.Git.CurrentTag
-	var build = ctx.Config.Builds[0]
+	build := ctx.Config.Builds[0]
 	for _, target := range build.Targets {
 		var ext string
 		if strings.HasPrefix(target, "windows") {
@@ -193,7 +193,7 @@ func TestBuild(t *testing.T) {
 		// injecting some delay here to force inconsistent mod times on bins
 		time.Sleep(2 * time.Second)
 
-		var err = Default.Build(ctx, build, api.Options{
+		err := Default.Build(ctx, build, api.Options{
 			Target: target,
 			Name:   bin + ext,
 			Path:   filepath.Join(folder, "dist", target, bin+ext),
@@ -311,12 +311,12 @@ func TestBuild(t *testing.T) {
 }
 
 func TestBuildCodeInSubdir(t *testing.T) {
-	var folder = testlib.Mktmp(t)
+	folder := testlib.Mktmp(t)
 	subdir := filepath.Join(folder, "bar")
-	err := os.Mkdir(subdir, 0755)
+	err := os.Mkdir(subdir, 0o755)
 	require.NoError(t, err)
 	writeGoodMain(t, subdir)
-	var config = config.Project{
+	config := config.Project{
 		Builds: []config.Build{
 			{
 				ID:     "foo",
@@ -330,9 +330,9 @@ func TestBuildCodeInSubdir(t *testing.T) {
 			},
 		},
 	}
-	var ctx = context.New(config)
+	ctx := context.New(config)
 	ctx.Git.CurrentTag = "5.6.7"
-	var build = ctx.Config.Builds[0]
+	build := ctx.Config.Builds[0]
 	err = Default.Build(ctx, build, api.Options{
 		Target: runtimeTarget,
 		Name:   build.Binary,
@@ -343,10 +343,10 @@ func TestBuildCodeInSubdir(t *testing.T) {
 }
 
 func TestBuildWithDotGoDir(t *testing.T) {
-	var folder = testlib.Mktmp(t)
-	require.NoError(t, os.Mkdir(filepath.Join(folder, ".go"), 0755))
+	folder := testlib.Mktmp(t)
+	require.NoError(t, os.Mkdir(filepath.Join(folder, ".go"), 0o755))
 	writeGoodMain(t, folder)
-	var config = config.Project{
+	config := config.Project{
 		Builds: []config.Build{
 			{
 				ID:       "foo",
@@ -357,9 +357,9 @@ func TestBuildWithDotGoDir(t *testing.T) {
 			},
 		},
 	}
-	var ctx = context.New(config)
+	ctx := context.New(config)
 	ctx.Git.CurrentTag = "5.6.7"
-	var build = ctx.Config.Builds[0]
+	build := ctx.Config.Builds[0]
 	require.NoError(t, Default.Build(ctx, build, api.Options{
 		Target: runtimeTarget,
 		Name:   build.Binary,
@@ -369,9 +369,9 @@ func TestBuildWithDotGoDir(t *testing.T) {
 }
 
 func TestBuildFailed(t *testing.T) {
-	var folder = testlib.Mktmp(t)
+	folder := testlib.Mktmp(t)
 	writeGoodMain(t, folder)
-	var config = config.Project{
+	config := config.Project{
 		Builds: []config.Build{
 			{
 				ID:    "buildid",
@@ -383,9 +383,9 @@ func TestBuildFailed(t *testing.T) {
 			},
 		},
 	}
-	var ctx = context.New(config)
+	ctx := context.New(config)
 	ctx.Git.CurrentTag = "5.6.7"
-	var err = Default.Build(ctx, ctx.Config.Builds[0], api.Options{
+	err := Default.Build(ctx, ctx.Config.Builds[0], api.Options{
 		Target: "darwin_amd64",
 	})
 	assertContainsError(t, err, `flag provided but not defined: -flag-that-dont-exists-to-force-failure`)
@@ -393,10 +393,10 @@ func TestBuildFailed(t *testing.T) {
 }
 
 func TestBuildInvalidTarget(t *testing.T) {
-	var folder = testlib.Mktmp(t)
+	folder := testlib.Mktmp(t)
 	writeGoodMain(t, folder)
-	var target = "linux"
-	var config = config.Project{
+	target := "linux"
+	config := config.Project{
 		Builds: []config.Build{
 			{
 				ID:      "foo",
@@ -405,10 +405,10 @@ func TestBuildInvalidTarget(t *testing.T) {
 			},
 		},
 	}
-	var ctx = context.New(config)
+	ctx := context.New(config)
 	ctx.Git.CurrentTag = "5.6.7"
-	var build = ctx.Config.Builds[0]
-	var err = Default.Build(ctx, build, api.Options{
+	build := ctx.Config.Builds[0]
+	err := Default.Build(ctx, build, api.Options{
 		Target: target,
 		Name:   build.Binary,
 		Path:   filepath.Join(folder, "dist", target, build.Binary),
@@ -418,9 +418,9 @@ func TestBuildInvalidTarget(t *testing.T) {
 }
 
 func TestRunInvalidAsmflags(t *testing.T) {
-	var folder = testlib.Mktmp(t)
+	folder := testlib.Mktmp(t)
 	writeGoodMain(t, folder)
-	var config = config.Project{
+	config := config.Project{
 		Builds: []config.Build{
 			{
 				Binary:   "nametest",
@@ -431,18 +431,18 @@ func TestRunInvalidAsmflags(t *testing.T) {
 			},
 		},
 	}
-	var ctx = context.New(config)
+	ctx := context.New(config)
 	ctx.Git.CurrentTag = "5.6.7"
-	var err = Default.Build(ctx, ctx.Config.Builds[0], api.Options{
+	err := Default.Build(ctx, ctx.Config.Builds[0], api.Options{
 		Target: runtimeTarget,
 	})
 	require.EqualError(t, err, `template: tmpl:1: unexpected "}" in operand`)
 }
 
 func TestRunInvalidGcflags(t *testing.T) {
-	var folder = testlib.Mktmp(t)
+	folder := testlib.Mktmp(t)
 	writeGoodMain(t, folder)
-	var config = config.Project{
+	config := config.Project{
 		Builds: []config.Build{
 			{
 				Binary:  "nametest",
@@ -453,18 +453,18 @@ func TestRunInvalidGcflags(t *testing.T) {
 			},
 		},
 	}
-	var ctx = context.New(config)
+	ctx := context.New(config)
 	ctx.Git.CurrentTag = "5.6.7"
-	var err = Default.Build(ctx, ctx.Config.Builds[0], api.Options{
+	err := Default.Build(ctx, ctx.Config.Builds[0], api.Options{
 		Target: runtimeTarget,
 	})
 	require.EqualError(t, err, `template: tmpl:1: unexpected "}" in operand`)
 }
 
 func TestRunInvalidLdflags(t *testing.T) {
-	var folder = testlib.Mktmp(t)
+	folder := testlib.Mktmp(t)
 	writeGoodMain(t, folder)
-	var config = config.Project{
+	config := config.Project{
 		Builds: []config.Build{
 			{
 				Binary:  "nametest",
@@ -476,18 +476,18 @@ func TestRunInvalidLdflags(t *testing.T) {
 			},
 		},
 	}
-	var ctx = context.New(config)
+	ctx := context.New(config)
 	ctx.Git.CurrentTag = "5.6.7"
-	var err = Default.Build(ctx, ctx.Config.Builds[0], api.Options{
+	err := Default.Build(ctx, ctx.Config.Builds[0], api.Options{
 		Target: runtimeTarget,
 	})
 	require.EqualError(t, err, `template: tmpl:1: unexpected "}" in operand`)
 }
 
 func TestRunInvalidFlags(t *testing.T) {
-	var folder = testlib.Mktmp(t)
+	folder := testlib.Mktmp(t)
 	writeGoodMain(t, folder)
-	var config = config.Project{
+	config := config.Project{
 		Builds: []config.Build{
 			{
 				Binary: "nametest",
@@ -498,17 +498,17 @@ func TestRunInvalidFlags(t *testing.T) {
 			},
 		},
 	}
-	var ctx = context.New(config)
-	var err = Default.Build(ctx, ctx.Config.Builds[0], api.Options{
+	ctx := context.New(config)
+	err := Default.Build(ctx, ctx.Config.Builds[0], api.Options{
 		Target: runtimeTarget,
 	})
 	require.EqualError(t, err, `template: tmpl:1: unexpected "}" in operand`)
 }
 
 func TestRunPipeWithoutMainFunc(t *testing.T) {
-	var folder = testlib.Mktmp(t)
+	folder := testlib.Mktmp(t)
 	writeMainWithoutMainFunc(t, folder)
-	var config = config.Project{
+	config := config.Project{
 		Builds: []config.Build{
 			{
 				Binary: "no-main",
@@ -519,7 +519,7 @@ func TestRunPipeWithoutMainFunc(t *testing.T) {
 			},
 		},
 	}
-	var ctx = context.New(config)
+	ctx := context.New(config)
 	ctx.Git.CurrentTag = "5.6.7"
 	t.Run("empty", func(t *testing.T) {
 		ctx.Config.Builds[0].Main = ""
@@ -531,7 +531,7 @@ func TestRunPipeWithoutMainFunc(t *testing.T) {
 		ctx.Config.Builds[0].Main = "foo.go"
 		require.EqualError(t, Default.Build(ctx, ctx.Config.Builds[0], api.Options{
 			Target: runtimeTarget,
-		}), `stat foo.go: no such file or directory`)
+		}), `couldn't find main file: stat foo.go: no such file or directory`)
 	})
 	t.Run("glob", func(t *testing.T) {
 		ctx.Config.Builds[0].Main = "."
@@ -548,13 +548,13 @@ func TestRunPipeWithoutMainFunc(t *testing.T) {
 }
 
 func TestRunPipeWithMainFuncNotInMainGoFile(t *testing.T) {
-	var folder = testlib.Mktmp(t)
+	folder := testlib.Mktmp(t)
 	require.NoError(t, ioutil.WriteFile(
 		filepath.Join(folder, "foo.go"),
 		[]byte("package main\nfunc main() {println(0)}"),
-		0644,
+		0o644,
 	))
-	var config = config.Project{
+	config := config.Project{
 		Builds: []config.Build{
 			{
 				Env:    []string{"GO111MODULE=off"},
@@ -567,7 +567,7 @@ func TestRunPipeWithMainFuncNotInMainGoFile(t *testing.T) {
 			},
 		},
 	}
-	var ctx = context.New(config)
+	ctx := context.New(config)
 	ctx.Git.CurrentTag = "5.6.7"
 	t.Run("empty", func(t *testing.T) {
 		ctx.Config.Builds[0].Main = ""
@@ -593,7 +593,7 @@ func TestLdFlagsFullTemplate(t *testing.T) {
 	run := time.Now().UTC()
 	commit := time.Now().AddDate(-1, 0, 0)
 
-	var ctx = &context.Context{
+	ctx := &context.Context{
 		Git: context.GitInfo{
 			CurrentTag: "v1.2.3",
 			Commit:     "123",
@@ -603,7 +603,7 @@ func TestLdFlagsFullTemplate(t *testing.T) {
 		Version: "1.2.3",
 		Env:     map[string]string{"FOO": "123"},
 	}
-	var artifact = &artifact.Artifact{Goarch: "amd64"}
+	artifact := &artifact.Artifact{Goarch: "amd64"}
 	flags, err := tmpl.New(ctx).WithArtifact(artifact, map[string]string{}).
 		Apply(`-s -w -X main.version={{.Version}} -X main.tag={{.Tag}} -X main.date={{.Date}} -X main.commit={{.Commit}} -X "main.foo={{.Env.FOO}}" -X main.time={{ time "20060102" }} -X main.arch={{.Arch}} -X main.commitDate={{.CommitDate}}`)
 	require.NoError(t, err)
@@ -624,7 +624,7 @@ func TestInvalidTemplate(t *testing.T) {
 		"{{.Env.NOPE}}": `template: tmpl:1:6: executing "tmpl" at <.Env.NOPE>: map has no entry for key "NOPE"`,
 	} {
 		t.Run(template, func(t *testing.T) {
-			var ctx = context.New(config.Project{})
+			ctx := context.New(config.Project{})
 			ctx.Git.CurrentTag = "3.4.1"
 			flags, err := tmpl.New(ctx).Apply(template)
 			require.EqualError(t, err, eerr)
@@ -634,12 +634,12 @@ func TestInvalidTemplate(t *testing.T) {
 }
 
 func TestProcessFlags(t *testing.T) {
-	var ctx = &context.Context{
+	ctx := &context.Context{
 		Version: "1.2.3",
 	}
 	ctx.Git.CurrentTag = "5.6.7"
 
-	var artifact = &artifact.Artifact{
+	artifact := &artifact.Artifact{
 		Name:   "name",
 		Goos:   "darwin",
 		Goarch: "amd64",
@@ -649,7 +649,7 @@ func TestProcessFlags(t *testing.T) {
 		},
 	}
 
-	var source = []string{
+	source := []string{
 		"flag",
 		"{{.Version}}",
 		"{{.Os}}",
@@ -659,7 +659,7 @@ func TestProcessFlags(t *testing.T) {
 		"{{.ArtifactName}}",
 	}
 
-	var expected = []string{
+	expected := []string{
 		"-testflag=flag",
 		"-testflag=1.2.3",
 		"-testflag=darwin",
@@ -676,13 +676,13 @@ func TestProcessFlags(t *testing.T) {
 }
 
 func TestProcessFlagsInvalid(t *testing.T) {
-	var ctx = &context.Context{}
+	ctx := &context.Context{}
 
-	var source = []string{
+	source := []string{
 		"{{.Version}",
 	}
 
-	var expected = `template: tmpl:1: unexpected "}" in operand`
+	expected := `template: tmpl:1: unexpected "}" in operand`
 
 	flags, err := processFlags(ctx, &artifact.Artifact{}, []string{}, source, "-testflag=")
 	require.EqualError(t, err, expected)
@@ -708,10 +708,10 @@ func TestBuildModTimestamp(t *testing.T) {
 	// round to seconds since this will be a unix timestamp
 	modTime := time.Now().AddDate(-1, 0, 0).Round(1 * time.Second).UTC()
 
-	var folder = testlib.Mktmp(t)
+	folder := testlib.Mktmp(t)
 	writeGoodMain(t, folder)
 
-	var config = config.Project{
+	config := config.Project{
 		Builds: []config.Build{
 			{
 				ID:     "foo",
@@ -734,11 +734,11 @@ func TestBuildModTimestamp(t *testing.T) {
 			},
 		},
 	}
-	var ctx = context.New(config)
+	ctx := context.New(config)
 	ctx.Env["GO_FLAGS"] = "-v"
 	ctx.Git.CurrentTag = "5.6.7"
 	ctx.Version = "v" + ctx.Git.CurrentTag
-	var build = ctx.Config.Builds[0]
+	build := ctx.Config.Builds[0]
 	for _, target := range build.Targets {
 		var ext string
 		if strings.HasPrefix(target, "windows") {
@@ -752,7 +752,7 @@ func TestBuildModTimestamp(t *testing.T) {
 		// injecting some delay here to force inconsistent mod times on bins
 		time.Sleep(2 * time.Second)
 
-		var err = Default.Build(ctx, build, api.Options{
+		err := Default.Build(ctx, build, api.Options{
 			Target: target,
 			Name:   bin + ext,
 			Path:   filepath.Join(folder, "dist", target, bin+ext),
@@ -781,7 +781,7 @@ func writeMainWithoutMainFunc(t *testing.T, folder string) {
 	require.NoError(t, ioutil.WriteFile(
 		filepath.Join(folder, "main.go"),
 		[]byte("package main\nconst a = 2\nfunc notMain() {println(0)}"),
-		0644,
+		0o644,
 	))
 }
 
@@ -790,7 +790,7 @@ func writeGoodMain(t *testing.T, folder string) {
 	require.NoError(t, ioutil.WriteFile(
 		filepath.Join(folder, "main.go"),
 		[]byte("package main\nvar a = 1\nfunc main() {println(0)}"),
-		0644,
+		0o644,
 	))
 }
 
diff --git a/internal/pipe/git/git_test.go b/internal/pipe/git/git_test.go
index 9e3bbb16..b5e2818a 100644
--- a/internal/pipe/git/git_test.go
+++ b/internal/pipe/git/git_test.go
@@ -3,6 +3,7 @@ package git
 import (
 	"io/ioutil"
 	"os"
+	"os/exec"
 	"path/filepath"
 	"testing"
 	"time"
@@ -20,7 +21,7 @@ func TestDescription(t *testing.T) {
 
 func TestNotAGitFolder(t *testing.T) {
 	testlib.Mktmp(t)
-	var ctx = &context.Context{
+	ctx := &context.Context{
 		Config: config.Project{},
 	}
 	require.EqualError(t, Pipe{}.Run(ctx), ErrNotRepository.Error())
@@ -32,7 +33,7 @@ func TestSingleCommit(t *testing.T) {
 	testlib.GitRemoteAdd(t, "git@github.com:foo/bar.git")
 	testlib.GitCommit(t, "commit1")
 	testlib.GitTag(t, "v0.0.1")
-	var ctx = &context.Context{
+	ctx := &context.Context{
 		Config: config.Project{},
 	}
 	require.NoError(t, Pipe{}.Run(ctx))
@@ -46,7 +47,7 @@ func TestBranch(t *testing.T) {
 	testlib.GitCommit(t, "test-branch-commit")
 	testlib.GitTag(t, "test-branch-tag")
 	testlib.GitCheckoutBranch(t, "test-branch")
-	var ctx = &context.Context{
+	ctx := &context.Context{
 		Config: config.Project{},
 	}
 	require.NoError(t, Pipe{}.Run(ctx))
@@ -58,7 +59,7 @@ func TestNoRemote(t *testing.T) {
 	testlib.GitInit(t)
 	testlib.GitCommit(t, "commit1")
 	testlib.GitTag(t, "v0.0.1")
-	var ctx = &context.Context{
+	ctx := &context.Context{
 		Config: config.Project{},
 	}
 	require.EqualError(t, Pipe{}.Run(ctx), "couldn't get remote URL: fatal: No remote configured to list refs from.")
@@ -67,7 +68,7 @@ func TestNoRemote(t *testing.T) {
 func TestNewRepository(t *testing.T) {
 	testlib.Mktmp(t)
 	testlib.GitInit(t)
-	var ctx = &context.Context{
+	ctx := &context.Context{
 		Config: config.Project{},
 	}
 	// TODO: improve this error handling
@@ -82,13 +83,13 @@ func TestNoTagsNoSnapshot(t *testing.T) {
 	testlib.GitInit(t)
 	testlib.GitRemoteAdd(t, "git@github.com:foo/bar.git")
 	testlib.GitCommit(t, "first")
-	var ctx = context.New(config.Project{})
+	ctx := context.New(config.Project{})
 	ctx.Snapshot = false
 	require.EqualError(t, Pipe{}.Run(ctx), `git doesn't contain any tags. Either add a tag or use --snapshot`)
 }
 
 func TestDirty(t *testing.T) {
-	var folder = testlib.Mktmp(t)
+	folder := testlib.Mktmp(t)
 	testlib.GitInit(t)
 	testlib.GitRemoteAdd(t, "git@github.com:foo/bar.git")
 	dummy, err := os.Create(filepath.Join(folder, "dummy"))
@@ -96,22 +97,48 @@ func TestDirty(t *testing.T) {
 	testlib.GitAdd(t)
 	testlib.GitCommit(t, "commit2")
 	testlib.GitTag(t, "v0.0.1")
-	require.NoError(t, ioutil.WriteFile(dummy.Name(), []byte("lorem ipsum"), 0644))
+	require.NoError(t, ioutil.WriteFile(dummy.Name(), []byte("lorem ipsum"), 0o644))
 	t.Run("all checks up", func(t *testing.T) {
-		err = Pipe{}.Run(context.New(config.Project{}))
+		err := Pipe{}.Run(context.New(config.Project{}))
 		require.Error(t, err)
 		require.Contains(t, err.Error(), "git is currently in a dirty state")
 	})
 	t.Run("skip validate is set", func(t *testing.T) {
 		ctx := context.New(config.Project{})
 		ctx.SkipValidate = true
-		err = Pipe{}.Run(ctx)
 		testlib.AssertSkipped(t, Pipe{}.Run(ctx))
 	})
 	t.Run("snapshot", func(t *testing.T) {
 		ctx := context.New(config.Project{})
 		ctx.Snapshot = true
-		err = Pipe{}.Run(ctx)
+		testlib.AssertSkipped(t, Pipe{}.Run(ctx))
+	})
+}
+
+func TestShallowClone(t *testing.T) {
+	folder := testlib.Mktmp(t)
+	require.NoError(
+		t,
+		exec.Command(
+			"git", "clone",
+			"--depth", "1",
+			"--branch", "v0.160.0",
+			"https://github.com/goreleaser/goreleaser",
+			folder,
+		).Run(),
+	)
+	t.Run("all checks up", func(t *testing.T) {
+		err := Pipe{}.Run(context.New(config.Project{}))
+		require.EqualError(t, err, ErrShallowClone.Error())
+	})
+	t.Run("skip validate is set", func(t *testing.T) {
+		ctx := context.New(config.Project{})
+		ctx.SkipValidate = true
+		testlib.AssertSkipped(t, Pipe{}.Run(ctx))
+	})
+	t.Run("snapshot", func(t *testing.T) {
+		ctx := context.New(config.Project{})
+		ctx.Snapshot = true
 		testlib.AssertSkipped(t, Pipe{}.Run(ctx))
 	})
 }
@@ -136,7 +163,7 @@ func TestValidState(t *testing.T) {
 	testlib.GitTag(t, "v0.0.1")
 	testlib.GitCommit(t, "commit4")
 	testlib.GitTag(t, "v0.0.2")
-	var ctx = context.New(config.Project{})
+	ctx := context.New(config.Project{})
 	require.NoError(t, Pipe{}.Run(ctx))
 	require.Equal(t, "v0.0.2", ctx.Git.CurrentTag)
 	require.Equal(t, "git@github.com:foo/bar.git", ctx.Git.URL)
@@ -148,7 +175,7 @@ func TestSnapshotNoTags(t *testing.T) {
 	testlib.GitRemoteAdd(t, "git@github.com:foo/bar.git")
 	testlib.GitAdd(t)
 	testlib.GitCommit(t, "whatever")
-	var ctx = context.New(config.Project{})
+	ctx := context.New(config.Project{})
 	ctx.Snapshot = true
 	testlib.AssertSkipped(t, Pipe{}.Run(ctx))
 	require.Equal(t, fakeInfo.CurrentTag, ctx.Git.CurrentTag)
@@ -158,7 +185,7 @@ func TestSnapshotNoCommits(t *testing.T) {
 	testlib.Mktmp(t)
 	testlib.GitInit(t)
 	testlib.GitRemoteAdd(t, "git@github.com:foo/bar.git")
-	var ctx = context.New(config.Project{})
+	ctx := context.New(config.Project{})
 	ctx.Snapshot = true
 	testlib.AssertSkipped(t, Pipe{}.Run(ctx))
 	require.Equal(t, fakeInfo, ctx.Git)
@@ -166,27 +193,27 @@ func TestSnapshotNoCommits(t *testing.T) {
 
 func TestSnapshotWithoutRepo(t *testing.T) {
 	testlib.Mktmp(t)
-	var ctx = context.New(config.Project{})
+	ctx := context.New(config.Project{})
 	ctx.Snapshot = true
 	testlib.AssertSkipped(t, Pipe{}.Run(ctx))
 	require.Equal(t, fakeInfo, ctx.Git)
 }
 
 func TestSnapshotDirty(t *testing.T) {
-	var folder = testlib.Mktmp(t)
+	folder := testlib.Mktmp(t)
 	testlib.GitInit(t)
 	testlib.GitRemoteAdd(t, "git@github.com:foo/bar.git")
 	testlib.GitAdd(t)
 	testlib.GitCommit(t, "whatever")
 	testlib.GitTag(t, "v0.0.1")
-	require.NoError(t, ioutil.WriteFile(filepath.Join(folder, "foo"), []byte("foobar"), 0644))
-	var ctx = context.New(config.Project{})
+	require.NoError(t, ioutil.WriteFile(filepath.Join(folder, "foo"), []byte("foobar"), 0o644))
+	ctx := context.New(config.Project{})
 	ctx.Snapshot = true
 	testlib.AssertSkipped(t, Pipe{}.Run(ctx))
 }
 
 func TestGitNotInPath(t *testing.T) {
-	var path = os.Getenv("PATH")
+	path := os.Getenv("PATH")
 	defer func() {
 		require.NoError(t, os.Setenv("PATH", path))
 	}()
@@ -219,7 +246,7 @@ func TestTagFromCI(t *testing.T) {
 			require.NoError(t, os.Setenv(name, value))
 		}
 
-		var ctx = &context.Context{
+		ctx := &context.Context{
 			Config: config.Project{},
 		}
 		require.NoError(t, Pipe{}.Run(ctx))
@@ -240,7 +267,7 @@ func TestCommitDate(t *testing.T) {
 	testlib.GitRemoteAdd(t, "git@github.com:foo/bar.git")
 	testlib.GitCommitWithDate(t, "commit1", commitDate)
 	testlib.GitTag(t, "v0.0.1")
-	var ctx = &context.Context{
+	ctx := &context.Context{
 		Config: config.Project{},
 	}
 	require.NoError(t, Pipe{}.Run(ctx))