Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gitea Publish URL contains an extra / #3487

Closed
3 tasks done
SamTherapy opened this issue Oct 21, 2022 · 6 comments · Fixed by #3488
Closed
3 tasks done

Gitea Publish URL contains an extra / #3487

SamTherapy opened this issue Oct 21, 2022 · 6 comments · Fixed by #3488
Assignees
Labels
bug Something isn't working

Comments

@SamTherapy
Copy link
Contributor

SamTherapy commented Oct 21, 2022

What happened?

When following the documentation, publishing a release to Gitea creates a URL that Gitea cannot parse properly.

This incorrect URL will be published when pushing to a homebrew repository, where trying to install will 404.

How can we reproduce this?

https://try.gitea.io/goreleaserbugtester9000/GoreleaserTest

gitea_urls:
  api: https://try.gitea.io/api/v1/

creates an (incorrect) publishing URL at https://try.gitea.io//goreleaserbugtester9000/GoreleaserTest/releases/tag/v0.0.4
Homebrew repo: https://try.gitea.io/goreleaserbugtester9000/homebrew/src/branch/main/GoreleaserTest.rb#L12

while

gitea_urls:
  api: https://try.gitea.io/api/v1

creates a (correct) publishing URL at https://try.gitea.io/goreleaserbugtester9000/GoreleaserTest/releases/tag/v0.0.5
Homebrew repo: https://try.gitea.io/goreleaserbugtester9000/homebrew/src/branch/main/TestCorrectURL.rb#L12

goreleaser version

goreleaser version 1.12.3
commit: e27e6a9e8c66ec5d2bbcafb1c047068bcf250269
built at: 2022-10-20T12:30:56Z
built by: goreleaser
goos: linux
goarch: amd64
module version: v1.12.3, checksum: h1:sTJXdkGQO9eAP6pwEUazaD6ERJewZ7yzQexWEGPUVg4=

https://goreleaser.com

GoReleaser Check

  • goreleaser check shows no errors

Search

  • I did search for other open and closed issues before opening this.

Code of Conduct

  • I agree to follow this project's Code of Conduct

Additional context

Related Gitea issue: go-gitea/gitea#20462

If this behaviour is intentional, I can make a PR to fix the docs.

@SamTherapy SamTherapy added bug Something isn't working triage Issue pending triage by one of the maintainers labels Oct 21, 2022
@caarlos0
Copy link
Member

so, we could basically strip any trailing / in gitea URL?

@SamTherapy
Copy link
Contributor Author

I think so? I have tried applying the below patch as a naïve fix and both the tests passed and the URL was correct when supplying the .yaml file with the trailing slash.

diff --git a/internal/pipe/defaults/defaults.go b/internal/pipe/defaults/defaults.go
index 4bdfeb1c..f947e69c 100644
--- a/internal/pipe/defaults/defaults.go
+++ b/internal/pipe/defaults/defaults.go
@@ -36,6 +36,7 @@ func (Pipe) Run(ctx *context.Context) error {
 		}
 
 		ctx.Config.GiteaURLs.Download = strings.ReplaceAll(apiURL, "/api/v1", "")
+		ctx.Config.GiteaURLs.Download = strings.TrimSuffix(apiURL, "/")
 	}
 	for _, defaulter := range defaults.Defaulters {
 		if err := errhandler.Handle(defaulter.Default)(ctx); err != nil {

@caarlos0
Copy link
Member

yeah, looks like a fix.. wanna pr it?

@caarlos0 caarlos0 removed the triage Issue pending triage by one of the maintainers label Oct 21, 2022
@SamTherapy
Copy link
Contributor Author

Sure. If I have documentation changes, should those be separate?

SamTherapy added a commit to SamTherapy/goreleaser that referenced this issue Oct 21, 2022
Fixes goreleaser#3487

Signed-off-by: Sam Therapy <sam@samtherapy.net>
@caarlos0
Copy link
Member

Sure. If I have documentation changes, should those be separate?

nope, same pr is fine :)

docs are all in the www folder

caarlos0 added a commit that referenced this issue Oct 22, 2022
This PR will truncate any trailing slash left by specifying only a Gitea
API URL.

Fixes #3487

I have not added any tests for this.

Signed-off-by: Sam Therapy <sam@samtherapy.net>
Co-authored-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
@github-actions
Copy link
Contributor

github-actions bot commented Dec 5, 2022

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 5, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants