-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Move repository sub menu data loading to the shared file and only display license on repository home page #32686
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
Conversation
Think about another case: "main" branch's license is MIT and "feature/other" branch/tag's license is Apache2, then the license stored in database is always MIT, if you show the license on "feature/other" branch/tag/release page, then it confuses users. Overall the optimization should be like this: only show License on the repo's home page. Then the code could also be simplified, no need to introduce any more tricks. |
I also find the LICENSE may be different between different branches. I will not change the previous design in this PR. 9ec4bdd Please review again, removed the permission check. |
I do not understand why "you will not change the previous License design in this PR" but you changed the template and might break the design of "Add tags list for repos whose release setting is disabled (#23465)" There are indeed simple approaches, why make it so complex? |
984c0ae
to
51f4ad8
Compare
routers/web/repo/shared/license.go
Outdated
return false | ||
} | ||
ctx.Data["DetectedRepoLicenses"] = repoLicenses.StringList() | ||
ctx.Data["LicenseFileName"] = repo_service.LicenseFileName |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know, this code was simply moved.
But… why are we storing request-specific data inside a global variable?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I cannot answer the question. I guess it may allow a different license file name in the future. Maybe @yp05327 can answer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LicenseFileName
in context data is used for the link.
At first, I reused the code of detecting README
file, so the license file name is not a specific value, but according to the review of #24872 (comment) and #24872 (comment), I changed it into a specific value.
But I think is not enough, e.g. LICENSES
or license
is not supported, and if it is necessary, we can improve it in the future.
This is the second step in my plan, it will be/maybe done in #32213 |
Can this PR fix 500 error in https://gitea.com/gitea/docs/tags? |
It is safe to do some changes of preparing license related data, as it is newly added, no other places start using them, but why you touch others like branch/tag/commit? Advice: |
Most necessary changes have been implemented in #32213 |
#24872 introduce display license in code, branch, commits and tags page. But it's unnecessary to load licenses data for branches or commit list pages.
This PR will keep license display only for repository home page. It also extracts licenses loading from
RepoAssignment
middleware to ashared/license.go
file.This will avoid loading commits/branches/tags/license number or information in issues/pulls/releases and other unrelated pages. It at least reduced 3 database queries for every page of these features.