mirror of
				https://github.com/go-gitea/gitea
				synced 2025-10-31 03:18:24 +00:00 
			
		
		
		
	show folder first on file list page
This commit is contained in:
		| @@ -8,7 +8,7 @@ import ( | |||||||
| 	"path" | 	"path" | ||||||
| 	"time" | 	"time" | ||||||
|  |  | ||||||
| 	git "github.com/speedata/gogit" | 	git "github.com/gogits/git" | ||||||
| ) | ) | ||||||
|  |  | ||||||
| type RepoFile struct { | type RepoFile struct { | ||||||
| @@ -46,20 +46,33 @@ func GetReposFiles(userName, reposName, branchName, rpath string) ([]*RepoFile, | |||||||
| 		return nil, err | 		return nil, err | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|  | 	var repodirs []*RepoFile | ||||||
| 	var repofiles []*RepoFile | 	var repofiles []*RepoFile | ||||||
| 	lastCommit.Tree.Walk(func(dirname string, entry *git.TreeEntry) int { | 	lastCommit.Tree.Walk(func(dirname string, entry *git.TreeEntry) int { | ||||||
| 		if dirname == rpath { | 		if dirname == rpath { | ||||||
| 			repofiles = append(repofiles, &RepoFile{ | 			switch entry.Filemode { | ||||||
| 				entry.Id, | 			case git.FileModeBlob, git.FileModeBlobExec: | ||||||
| 				entry.Filemode, | 				repofiles = append(repofiles, &RepoFile{ | ||||||
| 				entry.Name, | 					entry.Id, | ||||||
| 				path.Join(dirname, entry.Name), | 					entry.Filemode, | ||||||
| 				lastCommit.Message(), | 					entry.Name, | ||||||
| 				lastCommit.Committer.When, | 					path.Join(dirname, entry.Name), | ||||||
| 			}) | 					lastCommit.Message(), | ||||||
|  | 					lastCommit.Committer.When, | ||||||
|  | 				}) | ||||||
|  | 			case git.FileModeTree: | ||||||
|  | 				repodirs = append(repodirs, &RepoFile{ | ||||||
|  | 					entry.Id, | ||||||
|  | 					entry.Filemode, | ||||||
|  | 					entry.Name, | ||||||
|  | 					path.Join(dirname, entry.Name), | ||||||
|  | 					lastCommit.Message(), | ||||||
|  | 					lastCommit.Committer.When, | ||||||
|  | 				}) | ||||||
|  | 			} | ||||||
| 		} | 		} | ||||||
| 		return 0 | 		return 0 | ||||||
| 	}) | 	}) | ||||||
|  |  | ||||||
| 	return repofiles, nil | 	return append(repodirs, repofiles...), nil | ||||||
| } | } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user