1
0
Fork 0
forked from forgejo/forgejo

Display human-readable text instead of cryptic filemodes (#26352) (#26358)

Backport #26352

Now, you don't need to be a git expert anymore to know what these numbers mean.

## Before

![grafik](9a964bf6-10fd-40a6-aeb2-ac8f437f8c32)

## After

![grafik](84573cb9-55b6-4dde-9866-95f71b657554)

or when the mode actually changed:

![grafik](0f327538-ebdc-40e7-8c99-f9e21b67f638)

(cherry picked from commit 39cbca0f95)
This commit is contained in:
delvh 2023-08-06 23:15:01 +02:00 committed by Earl Warren
parent 678c611c3d
commit 64e2c8f6ff
No known key found for this signature in database
GPG key ID: 0579CB2928A78A00
3 changed files with 30 additions and 2 deletions

View file

@ -427,6 +427,23 @@ func (diffFile *DiffFile) ShouldBeHidden() bool {
return diffFile.IsGenerated || diffFile.IsViewed
}
func (diffFile *DiffFile) ModeTranslationKey(mode string) string {
switch mode {
case "040000":
return "git.filemode.directory"
case "100644":
return "git.filemode.normal_file"
case "100755":
return "git.filemode.executable_file"
case "120000":
return "git.filemode.symbolic_link"
case "160000":
return "git.filemode.submodule"
default:
return mode
}
}
func getCommitFileLineCount(commit *git.Commit, filePath string) int {
blob, err := commit.GetBlobByPath(filePath)
if err != nil {