* Calculate hash only once. * remove unused Sha1 template helper function, use ctx.Data["FileNameHash"] * fix unit tests
Showing the changes to services/gitdiff/gitdiff.go (1 of 8 files). Show all
Unified · Split
| @@ -25,6 +25,7 @@ import ( · 24 unmodified lines | |||
| 25 | pull_model "code.gitea.io/gitea/models/pull" | 25 | pull_model "code.gitea.io/gitea/models/pull" |
| 26 | user_model "code.gitea.io/gitea/models/user" | 26 | user_model "code.gitea.io/gitea/models/user" |
| 27 | "code.gitea.io/gitea/modules/analyze" | 27 | "code.gitea.io/gitea/modules/analyze" |
| 28 | "code.gitea.io/gitea/modules/base" | ||
| 28 | "code.gitea.io/gitea/modules/charset" | 29 | "code.gitea.io/gitea/modules/charset" |
| 29 | "code.gitea.io/gitea/modules/git" | 30 | "code.gitea.io/gitea/modules/git" |
| 30 | "code.gitea.io/gitea/modules/highlight" | 31 | "code.gitea.io/gitea/modules/highlight" |
| @@ -604,6 +605,7 @@ func (diffSection *DiffSection) GetComputedInlineDiffFor(diffLine *DiffLine) Dif · 573 unmodified lines | |||
| 604 | // DiffFile represents a file diff. | 605 | // DiffFile represents a file diff. |
| 605 | type DiffFile struct { | 606 | type DiffFile struct { |
| 606 | Name string | 607 | Name string |
| 608 | NameHash string | ||
| 607 | OldName string | 609 | OldName string |
| 608 | Index int | 610 | Index int |
| 609 | Addition, Deletion int | 611 | Addition, Deletion int |
| @@ -952,7 +954,6 @@ parsingLoop: · 342 unmodified lines | |||
| 952 | break curFileLoop | 954 | break curFileLoop |
| 953 | } | 955 | } |
| 954 | } | 956 | } |
| 955 | |||
| 956 | } | 957 | } |
| 957 | 958 | ||
| 958 | // TODO: There are numerous issues with this: | 959 | // TODO: There are numerous issues with this: |
| @@ -964,6 +965,8 @@ parsingLoop: · 5 unmodified lines | |||
| 964 | diffLineTypeBuffers[DiffLineAdd] = new(bytes.Buffer) | 965 | diffLineTypeBuffers[DiffLineAdd] = new(bytes.Buffer) |
| 965 | diffLineTypeBuffers[DiffLineDel] = new(bytes.Buffer) | 966 | diffLineTypeBuffers[DiffLineDel] = new(bytes.Buffer) |
| 966 | for _, f := range diff.Files { | 967 | for _, f := range diff.Files { |
| 968 | f.NameHash = base.EncodeSha1(f.Name) | ||
| 969 | |||
| 967 | for _, buffer := range diffLineTypeBuffers { | 970 | for _, buffer := range diffLineTypeBuffers { |
| 968 | buffer.Reset() | 971 | buffer.Reset() |
| 969 | } | 972 | } |