File tree Expand file tree Collapse file tree 1 file changed +15
-3
lines changed Expand file tree Collapse file tree 1 file changed +15
-3
lines changed Original file line number Diff line number Diff line change @@ -45,23 +45,35 @@ func getBasicFileIconName(entry *git.TreeEntry) string {
4545 return "octicon-file"
4646}
4747
48+ // getFileIconNames returns a list of possible icon names for a file or directory
49+ // Folder named `sub-folder` =>
50+ // - `folder_sub-folder“ (. will be replaced with _)
51+ // - `folder`
52+ //
53+ // File named `.gitignore` =>
54+ // - `file__gitignore` (. will be replaced with _)
55+ // - `file_`
56+ //
57+ // File named `README.md` =>
58+ // - `file_readme_md`
59+ // - `file_md`
4860func getFileIconNames (entry * git.TreeEntry ) []string {
49- fileName := strings .ToLower (path .Base (entry .Name ()))
61+ fileName := strings .ReplaceAll ( strings . ToLower (path .Base (entry .Name ())), "." , "_" )
5062
5163 if entry .IsDir () {
5264 return []string {"folder_" + fileName , "folder" }
5365 }
5466
5567 if entry .IsRegular () {
56- ext := strings .ToLower (strings .TrimPrefix (path .Ext (fileName ), "." ))
68+ ext := strings .ToLower (strings .TrimPrefix (path .Ext (entry . Name () ), "." ))
5769 return []string {"file_" + fileName , "file_" + ext , "file" }
5870 }
5971
6072 return nil
6173}
6274
6375func loadCustomIcon (iconPath string ) (string , error ) {
64- log .Info ("Loading custom icon from %s" , iconPath )
76+ log .Debug ("Loading custom icon from %s" , iconPath )
6577
6678 if icon , ok := fileIconCache .Get (iconPath ); ok {
6779 return icon , nil
You can’t perform that action at this time.
0 commit comments