-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
Deduplicate findReadmeFile() #22177
Deduplicate findReadmeFile() #22177
Conversation
c424ae3
to
981f19b
Compare
routers/web/repo/view.go
Outdated
URLPrefix: readmeTreelink, | ||
URLPrefix: path.Dir(treeLink), |
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 need some advice on this. readmeTreelink
was an annoying appendix that needed to be carried around like an albatross on our shoulders. I believe the only reason it existed was for the docs/README.md
cases, where you need to append e.g. "docs/" to treeLink to maintain the invariant that URLPrefix is the full URL path, '/src/', the branch name, and any subfolder, for the file being rendered.
But as far as I can tell, in this subroutine the contents of URLPrefix
are never served to the user, and nothing seems broken with it switched out like this.
c66a1f0
to
0b0f2bb
Compare
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.
Seems like a good refactor. Afraid I can not answer about readmeTreelink
but if nothing breaks, I guess we just go for it.
Thanks! Hm looks like CI broke between when I submitted and now. I'll fix that up. |
CI failure is likely unrelated, but you can restart by pushing an empty commit just to be sure. |
0b0f2bb
to
a78e665
Compare
Good call, so it was :) |
b907a0e
to
4f31708
Compare
067bf63
to
4138aa2
Compare
3fab56a
to
4138aa2
Compare
I will have a look again after the CI PASS. |
bc1d840
to
9fbfdd7
Compare
Hiya, this is passing and up to date again with |
Codecov Report
📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more @@ Coverage Diff @@
## main #22177 +/- ##
=========================================
+ Coverage 0 47.32% +47.32%
=========================================
Files 0 1111 +1111
Lines 0 149389 +149389
=========================================
+ Hits 0 70701 +70701
- Misses 0 70298 +70298
- Partials 0 8390 +8390
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
Please update branch |
This code was copy-pasted at some point. Reunify it. But to do this I found I had to expose git.TreeEntry.Tree() Signed-off-by: Nick Guenther <nick.guenther@polymtl.ca>
c2304e6
to
9201b8c
Compare
Great! On its way now. Thanks for your time :) |
Thank you for your work and patience!!! |
* upstream/main: Add some headings to repo views (go-gitea#22869) Fix style of actions rerun button (go-gitea#22835) Make issue and code search support camel case (go-gitea#22829) Revert "Fix notification and stopwatch empty states" (go-gitea#22876) Deduplicate findReadmeFile() (go-gitea#22177) Fix milestone title font problem (go-gitea#22863) Fix PR file tree folders no longer collapsing (go-gitea#22864) escape filename when assemble URL (go-gitea#22850) Fix notification and stopwatch empty states (go-gitea#22845) Fix .golangci.yml (go-gitea#22868) Fix migration issue. (go-gitea#22867) Add `/$count` endpoints for NuGet v2 (go-gitea#22855) Preview images for Issue cards in Project Board view (go-gitea#22112) Fix improper HTMLURL usages in Go code (go-gitea#22839) Use proxy for pull mirror (go-gitea#22771)
These functions don't examine contents, just filenames, so they don't fit in well in a markup module. This was originally part of #22177. Signed-off-by: Nick Guenther <nick.guenther@polymtl.ca>
Fixes a bug introduced in go-gitea#22177 which allows finding READMEs like docs/docs/docs/.gitea/.github/docs/README.md
!fixup go-gitea#22177 The only place this function is used so far is in findReadmeFileInEntries(), so the only visible effect of this oversight was in an obscure corner: if the README was in a subfolder and was a symlink that pointed up, as in .github/README.md -> ../docs/old/setup.md, the README would fail to render when because FollowLinks() hit the nil ptree.
…e() (#22902) !fixup #22177 The only place this function is used so far is in findReadmeFileInEntries(), so the only visible effect of this oversight was in an obscure README-related corner: if the README was in a subfolder and was a symlink that pointed up, as in .github/README.md -> ../docs/old/setup.md, the README would fail to render when FollowLinks() hit the nil ptree. This makes the ptree non-nil and thus repairs it.
Fixes a bug introduced in go-gitea#22177 which allows finding READMEs like docs/docs/docs/.gitea/.github/docs/README.md Fixes go-gitea#23694
This code was copy-pasted at some point. Revisit it to reunify it.
Doing that then encouraged simplifying the types of a couple of related functions.As a follow-up, move two helper functions,isReadmeFile()
andisReadmeFileExtension()
, intimately tied tofindReadmeFile()
, in as package-private.