Bladeren bron

gitutil: strip SSH port from submodule URL when rendering for HTML link (#7383)

Co-authored-by: Joe Chen <[email protected]>
TheDarkUndoing 2 jaren geleden
bovenliggende
commit
5483d97f73
6 gewijzigde bestanden met toevoegingen van 9 en 5 verwijderingen
  1. 4 0
      CHANGELOG.md
  2. 1 1
      gen.go
  3. 1 1
      internal/db/mocks_test.go
  4. 1 1
      internal/gitutil/submodule.go
  5. 1 1
      internal/gitutil/submodule_test.go
  6. 1 1
      internal/route/lfs/mocks_test.go

+ 4 - 0
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

+ 1 - 1
gen.go

@@ -5,4 +5,4 @@
 package main
 
 //go:generate go install golang.org/x/tools/cmd/[email protected]
-//go:generate go run github.com/derision-test/go-mockgen/cmd/[email protected].3
+//go:generate go run github.com/derision-test/go-mockgen/cmd/[email protected].7

+ 1 - 1
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

+ 1 - 1
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
 	}

+ 1 - 1
internal/gitutil/submodule_test.go

@@ -31,7 +31,7 @@ func TestInferSubmoduleURL(t *testing.T) {
 				URL:    "ssh://[email protected]: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",

+ 1 - 1
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