From 340c1f15e32648788ad0b39a3d752ee610a00c1d Mon Sep 17 00:00:00 2001 From: shy Date: Tue, 12 Mar 2024 10:20:22 +0800 Subject: [PATCH] add some --- misc/git/service.go | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/misc/git/service.go b/misc/git/service.go index b4c3c40f..8d80fb8e 100644 --- a/misc/git/service.go +++ b/misc/git/service.go @@ -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)))