Skip to content

Commit c4e14df

Browse files
authored
fix: use GoReleaser trimprefix in packaging templates (#15)
v0.5.1 failed at winget generation: trimPrefix is not a GoReleaser template function. Use trimprefix(string, prefix) for the repo name.
1 parent 815a177 commit c4e14df

2 files changed

Lines changed: 9 additions & 3 deletions

File tree

‎.goreleaser.yaml‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ homebrew_casks:
4545
skip_upload: auto
4646
repository:
4747
owner: "{{ .Env.GITHUB_REPOSITORY_OWNER }}"
48-
name: '{{ trimPrefix (print .Env.GITHUB_REPOSITORY_OWNER "/") .Env.GITHUB_REPOSITORY }}'
48+
name: '{{ trimprefix .Env.GITHUB_REPOSITORY (print .Env.GITHUB_REPOSITORY_OWNER "/") }}'
4949

5050
scoops:
5151
- name: squad-oc
@@ -55,7 +55,7 @@ scoops:
5555
skip_upload: auto
5656
repository:
5757
owner: "{{ .Env.GITHUB_REPOSITORY_OWNER }}"
58-
name: '{{ trimPrefix (print .Env.GITHUB_REPOSITORY_OWNER "/") .Env.GITHUB_REPOSITORY }}'
58+
name: '{{ trimprefix .Env.GITHUB_REPOSITORY (print .Env.GITHUB_REPOSITORY_OWNER "/") }}'
5959

6060
winget:
6161
- name: squad-oc
@@ -74,4 +74,4 @@ winget:
7474
- squad
7575
repository:
7676
owner: "{{ .Env.GITHUB_REPOSITORY_OWNER }}"
77-
name: '{{ trimPrefix (print .Env.GITHUB_REPOSITORY_OWNER "/") .Env.GITHUB_REPOSITORY }}'
77+
name: '{{ trimprefix .Env.GITHUB_REPOSITORY (print .Env.GITHUB_REPOSITORY_OWNER "/") }}'

‎internal/version/packaging_test.go‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,12 @@ func TestGoreleaserGeneratesPackaging(t *testing.T) {
103103
if strings.Contains(s, "directory: Formula") {
104104
t.Error("cask must not use Formula/")
105105
}
106+
if strings.Contains(s, "trimPrefix") {
107+
t.Error("GoReleaser templates use trimprefix, not Sprig trimPrefix")
108+
}
109+
if !strings.Contains(s, "trimprefix") {
110+
t.Error(".goreleaser.yaml should use trimprefix for the repo name")
111+
}
106112
}
107113

108114
func TestReleaseWorkflowOpensOnePackagingPR(t *testing.T) {

0 commit comments

Comments
 (0)