* 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 | 25 | pull_model "code.gitea.io/gitea/models/pull" |
| 26 | 26 | user_model "code.gitea.io/gitea/models/user" |
| 27 | 27 | "code.gitea.io/gitea/modules/analyze" |
| 28 | + "code.gitea.io/gitea/modules/base" | |
| 28 | 29 | "code.gitea.io/gitea/modules/charset" |
| 29 | 30 | "code.gitea.io/gitea/modules/git" |
| 30 | 31 | "code.gitea.io/gitea/modules/highlight" |
| @@ -604,6 +605,7 @@ func (diffSection *DiffSection) GetComputedInlineDiffFor(diffLine *DiffLine) Dif · 573 unmodified lines | ||
| 604 | 605 | // DiffFile represents a file diff. |
| 605 | 606 | type DiffFile struct { |
| 606 | 607 | Name string |
| 608 | + NameHash string | |
| 607 | 609 | OldName string |
| 608 | 610 | Index int |
| 609 | 611 | Addition, Deletion int |
| @@ -952,7 +954,6 @@ parsingLoop: · 342 unmodified lines | ||
| 952 | 954 | break curFileLoop |
| 953 | 955 | } |
| 954 | 956 | } |
| 955 | − | |
| 956 | 957 | } |
| 957 | 958 | |
| 958 | 959 | // TODO: There are numerous issues with this: |
| @@ -964,6 +965,8 @@ parsingLoop: · 5 unmodified lines | ||
| 964 | 965 | diffLineTypeBuffers[DiffLineAdd] = new(bytes.Buffer) |
| 965 | 966 | diffLineTypeBuffers[DiffLineDel] = new(bytes.Buffer) |
| 966 | 967 | for _, f := range diff.Files { |
| 968 | + f.NameHash = base.EncodeSha1(f.Name) | |
| 969 | + | |
| 967 | 970 | for _, buffer := range diffLineTypeBuffers { |
| 968 | 971 | buffer.Reset() |
| 969 | 972 | } |