From 5483d97f73bf22ee4f8efddff246ed0433d75c6a Mon Sep 17 00:00:00 2001 From: TheDarkUndoing <38772798+TheDarkUndoing@users.noreply.github.com> Date: Sun, 5 Mar 2023 07:00:56 -0500 Subject: gitutil: strip SSH port from submodule URL when rendering for HTML link (#7383) Co-authored-by: Joe Chen --- CHANGELOG.md | 4 ++++ gen.go | 2 +- internal/db/mocks_test.go | 2 +- internal/gitutil/submodule.go | 2 +- internal/gitutil/submodule_test.go | 2 +- internal/route/lfs/mocks_test.go | 2 +- 6 files changed, 9 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 27fae923..9c543f8d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ All notable changes to Gogs are documented in this file. ## 0.14.0+dev (`main`) +### Fixed + +- Submodules using `ssh://` protocol and a port number are not rendered correctly. [#4941](https://github.com/gogs/gogs/issues/4941) + ## 0.13.0 ### Added diff --git a/gen.go b/gen.go index f353b854..ea1d8503 100644 --- a/gen.go +++ b/gen.go @@ -5,4 +5,4 @@ package main //go:generate go install golang.org/x/tools/cmd/goimports@v0.1.10 -//go:generate go run github.com/derision-test/go-mockgen/cmd/go-mockgen@v1.3.3 +//go:generate go run github.com/derision-test/go-mockgen/cmd/go-mockgen@v1.3.7 diff --git a/internal/db/mocks_test.go b/internal/db/mocks_test.go index 491e1da2..6ba67770 100644 --- a/internal/db/mocks_test.go +++ b/internal/db/mocks_test.go @@ -1,4 +1,4 @@ -// Code generated by go-mockgen 1.3.3; DO NOT EDIT. +// Code generated by go-mockgen 1.3.7; DO NOT EDIT. // // This file was generated by running `go-mockgen` at the root of this repository. // To add additional mocks to this or another package, add a new entry to the diff --git a/internal/gitutil/submodule.go b/internal/gitutil/submodule.go index 73e08040..519a24f9 100644 --- a/internal/gitutil/submodule.go +++ b/internal/gitutil/submodule.go @@ -50,7 +50,7 @@ func InferSubmoduleURL(baseURL string, mod *git.Submodule) string { case "http", "https": raw = parsed.String() case "ssh": - raw = fmt.Sprintf("http://%s%s", parsed.Host, parsed.Path) + raw = fmt.Sprintf("http://%s%s", parsed.Hostname(), parsed.Path) default: return raw } diff --git a/internal/gitutil/submodule_test.go b/internal/gitutil/submodule_test.go index 53f48766..0ef60a0d 100644 --- a/internal/gitutil/submodule_test.go +++ b/internal/gitutil/submodule_test.go @@ -31,7 +31,7 @@ func TestInferSubmoduleURL(t *testing.T) { URL: "ssh://user@github.com:22/gogs/docs-api.git", Commit: "6b08f76a5313fa3d26859515b30aa17a5faa2807", }, - expURL: "http://github.com:22/gogs/docs-api/commit/6b08f76a5313fa3d26859515b30aa17a5faa2807", + expURL: "http://github.com/gogs/docs-api/commit/6b08f76a5313fa3d26859515b30aa17a5faa2807", }, { name: "SSH URL in SCP syntax", diff --git a/internal/route/lfs/mocks_test.go b/internal/route/lfs/mocks_test.go index 7ab968d3..e4f013a6 100644 --- a/internal/route/lfs/mocks_test.go +++ b/internal/route/lfs/mocks_test.go @@ -1,4 +1,4 @@ -// Code generated by go-mockgen 1.3.3; DO NOT EDIT. +// Code generated by go-mockgen 1.3.7; DO NOT EDIT. // // This file was generated by running `go-mockgen` at the root of this repository. // To add additional mocks to this or another package, add a new entry to the -- cgit v1.2.3