Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

koalajoe23
Copy link
Contributor

@koalajoe23 koalajoe23 commented Sep 5, 2025

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.

Considerations

  • I am not a golang dev, feel free to suggest a more idiomatic implementation
  • This introduces DB lookups during the serv command. I am not sure how gitea handles this and if this may lead to performance or concurrency problems. My manual tests do not indicate any, but I'd be glad if an experienced contributor could verify this.
  • I haven't written any test cases yet. I'm a bit tired now but I try to commit them at a later time.
  • I did manual tests to verify correct handling of user rename and repo transfer though, also in combination.

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Sep 5, 2025
@github-actions github-actions bot added modifies/go Pull requests that update Go code modifies/cli PR changes something on the CLI, i.e. gitea doctor or gitea admin labels Sep 5, 2025
lunny
lunny previously requested changes Sep 5, 2025
Copy link
Member

@lunny lunny left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All operations should be performed under private routers, rather than directly in the serv command.

@GiteaBot GiteaBot added lgtm/blocked A maintainer has reservations with the PR and thus it cannot be merged and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Sep 5, 2025
@koalajoe23
Copy link
Contributor Author

All operations should be performed under private routers, rather than directly in the serv command.

I see, much cleaner to implement it there.

Moved the redirection handling there and also cleaned it up a bit

@lunny lunny dismissed their stale review September 5, 2025 23:16

code changed.

@GiteaBot GiteaBot added lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. and removed lgtm/blocked A maintainer has reservations with the PR and thus it cannot be merged labels Sep 5, 2025
@koalajoe23
Copy link
Contributor Author

Apart from missing tests for the SSH redirects, Git LFS over SSH tests now fail. Not sure why though...

@koalajoe23
Copy link
Contributor Author

I implemented integration tests cloning renamed repos, CI tests are green

@koalajoe23 koalajoe23 requested a review from lunny September 6, 2025 17:09
@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Sep 7, 2025
@lunny lunny added this to the 1.25.0 milestone Sep 7, 2025
@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Sep 9, 2025
@lunny lunny added the reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. label Sep 9, 2025
@lunny lunny enabled auto-merge (squash) September 9, 2025 19:18
@lunny lunny merged commit 2802f96 into go-gitea:main Sep 9, 2025
26 checks passed
@GiteaBot GiteaBot removed the reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. label Sep 9, 2025
zjjhot added a commit to zjjhot/gitea that referenced this pull request Sep 10, 2025
* giteaofficial/main:
  Fix a compare page 404 bug when the pull request disabled (go-gitea#35441)
  Use db.WithTx/WithTx2 instead of TxContext when possible (go-gitea#35428)
  [skip ci] Updated translations via Crowdin
  Update JS and PY dependencies (go-gitea#35444)
  check user and repo for redirects when using git via SSH transport (go-gitea#35416)
  Fix push commits comments when changing the pull request target branch (go-gitea#35386)
  Fix bug when issue disabled, pull request number in the commit message cannot be redirected (go-gitea#35420)
  [skip ci] Updated translations via Crowdin
  Update gofumpt, add go.mod ignore directive (go-gitea#35434)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. modifies/cli PR changes something on the CLI, i.e. gitea doctor or gitea admin modifies/go Pull requests that update Go code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Transfer Repo Ownership SSH Clone Redirect
4 participants