aboutsummaryrefslogtreecommitdiffstats
path: root/routers
diff options
context:
space:
mode:
authorKN4CK3R <admin@oldschoolhack.me>2023-12-21 22:48:18 +0100
committerGitHub <noreply@github.com>2023-12-21 22:48:18 +0100
commit31426938928c89a9441dcf04b767db60c666e09a (patch)
treebf80e9c4f4c4ca020057fd01ac3aa923ee6d4a63 /routers
parent177cea7c70473e375c1695f1e20fb9d538ff78fb (diff)
downloadgitea-31426938928c89a9441dcf04b767db60c666e09a.tar.gz
gitea-31426938928c89a9441dcf04b767db60c666e09a.zip
Use information from previous blame parts (#28572)
Fixes #28545 `git blame` output can contain blocks without commit information if it was outputted before (the `0dafa97ea3f6d9662299579e5be1875cd28baaae 48 26 1` line): ``` fec25436488499df7231f63b857f66457c193d5c 24 25 1 author Bastien Montagne author-mail <bastien@blender.org> author-time 1660731031 author-tz +0200 committer Bastien Montagne committer-mail <bastien@blender.org> committer-time 1660731031 committer-tz +0200 summary LibOverride: Add Make/Reset/Clear entries to IDTemplate contextual menu. previous 839ece6477203382b7a7483062961540180ff1cd source/blender/editors/interface/interface_ops.c filename source/blender/editors/interface/interface_ops.c #include "BLT_translation.h" 0dafa97ea3f6d9662299579e5be1875cd28baaae 48 26 1 3d57bc4397fca53bc9702a27bbf50102827829b0 27 27 1 author Hans Goudey author-mail <hans@blender.org> author-time 1700131315 author-tz +0100 committer Hans Goudey committer-mail <hooglyboogly@noreply.localhost> committer-time 1700131315 committer-tz +0100 summary Cleanup: Move several blenkernel headers to C++ previous 451c054d9b7d3148a646caa5a72fb127a5b5c408 source/blender/editors/interface/interface_ops.cc filename source/blender/editors/interface/interface_ops.cc #include "BKE_context.hh" ``` This PR reuses data from the previous blame part to fill these gaps.
Diffstat (limited to 'routers')
-rw-r--r--routers/web/repo/blame.go22
1 files changed, 17 insertions, 5 deletions
diff --git a/routers/web/repo/blame.go b/routers/web/repo/blame.go
index b2374e32c2..d414779a14 100644
--- a/routers/web/repo/blame.go
+++ b/routers/web/repo/blame.go
@@ -125,7 +125,7 @@ func RefBlame(ctx *context.Context) {
}
type blameResult struct {
- Parts []git.BlamePart
+ Parts []*git.BlamePart
UsesIgnoreRevs bool
FaultyIgnoreRevsFile bool
}
@@ -175,7 +175,9 @@ func performBlame(ctx *context.Context, repoPath string, commit *git.Commit, fil
func fillBlameResult(br *git.BlameReader, r *blameResult) error {
r.UsesIgnoreRevs = br.UsesIgnoreRevs()
- r.Parts = make([]git.BlamePart, 0, 5)
+ previousHelper := make(map[string]*git.BlamePart)
+
+ r.Parts = make([]*git.BlamePart, 0, 5)
for {
blamePart, err := br.NextPart()
if err != nil {
@@ -184,13 +186,23 @@ func fillBlameResult(br *git.BlameReader, r *blameResult) error {
if blamePart == nil {
break
}
- r.Parts = append(r.Parts, *blamePart)
+
+ if prev, ok := previousHelper[blamePart.Sha]; ok {
+ if blamePart.PreviousSha == "" {
+ blamePart.PreviousSha = prev.PreviousSha
+ blamePart.PreviousPath = prev.PreviousPath
+ }
+ } else {
+ previousHelper[blamePart.Sha] = blamePart
+ }
+
+ r.Parts = append(r.Parts, blamePart)
}
return nil
}
-func processBlameParts(ctx *context.Context, blameParts []git.BlamePart) map[string]*user_model.UserCommit {
+func processBlameParts(ctx *context.Context, blameParts []*git.BlamePart) map[string]*user_model.UserCommit {
// store commit data by SHA to look up avatar info etc
commitNames := make(map[string]*user_model.UserCommit)
// and as blameParts can reference the same commits multiple
@@ -232,7 +244,7 @@ func processBlameParts(ctx *context.Context, blameParts []git.BlamePart) map[str
return commitNames
}
-func renderBlame(ctx *context.Context, blameParts []git.BlamePart, commitNames map[string]*user_model.UserCommit) {
+func renderBlame(ctx *context.Context, blameParts []*git.BlamePart, commitNames map[string]*user_model.UserCommit) {
repoLink := ctx.Repo.RepoLink
language := ""