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

Fix redirect url of legacy commits route #2825

Merged
merged 6 commits into from
Nov 2, 2017

Conversation

Morlinest
Copy link
Member

As title.

@ethantkoenig
Copy link
Member

@Morlinest Can you give an example of what this fixes?

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

@ethantkoenig #2805.

@Morlinest
Copy link
Member Author

@ethantkoenig ctx.Req.URL doesn't contain suburl.

@Morlinest Morlinest force-pushed the fix/redirect-legacy-url branch from 6eaabbc to 119c696 Compare November 1, 2017 19:47
@codecov-io
Copy link

codecov-io commented Nov 1, 2017

Codecov Report

Merging #2825 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #2825   +/-   ##
=======================================
  Coverage   26.84%   26.84%           
=======================================
  Files          89       89           
  Lines       17608    17608           
=======================================
  Hits         4727     4727           
  Misses      12195    12195           
  Partials      686      686

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 529f9d0...9fc29b5. Read the comment docs.

return path.Join(urlPath[:idx], ctx.Repo.BranchNameSubURL())
urlPath := strings.TrimSuffix(ctx.Req.URL.String(), ctx.Params("*"))
urlPath = strings.TrimPrefix(urlPath, "/")
return setting.AppURL + path.Join(urlPath, ctx.Repo.BranchNameSubURL())
Copy link
Member

Choose a reason for hiding this comment

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

nit: could we use URLJoin instead of manually assembling the URL (it may make sense to also move URLJoin to modules/util)

Copy link
Member Author

Choose a reason for hiding this comment

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

@ethantkoenig @lafriks Do you want me to do this change in this PR? It's a lot of lines changed, would it be in the scope of this PR?

Copy link
Member

Choose a reason for hiding this comment

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

I think moving into path.Join would be enough for this PR

Copy link
Member Author

Choose a reason for hiding this comment

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

@lafriks You can't move setting.AppURL to path.Join. Or you mean markup.URLJoin?

Copy link
Member

Choose a reason for hiding this comment

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

I mean changing from return setting.AppURL + path.Join(urlPath, ctx... to return path.Join(setting.AppURL, urlPath, ctx....

Copy link
Member Author

Choose a reason for hiding this comment

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

It's imposible because path.Join strips http://example.com to http:/example.com

Copy link
Member

Choose a reason for hiding this comment

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

You can use that suburl variable then so than?

Copy link
Member Author

Choose a reason for hiding this comment

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

@lafriks I can use setting.AppSubURL.

@lunny
Copy link
Member

lunny commented Nov 2, 2017

I think we have to add tests for subURL at first.

@Morlinest
Copy link
Member Author

@lafriks @ethantkoenig Changed and simplified.

@lunny I think it is not needed now for this PR.

@ethantkoenig
Copy link
Member

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 Nov 2, 2017
@lafriks
Copy link
Member

lafriks commented Nov 2, 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 Nov 2, 2017
@lafriks lafriks modified the milestones: 1.2.3, 1.3.0 Nov 2, 2017
@Morlinest
Copy link
Member Author

@ethantkoenig @lafriks Shouldn't I remove repoRefRedirect as it is used in one place only and now it contains just 1 line of code?

@lafriks
Copy link
Member

lafriks commented Nov 2, 2017

If it is used in one place only than yes, no need for this function

@Morlinest Morlinest force-pushed the fix/redirect-legacy-url branch from 1266825 to 7c6cda8 Compare November 2, 2017 21:11
@Morlinest
Copy link
Member Author

@lafriks PR updated.

@lafriks lafriks merged commit 1f04c00 into go-gitea:master Nov 2, 2017
@Morlinest Morlinest deleted the fix/redirect-legacy-url branch November 2, 2017 22:31
@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/bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants