Repository: goreleaser/goreleaser
Pull request #2880 (2022-02-04 17:32:19)

fix: aur error messages
error messages and some variables still had the `pkgbuild` name instead of `aur`.

codecov[bot]: # [Codecov](https://codecov.io/gh/goreleaser/goreleaser/pull/2880?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=goreleaser) Report
> Merging [#2880](https://codecov.io/gh/goreleaser/goreleaser/pull/2880?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=goreleaser) (e61c04a) into [main](https://codecov.io/gh/goreleaser/goreleaser/commit/9cc1bb1595fc6ab726595ebbbe7e9611de3949c6?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=goreleaser) (9cc1bb1) will **not change** coverage.
> The diff coverage is `100.00%`.

[![Impacted file tree graph](https://codecov.io/gh/goreleaser/goreleaser/pull/2880/graphs/tree.svg?width=650&height=150&src=pr&token=3bJvv6b7hN&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=goreleaser)](https://codecov.io/gh/goreleaser/goreleaser/pull/2880?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=goreleaser)

```diff
@@           Coverage Diff           @@
##             main    #2880   +/-   ##
=======================================
  Coverage   84.47%   84.47%           
=======================================
  Files         111      111           
  Lines        8849     8849           
=======================================
  Hits         7475     7475           
  Misses       1105     1105           
  Partials      269      269           
```


| [Impacted Files](https://codecov.io/gh/goreleaser/goreleaser/pull/2880?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=goreleaser) | Coverage Δ | |
|---|---|---|
| [internal/pipe/aur/aur.go](https://codecov.io/gh/goreleaser/goreleaser/pull/2880/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=goreleaser#diff-aW50ZXJuYWwvcGlwZS9hdXIvYXVyLmdv) | `80.65% <100.00%> (ø)` | |

------

[Continue to review full report at Codecov](https://codecov.io/gh/goreleaser/goreleaser/pull/2880?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=goreleaser).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=goreleaser)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/goreleaser/goreleaser/pull/2880?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=goreleaser). Last update [9cc1bb1...e61c04a](https://codecov.io/gh/goreleaser/goreleaser/pull/2880?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=goreleaser). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=goreleaser).


Patch:
diff --git a/internal/pipe/aur/aur.go b/internal/pipe/aur/aur.go
index e98049ae..0183bc64 100644
--- a/internal/pipe/aur/aur.go
+++ b/internal/pipe/aur/aur.go
@@ -24,7 +24,7 @@ import (
 )
 
 const (
-	pkgBuildExtra     = "AURConfig"
+	aurExtra          = "AURConfig"
 	defaultSSHCommand = "ssh -i {{ .KeyPath }} -o StrictHostKeyChecking=accept-new -F /dev/null"
 	defaultCommitMsg  = "Update to {{ .Tag }}"
 )
@@ -78,8 +78,8 @@ func (Pipe) Run(ctx *context.Context) error {
 }
 
 func runAll(ctx *context.Context, cli client.Client) error {
-	for _, pkgbuild := range ctx.Config.AURs {
-		err := doRun(ctx, pkgbuild, cli)
+	for _, aur := range ctx.Config.AURs {
+		err := doRun(ctx, aur, cli)
 		if err != nil {
 			return err
 		}
@@ -87,12 +87,12 @@ func runAll(ctx *context.Context, cli client.Client) error {
 	return nil
 }
 
-func doRun(ctx *context.Context, pkgbuild config.AUR, cl client.Client) error {
-	name, err := tmpl.New(ctx).Apply(pkgbuild.Name)
+func doRun(ctx *context.Context, aur config.AUR, cl client.Client) error {
+	name, err := tmpl.New(ctx).Apply(aur.Name)
 	if err != nil {
 		return err
 	}
-	pkgbuild.Name = name
+	aur.Name = name
 
 	filters := []artifact.Filter{
 		artifact.ByGoos("linux"),
@@ -113,8 +113,8 @@ func doRun(ctx *context.Context, pkgbuild config.AUR, cl client.Client) error {
 			artifact.ByType(artifact.UploadableBinary),
 		),
 	}
-	if len(pkgbuild.IDs) > 0 {
-		filters = append(filters, artifact.ByIDs(pkgbuild.IDs...))
+	if len(aur.IDs) > 0 {
+		filters = append(filters, artifact.ByIDs(aur.IDs...))
 	}
 
 	archives := ctx.Artifacts.Filter(artifact.And(filters...)).List()
@@ -122,7 +122,7 @@ func doRun(ctx *context.Context, pkgbuild config.AUR, cl client.Client) error {
 		return ErrNoArchivesFound
 	}
 
-	pkg, err := tmpl.New(ctx).Apply(pkgbuild.Package)
+	pkg, err := tmpl.New(ctx).Apply(aur.Package)
 	if err != nil {
 		return err
 	}
@@ -141,7 +141,7 @@ func doRun(ctx *context.Context, pkgbuild config.AUR, cl client.Client) error {
 		}
 		log.Warnf("guessing package to be %q", pkg)
 	}
-	pkgbuild.Package = pkg
+	aur.Package = pkg
 
 	for _, info := range []struct {
 		name, tpl, ext string
@@ -149,7 +149,7 @@ func doRun(ctx *context.Context, pkgbuild config.AUR, cl client.Client) error {
 	}{
 		{
 			name: "PKGBUILD",
-			tpl:  pkgBuildTemplate,
+			tpl:  aurTemplateData,
 			ext:  ".pkgbuild",
 			kind: artifact.PkgBuild,
 		},
@@ -160,12 +160,12 @@ func doRun(ctx *context.Context, pkgbuild config.AUR, cl client.Client) error {
 			kind: artifact.SrcInfo,
 		},
 	} {
-		pkgContent, err := buildPkgFile(ctx, pkgbuild, cl, archives, info.tpl)
+		pkgContent, err := buildPkgFile(ctx, aur, cl, archives, info.tpl)
 		if err != nil {
 			return err
 		}
 
-		path := filepath.Join(ctx.Config.Dist, "aur", pkgbuild.Name+info.ext)
+		path := filepath.Join(ctx.Config.Dist, "aur", aur.Name+info.ext)
 		if err := os.MkdirAll(filepath.Dir(path), 0o755); err != nil {
 			return fmt.Errorf("failed to write %s: %w", info.kind, err)
 		}
@@ -179,8 +179,8 @@ func doRun(ctx *context.Context, pkgbuild config.AUR, cl client.Client) error {
 			Path: path,
 			Type: info.kind,
 			Extra: map[string]interface{}{
-				pkgBuildExtra:    pkgbuild,
-				artifact.ExtraID: pkgbuild.Name,
+				aurExtra:         aur,
+				artifact.ExtraID: aur.Name,
 			},
 		})
 	}
@@ -346,10 +346,10 @@ func (Pipe) Publish(ctx *context.Context) error {
 }
 
 func doPublish(ctx *context.Context, pkgs []*artifact.Artifact) error {
-	cfg := pkgs[0].Extra[pkgBuildExtra].(config.AUR)
+	cfg := pkgs[0].Extra[aurExtra].(config.AUR)
 
 	if strings.TrimSpace(cfg.SkipUpload) == "true" {
-		return pipe.Skip("pkgbuild.skip_upload is set")
+		return pipe.Skip("aur.skip_upload is set")
 	}
 
 	if strings.TrimSpace(cfg.SkipUpload) == "auto" && ctx.Semver.Prerelease != "" {
@@ -372,7 +372,7 @@ func doPublish(ctx *context.Context, pkgs []*artifact.Artifact) error {
 	}
 
 	if url == "" {
-		return pipe.Skip("pkgbuild.git_url is empty")
+		return pipe.Skip("aur.git_url is empty")
 	}
 
 	sshcmd, err := tmpl.New(ctx).WithExtraFields(tmpl.Fields{
@@ -442,7 +442,7 @@ func doPublish(ctx *context.Context, pkgs []*artifact.Artifact) error {
 
 func keyPath(key string) (string, error) {
 	if key == "" {
-		return "", pipe.Skip("pkgbuild.private_key is empty")
+		return "", pipe.Skip("aur.private_key is empty")
 	}
 	if _, err := ssh.ParsePrivateKey([]byte(key)); err == nil {
 		f, err := os.CreateTemp("", "id_*")
diff --git a/internal/pipe/aur/tmpl.go b/internal/pipe/aur/tmpl.go
index 1dc4491b..afb97112 100644
--- a/internal/pipe/aur/tmpl.go
+++ b/internal/pipe/aur/tmpl.go
@@ -24,7 +24,7 @@ type releasePackage struct {
 	Arch        string
 }
 
-const pkgBuildTemplate = `# This file was generated by GoReleaser. DO NOT EDIT.
+const aurTemplateData = `# This file was generated by GoReleaser. DO NOT EDIT.
 
 {{- range .Maintainers }}
 # Maintainer: {{ . }}


Test patch:
diff --git a/internal/pipe/aur/aur_test.go b/internal/pipe/aur/aur_test.go
index 605b918b..511b33a6 100644
--- a/internal/pipe/aur/aur_test.go
+++ b/internal/pipe/aur/aur_test.go
@@ -88,18 +88,18 @@ func createTemplateData() templateData {
 	}
 }
 
-func TestFullPkgBuild(t *testing.T) {
+func TestFullAur(t *testing.T) {
 	data := createTemplateData()
 	pkg, err := applyTemplate(context.New(config.Project{
 		ProjectName: "foo",
-	}), pkgBuildTemplate, data)
+	}), aurTemplateData, data)
 	require.NoError(t, err)
 
 	golden.RequireEqual(t, []byte(pkg))
 }
 
-func TestPkgBuildSimple(t *testing.T) {
-	pkg, err := applyTemplate(context.New(config.Project{}), pkgBuildTemplate, createTemplateData())
+func TestAurSimple(t *testing.T) {
+	pkg, err := applyTemplate(context.New(config.Project{}), aurTemplateData, createTemplateData())
 	require.NoError(t, err)
 	require.Contains(t, pkg, `# Maintainer: Ciclano <ciclano@example.com>`)
 	require.Contains(t, pkg, `# Maintainer: Cicrano <cicrano@example.com>`)
@@ -193,7 +193,7 @@ func TestFullPipe(t *testing.T) {
 			prepare: func(ctx *context.Context) {
 				ctx.Config.AURs[0].PrivateKey = ""
 			},
-			expectedPublishError: `pkgbuild.private_key is empty`,
+			expectedPublishError: `aur.private_key is empty`,
 		},
 		"key-not-found": {
 			prepare: func(ctx *context.Context) {
@@ -211,7 +211,7 @@ func TestFullPipe(t *testing.T) {
 			prepare: func(ctx *context.Context) {
 				ctx.Config.AURs[0].GitURL = ""
 			},
-			expectedPublishError: `pkgbuild.git_url is empty`,
+			expectedPublishError: `aur.git_url is empty`,
 		},
 		"invalid-ssh-cmd-template": {
 			prepare: func(ctx *context.Context) {
@@ -338,7 +338,7 @@ func TestRunPipe(t *testing.T) {
 			AURs: []config.AUR{
 				{
 					License:     "MIT",
-					Description: "A run pipe test pkgbuild and FOO={{ .Env.FOO }}",
+					Description: "A run pipe test aur and FOO={{ .Env.FOO }}",
 					Homepage:    "https://github.com/goreleaser",
 					IDs:         []string{"foo"},
 					GitURL:      url,
@@ -731,7 +731,7 @@ func TestKeyPath(t *testing.T) {
 	})
 	t.Run("empty", func(t *testing.T) {
 		result, err := keyPath("")
-		require.EqualError(t, err, `pkgbuild.private_key is empty`)
+		require.EqualError(t, err, `aur.private_key is empty`)
 		require.Equal(t, "", result)
 	})
 }
diff --git a/internal/pipe/aur/testdata/TestFullPkgBuild.golden b/internal/pipe/aur/testdata/TestFullAur.golden
similarity index 100%
rename from internal/pipe/aur/testdata/TestFullPkgBuild.golden
rename to internal/pipe/aur/testdata/TestFullAur.golden
diff --git a/internal/pipe/aur/testdata/TestRunPipe.pkgbuild.golden b/internal/pipe/aur/testdata/TestRunPipe.pkgbuild.golden
index 34d3089c..ecf34aaa 100644
--- a/internal/pipe/aur/testdata/TestRunPipe.pkgbuild.golden
+++ b/internal/pipe/aur/testdata/TestRunPipe.pkgbuild.golden
@@ -3,7 +3,7 @@
 pkgname='foo-bin'
 pkgver=1.0.1
 pkgrel=1
-pkgdesc='A run pipe test pkgbuild and FOO=foo_is_bar'
+pkgdesc='A run pipe test aur and FOO=foo_is_bar'
 url='https://github.com/goreleaser'
 arch=('aarch64' 'armv6h' 'armv7h' 'i686' 'x86_64')
 license=('MIT')
diff --git a/internal/pipe/aur/testdata/TestRunPipe.srcinfo.golden b/internal/pipe/aur/testdata/TestRunPipe.srcinfo.golden
index 8cc6caa0..26e843a9 100644
--- a/internal/pipe/aur/testdata/TestRunPipe.srcinfo.golden
+++ b/internal/pipe/aur/testdata/TestRunPipe.srcinfo.golden
@@ -1,5 +1,5 @@
 pkgbase = foo-bin
-	pkgdesc = A run pipe test pkgbuild and FOO=foo_is_bar
+	pkgdesc = A run pipe test aur and FOO=foo_is_bar
 	pkgver = 1.0.1
 	pkgrel = 1
 	url = https://github.com/goreleaser