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

Redirects for renamed repos #807

Merged
merged 2 commits into from
Feb 5, 2017
Merged

Redirects for renamed repos #807

merged 2 commits into from
Feb 5, 2017

Conversation

ethantkoenig
Copy link
Member

Adds a new table (repo_redirect) to track what previous names should be redirected to.

@lunny lunny added the type/feature Completely new functionality. Can only be merged if feature freeze is not active. label Feb 1, 2017
@lunny lunny added this to the 1.1.0 milestone Feb 1, 2017
@lunny
Copy link
Member

lunny commented Feb 2, 2017

But if A -> B, but C -> A, then A will never be visit?

@tboerger tboerger added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Feb 2, 2017
@ethantkoenig
Copy link
Member Author

@lunny Good point, there are a lot of bugs with reusing previously-used repo names. I'll work on finding a solution.

@ethantkoenig ethantkoenig force-pushed the redirect branch 2 times, most recently from 0dc913c to 493093b Compare February 2, 2017 17:59
@ethantkoenig
Copy link
Member Author

@lunny I've added changes so that whenever a repo is created or renamed, any redirects from the new name are deleted. I believe this should fix the problem.

func NewRepoRedirect(ownerID, repoID int64, oldRepoName, newRepoName string) error {
oldRepoName = strings.ToLower(oldRepoName)
newRepoName = strings.ToLower(newRepoName)
if err := deleteRepoRedirect(x, ownerID, newRepoName); err != nil {
Copy link
Member

Choose a reason for hiding this comment

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

I would like you use a database transaction to do that.

Copy link
Member

Choose a reason for hiding this comment

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

^

Copy link
Member Author

Choose a reason for hiding this comment

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

Added 😀

@ethantkoenig ethantkoenig force-pushed the redirect branch 2 times, most recently from 8239949 to 55b8a83 Compare February 3, 2017 04:03
@@ -14,7 +14,7 @@
{{.CsrfTokenHtml}}
<input type="hidden" name="action" value="update">
<div class="required field {{if .Err_RepoName}}error{{end}}">
<label for="repo_name">{{.i18n.Tr "repo.repo_name"}}<span class="text red hide" id="repo-name-change-prompt"> {{.i18n.Tr "repo.settings.change_reponame_prompt"}}</span></label>
<label for="repo_name">{{.i18n.Tr "repo.repo_name"}}</label>
Copy link
Member

Choose a reason for hiding this comment

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

why remove the prompt?

Copy link
Member Author

Choose a reason for hiding this comment

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

The prompt warns that "This change will affect how links relate to the repository". Once we have redirects, what the prompt says will no longer be true.

Copy link
Member

Choose a reason for hiding this comment

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

OK

@lunny
Copy link
Member

lunny commented Feb 3, 2017

Otherwise LGTM

@tboerger tboerger 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 Feb 3, 2017
@bkcsoft
Copy link
Member

bkcsoft commented Feb 3, 2017

If I remember correcly, the way github does it is to redirect for X period of time, during that time no new repo can be created with that name. Sounds good?

@ethantkoenig
Copy link
Member Author

ethantkoenig commented Feb 3, 2017

@bkcsoft Github lets you create a new repo with the old name immediately; I just checked. Perhaps it used to be as you described, but not anymore?

I also don't know about whether Github redirects expire. I haven't found any sources that explicitly say one way or another, and I can't easily test for myself 😄

@lunny
Copy link
Member

lunny commented Feb 5, 2017

conflicted

@appleboy
Copy link
Member

appleboy commented Feb 5, 2017

LGTM

@tboerger tboerger 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 Feb 5, 2017
@lunny lunny merged commit 027591a into go-gitea:master Feb 5, 2017
@ethantkoenig ethantkoenig deleted the redirect branch February 6, 2017 02:38
@lunny
Copy link
Member

lunny commented Feb 7, 2017

resolved #806

@go-gitea go-gitea locked and limited conversation to collaborators Nov 23, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. type/feature Completely new functionality. Can only be merged if feature freeze is not active.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants