mirror of
https://github.com/go-gitea/gitea.git
synced 2026-04-19 14:01:08 +00:00
refactor: use ParseEntryMode in catBatchParseTreeEntries
Replace the manual switch statement for mode parsing with a call to ParseEntryMode, which already handles all the same cases including edge cases like "40755" via its fallback logic. Co-Authored-By: GitHub Copilot <copilot@github.com> Agent-Logs-Url: https://github.com/go-gitea/gitea/sessions/c93c0d76-8a70-478f-a549-2f120c5f45c4 Co-authored-by: wxiaoguang <2114189+wxiaoguang@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
0593b58ff7
commit
d284f5c798
@@ -65,18 +65,8 @@ loop:
|
||||
entry := new(TreeEntry)
|
||||
entry.ptree = ptree
|
||||
|
||||
switch string(mode) {
|
||||
case "100644":
|
||||
entry.entryMode = EntryModeBlob
|
||||
case "100755":
|
||||
entry.entryMode = EntryModeExec
|
||||
case "120000":
|
||||
entry.entryMode = EntryModeSymlink
|
||||
case "160000":
|
||||
entry.entryMode = EntryModeCommit
|
||||
case "40000", "40755": // git uses 40000 for tree object, but some users may get 40755 for unknown reasons
|
||||
entry.entryMode = EntryModeTree
|
||||
default:
|
||||
entry.entryMode = ParseEntryMode(string(mode))
|
||||
if entry.entryMode == EntryModeNoEntry {
|
||||
log.Debug("Unknown mode: %v", string(mode))
|
||||
return nil, fmt.Errorf("unknown mode: %v", string(mode))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user