1
0
forked from x/icebergs
This commit is contained in:
IT 老营长 @云轩领航-创始人 2024-03-12 10:20:22 +08:00
parent 3ef850c581
commit 340c1f15e3

View File

@ -10,12 +10,6 @@ import (
"strconv"
"strings"
git "shylinux.com/x/go-git/v5"
"shylinux.com/x/go-git/v5/plumbing"
"shylinux.com/x/go-git/v5/plumbing/protocol/packp"
"shylinux.com/x/go-git/v5/plumbing/transport"
"shylinux.com/x/go-git/v5/plumbing/transport/server"
ice "shylinux.com/x/icebergs"
"shylinux.com/x/icebergs/base/aaa"
"shylinux.com/x/icebergs/base/cli"
@ -26,6 +20,12 @@ import (
"shylinux.com/x/icebergs/base/web/html"
"shylinux.com/x/icebergs/core/code"
kit "shylinux.com/x/toolkits"
git "shylinux.com/x/go-git/v5"
"shylinux.com/x/go-git/v5/plumbing"
"shylinux.com/x/go-git/v5/plumbing/protocol/packp"
"shylinux.com/x/go-git/v5/plumbing/transport"
"shylinux.com/x/go-git/v5/plumbing/transport/server"
)
func _service_path(m *ice.Message, p string, arg ...string) string {
@ -140,6 +140,13 @@ func init() {
return
}
}
if !nfs.Exists(m, repos) {
list := m.CmdMap(Prefix(REPOS), REPOS)
name := path.Base(repos)
if _repos, ok := list[name]; ok {
m.Cmd(Prefix(SERVICE), CLONE, name, _repos[ORIGIN])
}
}
if m.WarnNotFound(!nfs.Exists(m, repos), arg[0]) {
return
}
@ -151,6 +158,10 @@ func init() {
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) {
m.Cmd(nfs.DIR, ice.USR_LOCAL_REPOS, func(value ice.Maps) { _repos_insert(m, value[nfs.PATH]) })
}},
CLONE: {Name: "clone name*=demo origin", Hand: func(m *ice.Message, arg ...string) {
git.PlainClone(_service_path(m, m.Option(mdb.NAME)), true, &git.CloneOptions{URL: m.Option(ORIGIN), Auth: _repos_auth(m, m.Option(ORIGIN))})
_repos_insert(m, _service_path(m, m.Option(mdb.NAME)))
}},
mdb.CREATE: {Name: "create name*=demo", Hand: func(m *ice.Message, arg ...string) {
git.PlainInit(_service_path(m, m.Option(mdb.NAME)), true)
_repos_insert(m, _service_path(m, m.Option(mdb.NAME)))