feat: show breadcrumb path in path filtered commit history view (#12116)
Resolves forgejo/forgejo#8754 Add the breadcrumb path that already exists when browsing directories to the commit history of files/directories. Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/12116 Reviewed-by: Gusted <gusted@noreply.codeberg.org>
This commit is contained in:
@@ -45,10 +45,19 @@ const (
|
||||
func RefCommits(ctx *context.Context) {
|
||||
switch {
|
||||
case len(ctx.Repo.TreePath) == 0:
|
||||
ctx.Data["TreeNames"] = []string{}
|
||||
Commits(ctx)
|
||||
case ctx.Repo.TreePath == "search":
|
||||
ctx.Data["TreeNames"] = []string{}
|
||||
SearchCommits(ctx)
|
||||
default:
|
||||
treeNames := strings.Split(ctx.Repo.TreePath, "/")
|
||||
paths := make([]string, len(treeNames))
|
||||
for i := range treeNames {
|
||||
paths[i] = strings.Join(treeNames[:i+1], "/")
|
||||
}
|
||||
ctx.Data["TreeNames"] = treeNames
|
||||
ctx.Data["Paths"] = paths
|
||||
FileHistory(ctx)
|
||||
}
|
||||
}
|
||||
@@ -272,6 +281,9 @@ func FileHistory(ctx *context.Context) {
|
||||
}
|
||||
}
|
||||
|
||||
branchLink := ctx.Repo.RepoLink + "/src/" + ctx.Repo.BranchNameSubURL()
|
||||
ctx.Data["BranchLink"] = branchLink
|
||||
|
||||
ctx.Data["Commits"] = git_model.ParseCommitsWithStatus(ctx, commits, ctx.Repo.Repository)
|
||||
|
||||
ctx.Data["Username"] = ctx.Repo.Owner.Name
|
||||
|
||||
Reference in New Issue
Block a user