mirror of https://github.com/go-gitea/gitea.git
Browse Source
fixes #30565 When using git with a gitea hosted repository, the HTTP-Transport did honor the user and repository redirects, which are created when renaming a user or repo and also when transferring ownership of a repo to a different organization. This is extremely helpful, as repo URLs remain stable and do not have to be migrated on each client's worktree and other places, e.g. CI at once. The SSH transport - which I favor - did not know of these redirections and I implemented a lookup during the `serv` command.pull/35103/merge
4 changed files with 76 additions and 5 deletions
@ -0,0 +1,42 @@
@@ -0,0 +1,42 @@
|
||||
// Copyright 2025 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package integration |
||||
|
||||
import ( |
||||
"fmt" |
||||
"net/url" |
||||
"testing" |
||||
|
||||
auth_model "code.gitea.io/gitea/models/auth" |
||||
) |
||||
|
||||
func TestGitSSHRedirect(t *testing.T) { |
||||
onGiteaRun(t, testGitSSHRedirect) |
||||
} |
||||
|
||||
func testGitSSHRedirect(t *testing.T, u *url.URL) { |
||||
apiTestContext := NewAPITestContext(t, "user2", "repo1", auth_model.AccessTokenScopeWriteRepository, auth_model.AccessTokenScopeWriteUser) |
||||
|
||||
withKeyFile(t, "my-testing-key", func(keyFile string) { |
||||
t.Run("CreateUserKey", doAPICreateUserKey(apiTestContext, "test-key", keyFile)) |
||||
|
||||
testCases := []struct { |
||||
testName string |
||||
userName string |
||||
repoName string |
||||
}{ |
||||
{"Test untouched", "user2", "repo1"}, |
||||
{"Test renamed user", "olduser2", "repo1"}, |
||||
{"Test renamed repo", "user2", "oldrepo1"}, |
||||
{"Test renamed user and repo", "olduser2", "oldrepo1"}, |
||||
} |
||||
|
||||
for _, tc := range testCases { |
||||
t.Run(tc.testName, func(t *testing.T) { |
||||
cloneURL := createSSHUrl(fmt.Sprintf("%s/%s.git", tc.userName, tc.repoName), u) |
||||
t.Run("Clone", doGitClone(t.TempDir(), cloneURL)) |
||||
}) |
||||
} |
||||
}) |
||||
} |
||||
Loading…
Reference in new issue