some improvements

pull/32721/head
Lunny Xiao 3 weeks ago
parent 0b441325a9
commit 4890434b1e
No known key found for this signature in database
GPG Key ID: C3B7C91B632F738A

@ -84,6 +84,19 @@ func RefNameFromCommit(shortName string) RefName {
return RefName(shortName)
}
func RefNameFromTypeAndShortName(tp RefType, shortName string) RefName {
switch tp {
case RefTypeBranch:
return RefNameFromBranch(shortName)
case RefTypeTag:
return RefNameFromTag(shortName)
case RefTypeCommit:
return RefNameFromCommit(shortName)
default:
return ""
}
}
func (ref RefName) String() string {
return string(ref)
}

@ -56,16 +56,12 @@ func isExcludedEntry(entry *git.TreeEntry) bool {
func Tree(ctx *context.Context) {
treePath := ctx.PathParam("*")
var refFullName git.RefName
switch ctx.FormTrim("ref_type") {
case "branch":
refFullName = git.RefNameFromBranch(ctx.FormTrim("ref_name"))
case "tag":
refFullName = git.RefNameFromTag(ctx.FormTrim("ref_name"))
default:
refFullName = git.RefName(ctx.FormTrim("ref_name"))
}
recursive := ctx.FormBool("recursive")
refFullName := git.RefNameFromTypeAndShortName(git.RefType(ctx.FormTrim("ref_type")), ctx.FormTrim("ref_name"))
if refFullName == "" {
ctx.Error(http.StatusBadRequest, "RefNameFromTypeAndShortName", "ref_type or ref_name is invalid")
return
}
var results []*files_service.TreeViewNode
var err error

Loading…
Cancel
Save