0
0
mirror of https://github.com/go-gitea/gitea.git synced 2025-11-10 11:28:00 -05:00

Refactor ls-tree and git path related problems (#35858)

Fix #35852, the root problem is that the "name" field is heavily abused
(since #6816, and no way to get a clear fix)

There are still a lot of legacy problems in old code.

Co-authored-by: Giteabot <teabot@gitea.io>
This commit is contained in:
wxiaoguang
2025-11-06 01:48:38 +08:00
committed by GitHub
parent d0ca2f6bc3
commit 525265c1a8
24 changed files with 193 additions and 450 deletions

View File

@@ -7,27 +7,6 @@ package git
import "code.gitea.io/gitea/modules/log"
// TreeEntry the leaf in the git tree
type TreeEntry struct {
ID ObjectID
ptree *Tree
entryMode EntryMode
name string
size int64
sized bool
}
// Name returns the name of the entry (base name)
func (te *TreeEntry) Name() string {
return te.name
}
// Mode returns the mode of the entry
func (te *TreeEntry) Mode() EntryMode {
return te.entryMode
}
// Size returns the size of the entry
func (te *TreeEntry) Size() int64 {
if te.IsDir() {
@@ -57,31 +36,6 @@ func (te *TreeEntry) Size() int64 {
return te.size
}
// IsSubModule if the entry is a submodule
func (te *TreeEntry) IsSubModule() bool {
return te.entryMode.IsSubModule()
}
// IsDir if the entry is a sub dir
func (te *TreeEntry) IsDir() bool {
return te.entryMode.IsDir()
}
// IsLink if the entry is a symlink
func (te *TreeEntry) IsLink() bool {
return te.entryMode.IsLink()
}
// IsRegular if the entry is a regular file
func (te *TreeEntry) IsRegular() bool {
return te.entryMode.IsRegular()
}
// IsExecutable if the entry is an executable file (not necessarily binary)
func (te *TreeEntry) IsExecutable() bool {
return te.entryMode.IsExecutable()
}
// Blob returns the blob object the entry
func (te *TreeEntry) Blob() *Blob {
return &Blob{