mirror of
https://github.com/go-gitea/gitea.git
synced 2026-01-17 18:37:14 +00:00
Improve diff file headers (#36215)
- reduce file name font size from 15px to 14px - fix labels and buttons being cut off when their size is constrained - change labels from monospace to sans-serif font - move diff stats to right and change them from sum of changes to +/- - change filemode to label and change text to match other labels --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
@@ -399,20 +399,20 @@ type DiffFile struct {
|
||||
isAmbiguous bool
|
||||
|
||||
// basic fields (parsed from diff result)
|
||||
Name string
|
||||
NameHash string
|
||||
OldName string
|
||||
Addition int
|
||||
Deletion int
|
||||
Type DiffFileType
|
||||
Mode string
|
||||
OldMode string
|
||||
IsCreated bool
|
||||
IsDeleted bool
|
||||
IsBin bool
|
||||
IsLFSFile bool
|
||||
IsRenamed bool
|
||||
IsSubmodule bool
|
||||
Name string
|
||||
NameHash string
|
||||
OldName string
|
||||
Addition int
|
||||
Deletion int
|
||||
Type DiffFileType
|
||||
EntryMode string
|
||||
OldEntryMode string
|
||||
IsCreated bool
|
||||
IsDeleted bool
|
||||
IsBin bool
|
||||
IsLFSFile bool
|
||||
IsRenamed bool
|
||||
IsSubmodule bool
|
||||
// basic fields but for render purpose only
|
||||
Sections []*DiffSection
|
||||
IsIncomplete bool
|
||||
@@ -501,21 +501,36 @@ 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 (diffFile *DiffFile) TranslateDiffEntryMode(locale translation.Locale) string {
|
||||
entryModeTr := func(mode string) string {
|
||||
entryMode := git.ParseEntryMode(mode)
|
||||
switch {
|
||||
case entryMode.IsDir():
|
||||
return locale.TrString("git.filemode.directory")
|
||||
case entryMode.IsRegular():
|
||||
return locale.TrString("git.filemode.normal_file")
|
||||
case entryMode.IsExecutable():
|
||||
return locale.TrString("git.filemode.executable_file")
|
||||
case entryMode.IsLink():
|
||||
return locale.TrString("git.filemode.symbolic_link")
|
||||
case entryMode.IsSubModule():
|
||||
return locale.TrString("git.filemode.submodule")
|
||||
default:
|
||||
return mode
|
||||
}
|
||||
}
|
||||
|
||||
if diffFile.EntryMode != "" && diffFile.OldEntryMode != "" {
|
||||
oldMode := entryModeTr(diffFile.OldEntryMode)
|
||||
newMode := entryModeTr(diffFile.EntryMode)
|
||||
return locale.TrString("git.filemode.changed_filemode", oldMode, newMode)
|
||||
}
|
||||
if diffFile.EntryMode != "" {
|
||||
if entryMode := git.ParseEntryMode(diffFile.EntryMode); !entryMode.IsRegular() {
|
||||
return entryModeTr(diffFile.EntryMode)
|
||||
}
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type limitByteWriter struct {
|
||||
@@ -695,10 +710,10 @@ parsingLoop:
|
||||
strings.HasPrefix(line, "new mode "):
|
||||
|
||||
if strings.HasPrefix(line, "old mode ") {
|
||||
curFile.OldMode = prepareValue(line, "old mode ")
|
||||
curFile.OldEntryMode = prepareValue(line, "old mode ")
|
||||
}
|
||||
if strings.HasPrefix(line, "new mode ") {
|
||||
curFile.Mode = prepareValue(line, "new mode ")
|
||||
curFile.EntryMode = prepareValue(line, "new mode ")
|
||||
}
|
||||
if strings.HasSuffix(line, " 160000\n") {
|
||||
curFile.IsSubmodule, curFile.SubmoduleDiffInfo = true, &SubmoduleDiffInfo{}
|
||||
@@ -733,7 +748,7 @@ parsingLoop:
|
||||
curFile.Type = DiffFileAdd
|
||||
curFile.IsCreated = true
|
||||
if strings.HasPrefix(line, "new file mode ") {
|
||||
curFile.Mode = prepareValue(line, "new file mode ")
|
||||
curFile.EntryMode = prepareValue(line, "new file mode ")
|
||||
}
|
||||
if strings.HasSuffix(line, " 160000\n") {
|
||||
curFile.IsSubmodule, curFile.SubmoduleDiffInfo = true, &SubmoduleDiffInfo{}
|
||||
|
||||
Reference in New Issue
Block a user