mirror of
				https://gitee.com/gitea/gitea
				synced 2025-11-04 16:40:24 +08:00 
			
		
		
		
	* fix multiple readme file rendering and fix #1657 * remove unnecessary loop
This commit is contained in:
		@@ -59,6 +59,15 @@ func Type(filename string) string {
 | 
				
			|||||||
	return ""
 | 
						return ""
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ReadmeFileType reports whether name looks like a README file
 | 
				
			||||||
 | 
					// based on its name and find the parser via its ext name
 | 
				
			||||||
 | 
					func ReadmeFileType(name string) (string, bool) {
 | 
				
			||||||
 | 
						if IsReadmeFile(name) {
 | 
				
			||||||
 | 
							return Type(name), true
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						return "", false
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// IsReadmeFile reports whether name looks like a README file
 | 
					// IsReadmeFile reports whether name looks like a README file
 | 
				
			||||||
// based on its name.
 | 
					// based on its name.
 | 
				
			||||||
func IsReadmeFile(name string) bool {
 | 
					func IsReadmeFile(name string) bool {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -56,13 +56,19 @@ func renderDirectory(ctx *context.Context, treeLink string) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	var readmeFile *git.Blob
 | 
						var readmeFile *git.Blob
 | 
				
			||||||
	for _, entry := range entries {
 | 
						for _, entry := range entries {
 | 
				
			||||||
		if entry.IsDir() || !markup.IsReadmeFile(entry.Name()) {
 | 
							if entry.IsDir() {
 | 
				
			||||||
 | 
								continue
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							tp, ok := markup.ReadmeFileType(entry.Name())
 | 
				
			||||||
 | 
							if !ok {
 | 
				
			||||||
			continue
 | 
								continue
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		// TODO: collect all possible README files and show with priority.
 | 
					 | 
				
			||||||
		readmeFile = entry.Blob()
 | 
							readmeFile = entry.Blob()
 | 
				
			||||||
		break
 | 
							if tp != "" {
 | 
				
			||||||
 | 
								break
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if readmeFile != nil {
 | 
						if readmeFile != nil {
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user