gogs / gogs

Gogs is a painless self-hosted Git service
https://gogs.io
MIT License
44.77k stars 4.85k forks source link

Gogs chooses the wrong README sometimes #877

Open jiphex opened 9 years ago

jiphex commented 9 years ago

If I have a repo with a file named (for example) README-stuff.md as well as README.md, Gogs will choose to display the former instead of the latter which would be expected. This is different from the behaviour of say, Github.

It looks like this is because the check for whether a file is a README just checks if filename[:6] is "README", and the view gives up when it finds the first file.

I've used this for extra documentation about specific aspects of the project, e.g README-Building.md. Github does the right thing here.

unknwon commented 9 years ago

Thanks your feedback!

You're right, Gogs should also check that the 7th character is . as my quick think of solution.

jiphex commented 9 years ago

Wouldn't that break repos which just have a file named "README"? (no .md)

unknwon commented 9 years ago

Good catch, just check length first, then see if the 7th is . or not.

unknwon commented 9 years ago

Hi @jiphex , @jcracknell , I've pushed fix on dev branch and feel free to test on https://try.gogs.io/

jiphex commented 9 years ago

Seems OK: https://try.gogs.io/testzz/issue877

unknwon commented 9 years ago

Great!

AdrianVerde commented 4 years ago

It still chooses the wrong README as in the case of this mirror https://try.gogs.io/AdrianVerde/PHP Where it prefers README.REDIST.BINS instead of README.md