diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index b2eeab617e4..64bc0c7cc1f 100644 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -3505,3 +3505,12 @@ variables.update.success = The variable has been edited. type-1.display_name = Individual Project type-2.display_name = Repository Project type-3.display_name = Organization Project + +[git.filemode] +changed_filemode = %[1]s → %[2]s +# Ordered by git filemode value, ascending. E.g. directory has "040000", normal file has "100644", … +directory = Directory +normal_file = Normal file +executable_file = Executable file +symbolic_link = Symbolic link +submodule = Submodule diff --git a/services/gitdiff/gitdiff.go b/services/gitdiff/gitdiff.go index 9e1db6fd435..4cb2b1303df 100644 --- a/services/gitdiff/gitdiff.go +++ b/services/gitdiff/gitdiff.go @@ -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 { diff --git a/templates/repo/diff/box.tmpl b/templates/repo/diff/box.tmpl index c4dd1f658d9..324166b03c1 100644 --- a/templates/repo/diff/box.tmpl +++ b/templates/repo/diff/box.tmpl @@ -130,9 +130,11 @@ {{$.locale.Tr "repo.diff.vendored"}} {{end}} {{if and $file.Mode $file.OldMode}} - {{$file.OldMode}} → {{$file.Mode}} + {{$old := $.locale.Tr ($file.ModeTranslationKey $file.OldMode)}} + {{$new := $.locale.Tr ($file.ModeTranslationKey $file.Mode)}} + {{$.locale.Tr "git.filemode.changed_filemode" $old $new}} {{else if $file.Mode}} - {{$file.Mode}} + {{$.locale.Tr ($file.ModeTranslationKey $file.Mode)}} {{end}}