mirror of
https://shylinux.com/x/icebergs
synced 2025-04-28 18:22:02 +08:00
opt git
This commit is contained in:
parent
b346bd01d0
commit
cf9ecde493
@ -14,10 +14,24 @@ const CONFIG = "config"
|
|||||||
func init() {
|
func init() {
|
||||||
Index.Merge(&ice.Context{
|
Index.Merge(&ice.Context{
|
||||||
Configs: map[string]*ice.Config{
|
Configs: map[string]*ice.Config{
|
||||||
CONFIG: {Name: CONFIG, Help: "配置键", Value: kit.Data(kit.MDB_SHORT, kit.MDB_NAME)},
|
CONFIG: {Name: CONFIG, Help: "配置键", Value: kit.Data(kit.MDB_SHORT, kit.MDB_NAME, "init", kit.Dict(
|
||||||
|
"alias", kit.Dict("s", "status", "b", "branch"),
|
||||||
|
"credential", kit.Dict("helper", "store"),
|
||||||
|
"core", kit.Dict("quotepath", "false"),
|
||||||
|
"push", kit.Dict("default", "simple"),
|
||||||
|
"color", kit.Dict("ui", "always"),
|
||||||
|
))},
|
||||||
},
|
},
|
||||||
Commands: map[string]*ice.Command{
|
Commands: map[string]*ice.Command{
|
||||||
CONFIG: {Name: "server name auto create", Help: "配置键", Action: map[string]*ice.Action{
|
CONFIG: {Name: "server name auto create", Help: "配置键", Action: map[string]*ice.Action{
|
||||||
|
"init": {Name: "create name value", Help: "添加", Hand: func(m *ice.Message, arg ...string) {
|
||||||
|
kit.Fetch(m.Confv(GIT, kit.Keym("config")), func(conf string, value interface{}) {
|
||||||
|
kit.Fetch(value, func(key string, value string) {
|
||||||
|
m.Cmd(cli.SYSTEM, "bin/git", "config", "--global", conf+"."+key, value)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}},
|
||||||
|
|
||||||
mdb.CREATE: {Name: "create name value", Help: "添加", Hand: func(m *ice.Message, arg ...string) {
|
mdb.CREATE: {Name: "create name value", Help: "添加", Hand: func(m *ice.Message, arg ...string) {
|
||||||
m.Cmd(cli.SYSTEM, GIT, CONFIG, "--global", m.Option(kit.MDB_NAME), m.Option(kit.MDB_VALUE))
|
m.Cmd(cli.SYSTEM, GIT, CONFIG, "--global", m.Option(kit.MDB_NAME), m.Option(kit.MDB_VALUE))
|
||||||
m.Cmd(mdb.DELETE, m.Prefix(CONFIG), "", kit.MDB_HASH, kit.MDB_NAME, m.Option(kit.MDB_NAME))
|
m.Cmd(mdb.DELETE, m.Prefix(CONFIG), "", kit.MDB_HASH, kit.MDB_NAME, m.Option(kit.MDB_NAME))
|
||||||
|
@ -5,7 +5,6 @@ import (
|
|||||||
|
|
||||||
ice "github.com/shylinux/icebergs"
|
ice "github.com/shylinux/icebergs"
|
||||||
"github.com/shylinux/icebergs/base/cli"
|
"github.com/shylinux/icebergs/base/cli"
|
||||||
"github.com/shylinux/icebergs/base/nfs"
|
|
||||||
"github.com/shylinux/icebergs/base/web"
|
"github.com/shylinux/icebergs/base/web"
|
||||||
"github.com/shylinux/icebergs/core/code"
|
"github.com/shylinux/icebergs/core/code"
|
||||||
kit "github.com/shylinux/toolkits"
|
kit "github.com/shylinux/toolkits"
|
||||||
@ -16,49 +15,25 @@ const GIT = "git"
|
|||||||
var Index = &ice.Context{Name: GIT, Help: "代码库",
|
var Index = &ice.Context{Name: GIT, Help: "代码库",
|
||||||
Configs: map[string]*ice.Config{
|
Configs: map[string]*ice.Config{
|
||||||
GIT: {Name: GIT, Help: "代码库", Value: kit.Data(
|
GIT: {Name: GIT, Help: "代码库", Value: kit.Data(
|
||||||
kit.SSH_SOURCE, "https://mirrors.edge.kernel.org/pub/software/scm/git/git-1.8.3.1.tar.gz", CONFIG, kit.Dict(
|
cli.SOURCE, "https://mirrors.edge.kernel.org/pub/software/scm/git/git-1.8.3.1.tar.gz",
|
||||||
"alias", kit.Dict("s", "status", "b", "branch"),
|
|
||||||
"credential", kit.Dict("helper", "store"),
|
|
||||||
"core", kit.Dict("quotepath", "false"),
|
|
||||||
"push", kit.Dict("default", "simple"),
|
|
||||||
"color", kit.Dict("ui", "always"),
|
|
||||||
),
|
|
||||||
)},
|
)},
|
||||||
},
|
},
|
||||||
Commands: map[string]*ice.Command{
|
Commands: map[string]*ice.Command{
|
||||||
ice.CTX_INIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
ice.CTX_INIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { m.Load() }},
|
||||||
m.Load()
|
ice.CTX_EXIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { m.Save() }},
|
||||||
|
|
||||||
_repos_insert(m, path.Base(kit.Pwd()), kit.Pwd())
|
|
||||||
m.Cmd(nfs.DIR, kit.SSH_USR, "name,path").Table(func(index int, value map[string]string, head []string) {
|
|
||||||
_repos_insert(m, value[kit.MDB_NAME], value[kit.MDB_PATH])
|
|
||||||
})
|
|
||||||
}},
|
|
||||||
ice.CTX_EXIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
|
||||||
m.Save(CONFIG)
|
|
||||||
}},
|
|
||||||
|
|
||||||
GIT: {Name: "git port path auto start build download", Help: "源代码", Action: map[string]*ice.Action{
|
GIT: {Name: "git port path auto start build download", Help: "源代码", Action: map[string]*ice.Action{
|
||||||
web.DOWNLOAD: {Name: "download", Help: "下载", Hand: func(m *ice.Message, arg ...string) {
|
web.DOWNLOAD: {Name: "download", Help: "下载", Hand: func(m *ice.Message, arg ...string) {
|
||||||
m.Cmdy(code.INSTALL, web.DOWNLOAD, m.Conf(GIT, kit.META_SOURCE))
|
m.Cmdy(code.INSTALL, web.DOWNLOAD, m.Conf(GIT, kit.Keym(cli.SOURCE)))
|
||||||
}},
|
}},
|
||||||
cli.BUILD: {Name: "build", Help: "构建", Hand: func(m *ice.Message, arg ...string) {
|
cli.BUILD: {Name: "build", Help: "构建", Hand: func(m *ice.Message, arg ...string) {
|
||||||
m.Cmdy(code.INSTALL, cli.BUILD, m.Conf(GIT, kit.META_SOURCE))
|
m.Cmdy(code.INSTALL, cli.BUILD, m.Conf(GIT, kit.Keym(cli.SOURCE)))
|
||||||
}},
|
}},
|
||||||
cli.START: {Name: "start", Help: "启动", Hand: func(m *ice.Message, arg ...string) {
|
cli.START: {Name: "start", Help: "启动", Hand: func(m *ice.Message, arg ...string) {
|
||||||
m.Optionv(code.PREPARE, func(p string) []string {
|
m.Cmdy(code.INSTALL, cli.START, m.Conf(GIT, kit.Keym(cli.SOURCE)), "bin/git")
|
||||||
m.Option(cli.CMD_DIR, p)
|
|
||||||
kit.Fetch(m.Confv(GIT, kit.Keym("config")), func(conf string, value interface{}) {
|
|
||||||
kit.Fetch(value, func(key string, value string) {
|
|
||||||
m.Cmd(cli.SYSTEM, "bin/git", "config", "--global", conf+"."+key, value)
|
|
||||||
})
|
|
||||||
})
|
|
||||||
return []string{}
|
|
||||||
})
|
|
||||||
m.Cmdy(code.INSTALL, cli.START, m.Conf(GIT, kit.META_SOURCE), "bin/git")
|
|
||||||
}},
|
}},
|
||||||
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||||
m.Cmdy(code.INSTALL, path.Base(m.Conf(GIT, kit.META_SOURCE)), arg)
|
m.Cmdy(code.INSTALL, path.Base(m.Conf(GIT, kit.Keym(cli.SOURCE))), arg)
|
||||||
}},
|
}},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package git
|
package git
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
"strings"
|
"strings"
|
||||||
@ -37,7 +36,6 @@ const (
|
|||||||
MASTER = "master"
|
MASTER = "master"
|
||||||
|
|
||||||
CLONE = "clone"
|
CLONE = "clone"
|
||||||
|
|
||||||
INIT = "init"
|
INIT = "init"
|
||||||
)
|
)
|
||||||
const REPOS = "repos"
|
const REPOS = "repos"
|
||||||
@ -46,11 +44,18 @@ func init() {
|
|||||||
Index.Merge(&ice.Context{
|
Index.Merge(&ice.Context{
|
||||||
Configs: map[string]*ice.Config{
|
Configs: map[string]*ice.Config{
|
||||||
REPOS: {Name: REPOS, Help: "代码库", Value: kit.Data(
|
REPOS: {Name: REPOS, Help: "代码库", Value: kit.Data(
|
||||||
kit.MDB_SHORT, kit.MDB_NAME, kit.SSH_REPOS, "https://github.com/shylinux",
|
kit.MDB_SHORT, kit.MDB_NAME, kit.MDB_FIELD, "time,name,branch,commit,remote",
|
||||||
|
kit.SSH_REPOS, "https://github.com/shylinux",
|
||||||
)},
|
)},
|
||||||
},
|
},
|
||||||
Commands: map[string]*ice.Command{
|
Commands: map[string]*ice.Command{
|
||||||
REPOS: {Name: "repos name path auto create proxy", Help: "代码库", Action: map[string]*ice.Action{
|
ice.CTX_INIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||||
|
_repos_insert(m, path.Base(kit.Pwd()), kit.Pwd())
|
||||||
|
m.Cmd(nfs.DIR, kit.SSH_USR, "name,path").Table(func(index int, value map[string]string, head []string) {
|
||||||
|
_repos_insert(m, value[kit.MDB_NAME], value[kit.MDB_PATH])
|
||||||
|
})
|
||||||
|
}},
|
||||||
|
REPOS: {Name: "repos name path auto create", Help: "代码库", Action: map[string]*ice.Action{
|
||||||
mdb.CREATE: {Name: "create repos branch name path", Help: "添加", Hand: func(m *ice.Message, arg ...string) {
|
mdb.CREATE: {Name: "create repos branch name path", Help: "添加", Hand: func(m *ice.Message, arg ...string) {
|
||||||
m.Option(kit.MDB_NAME, kit.Select(strings.TrimSuffix(path.Base(m.Option(kit.SSH_REPOS)), ".git"), m.Option(kit.MDB_NAME)))
|
m.Option(kit.MDB_NAME, kit.Select(strings.TrimSuffix(path.Base(m.Option(kit.SSH_REPOS)), ".git"), m.Option(kit.MDB_NAME)))
|
||||||
m.Option(kit.MDB_PATH, kit.Select(path.Join(kit.SSH_USR, m.Option(kit.MDB_NAME)), m.Option(kit.MDB_PATH)))
|
m.Option(kit.MDB_PATH, kit.Select(path.Join(kit.SSH_USR, m.Option(kit.MDB_NAME)), m.Option(kit.MDB_PATH)))
|
||||||
@ -75,7 +80,7 @@ func init() {
|
|||||||
}},
|
}},
|
||||||
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||||
if len(arg) == 0 { // 仓库列表
|
if len(arg) == 0 { // 仓库列表
|
||||||
m.Fields(len(arg) == 0, "time,name,branch,commit,remote")
|
m.Fields(len(arg) == 0, m.Conf(REPOS, kit.META_FIELD))
|
||||||
m.Cmdy(mdb.SELECT, m.Prefix(REPOS), "", mdb.HASH)
|
m.Cmdy(mdb.SELECT, m.Prefix(REPOS), "", mdb.HASH)
|
||||||
m.Sort(kit.MDB_NAME)
|
m.Sort(kit.MDB_NAME)
|
||||||
return
|
return
|
||||||
@ -83,11 +88,6 @@ func init() {
|
|||||||
|
|
||||||
m.Option(nfs.DIR_ROOT, _repos_path(arg[0]))
|
m.Option(nfs.DIR_ROOT, _repos_path(arg[0]))
|
||||||
m.Cmdy(nfs.CAT, kit.Select("./", arg, 1), "time,line,path")
|
m.Cmdy(nfs.CAT, kit.Select("./", arg, 1), "time,line,path")
|
||||||
|
|
||||||
m.Option(cli.CMD_DIR, _repos_path(arg[0]))
|
|
||||||
p := strings.TrimPrefix(strings.TrimPrefix(m.Cmdx(cli.SYSTEM, GIT, REMOTE, "get-url", ORIGIN), "http://"), "https://")
|
|
||||||
pp := kit.MergeURL2(m.Option(ice.MSG_USERWEB), fmt.Sprintf("/code/git/%s", strings.TrimSpace(p)))
|
|
||||||
m.EchoScript(fmt.Sprintf("git clone %s", pp))
|
|
||||||
}},
|
}},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user