forked from x/icebergs
opt git
This commit is contained in:
parent
571d6d1f6c
commit
476d82cf19
@ -56,6 +56,7 @@ func (f *Frame) parse(m *ice.Message, line string) *Frame {
|
|||||||
m.Log(ice.LOG_IMPORT, "stdin: %d %v", len(ls), ls)
|
m.Log(ice.LOG_IMPORT, "stdin: %d %v", len(ls), ls)
|
||||||
|
|
||||||
if len(ls) == 1 && ls[0] == "~" {
|
if len(ls) == 1 && ls[0] == "~" {
|
||||||
|
// 模块列表
|
||||||
ls = []string{"context"}
|
ls = []string{"context"}
|
||||||
} else if len(ls) > 0 && strings.HasPrefix(ls[0], "~") {
|
} else if len(ls) > 0 && strings.HasPrefix(ls[0], "~") {
|
||||||
// 切换模块
|
// 切换模块
|
||||||
@ -90,9 +91,32 @@ func (f *Frame) parse(m *ice.Message, line string) *Frame {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 执行命令
|
// 解析选项
|
||||||
|
ln := []string{}
|
||||||
msg := m.Spawns(f.target)
|
msg := m.Spawns(f.target)
|
||||||
msg.Cmdy(ls[0], ls[1:])
|
for i := 0; i < len(ls); i++ {
|
||||||
|
if ls[i] == "--" {
|
||||||
|
ln = append(ln, ls[i+1:]...)
|
||||||
|
break
|
||||||
|
} else if strings.HasPrefix(ls[i], "-") {
|
||||||
|
for j := i; j < len(ls); j++ {
|
||||||
|
if j == len(ls)-1 || strings.HasPrefix(ls[j+1], "-") {
|
||||||
|
if i == j {
|
||||||
|
msg.Option(ls[i][1:], "true")
|
||||||
|
} else {
|
||||||
|
msg.Option(ls[i][1:], ls[i+1:j+1])
|
||||||
|
}
|
||||||
|
i = j
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
ln = append(ln, ls[i])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 执行命令
|
||||||
|
msg.Cmdy(ln[0], ln[1:])
|
||||||
|
|
||||||
// 转换结果
|
// 转换结果
|
||||||
res := msg.Result()
|
res := msg.Result()
|
||||||
|
@ -708,18 +708,16 @@ var Index = &ice.Context{Name: "web", Help: "网络模块",
|
|||||||
})
|
})
|
||||||
fallthrough
|
fallthrough
|
||||||
case "dev":
|
case "dev":
|
||||||
// 系统初始化
|
|
||||||
m.Event(ice.SYSTEM_INIT)
|
|
||||||
fallthrough
|
|
||||||
case "self":
|
|
||||||
// 启动服务
|
|
||||||
m.Target().Start(m, "self")
|
|
||||||
fallthrough
|
|
||||||
default:
|
|
||||||
// 连接上游服务
|
// 连接上游服务
|
||||||
m.Richs(ice.WEB_SPIDE, nil, "dev", func(key string, value map[string]interface{}) {
|
m.Richs(ice.WEB_SPIDE, nil, "dev", func(key string, value map[string]interface{}) {
|
||||||
m.Cmd(ice.WEB_SPACE, "connect", "dev")
|
m.Cmd(ice.WEB_SPACE, "connect", "dev")
|
||||||
})
|
})
|
||||||
|
fallthrough
|
||||||
|
default:
|
||||||
|
// 启动服务
|
||||||
|
m.Target().Start(m, "self")
|
||||||
|
// 系统初始化
|
||||||
|
m.Event(ice.SYSTEM_INIT)
|
||||||
}
|
}
|
||||||
}},
|
}},
|
||||||
ice.WEB_SPACE: {Name: "space", Help: "空间站", Meta: kit.Dict("exports", []string{"pod", "name"}), List: kit.List(
|
ice.WEB_SPACE: {Name: "space", Help: "空间站", Meta: kit.Dict("exports", []string{"pod", "name"}), List: kit.List(
|
||||||
@ -839,9 +837,11 @@ var Index = &ice.Context{Name: "web", Help: "网络模块",
|
|||||||
m.Target().Server().(*Frame).send[id] = m
|
m.Target().Server().(*Frame).send[id] = m
|
||||||
socket.WriteMessage(MSG_MAPS, []byte(m.Format("meta")))
|
socket.WriteMessage(MSG_MAPS, []byte(m.Format("meta")))
|
||||||
t := time.AfterFunc(kit.Duration(m.Conf(ice.WEB_SPACE, "meta.timeout.c")), func() {
|
t := time.AfterFunc(kit.Duration(m.Conf(ice.WEB_SPACE, "meta.timeout.c")), func() {
|
||||||
|
m.TryCatch(m, true, func(m *ice.Message) {
|
||||||
m.Log(ice.LOG_WARN, "timeout")
|
m.Log(ice.LOG_WARN, "timeout")
|
||||||
m.Back(nil)
|
m.Back(nil)
|
||||||
})
|
})
|
||||||
|
})
|
||||||
m.Call(true, func(msg *ice.Message) *ice.Message {
|
m.Call(true, func(msg *ice.Message) *ice.Message {
|
||||||
// 返回结果
|
// 返回结果
|
||||||
m.Copy(msg).Log("cost", "%s: %s %v", m.Format("cost"), arg[0], arg[1:])
|
m.Copy(msg).Log("cost", "%s: %s %v", m.Format("cost"), arg[0], arg[1:])
|
||||||
@ -861,11 +861,11 @@ var Index = &ice.Context{Name: "web", Help: "网络模块",
|
|||||||
if len(arg) > 1 {
|
if len(arg) > 1 {
|
||||||
switch arg[1] {
|
switch arg[1] {
|
||||||
case "启动":
|
case "启动":
|
||||||
arg = []string{arg[3]}
|
arg = []string{arg[4]}
|
||||||
case "停止", "stop":
|
case "停止", "stop":
|
||||||
m.Cmd(ice.WEB_SPACE, kit.Select(m.Option("name"), arg, 3), "exit", "1")
|
m.Cmd(ice.WEB_SPACE, kit.Select(m.Option("name"), arg, 4), "exit", "1")
|
||||||
time.Sleep(time.Second * 3)
|
time.Sleep(time.Second * 3)
|
||||||
m.Event(ice.DREAM_CLOSE, arg[3])
|
m.Event(ice.DREAM_CLOSE, arg[4])
|
||||||
arg = arg[:0]
|
arg = arg[:0]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -41,7 +41,6 @@ var Index = &ice.Context{Name: "chat", Help: "聊天中心",
|
|||||||
[]interface{}{"field", "command", "web.code.docker"},
|
[]interface{}{"field", "command", "web.code.docker"},
|
||||||
[]interface{}{"field", "repos", "web.code.git"},
|
[]interface{}{"field", "repos", "web.code.git"},
|
||||||
[]interface{}{"field", "total", "web.code.git"},
|
[]interface{}{"field", "total", "web.code.git"},
|
||||||
[]interface{}{"field", "branch", "web.code.git"},
|
|
||||||
[]interface{}{"field", "status", "web.code.git"},
|
[]interface{}{"field", "status", "web.code.git"},
|
||||||
|
|
||||||
[]interface{}{"storm", "root"},
|
[]interface{}{"storm", "root"},
|
||||||
|
@ -62,7 +62,7 @@ var Index = &ice.Context{Name: "code", Help: "编程中心",
|
|||||||
"compile": {Name: "compile", Help: "编译", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
"compile": {Name: "compile", Help: "编译", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||||
if len(arg) == 0 {
|
if len(arg) == 0 {
|
||||||
// 目录列表
|
// 目录列表
|
||||||
m.Cmdy("nfs.dir", "", m.Conf("publish", "meta.path"), "time size path")
|
m.Cmdy("nfs.dir", m.Conf("publish", "meta.path"), "time size path")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -344,31 +344,29 @@ var Index = &ice.Context{Name: "team", Help: "团队中心",
|
|||||||
// 本月日期
|
// 本月日期
|
||||||
for day := one; day.Before(end); day = day.AddDate(0, 0, 1) {
|
for day := one; day.Before(end); day = day.AddDate(0, 0, 1) {
|
||||||
note := []string{ShowDay(m, day)}
|
note := []string{ShowDay(m, day)}
|
||||||
m.Info("what %v", note)
|
|
||||||
|
|
||||||
index := day.Format("2006-01-02")
|
index := day.Format("2006-01-02")
|
||||||
if arg[0] == "month" {
|
|
||||||
for i, v := range list[index] {
|
for i, v := range list[index] {
|
||||||
b, _ := kit.Render(kit.Format(template, name[index][i]), v)
|
b, _ := kit.Render(kit.Format(template, name[index][i]), v)
|
||||||
note = append(note, string(b))
|
note = append(note, string(b))
|
||||||
|
// note = append(note, kit.Format(`%s: %s`, v["name"], v["text"]))
|
||||||
}
|
}
|
||||||
m.Push(head[int(day.Weekday())], strings.Join(note, ""))
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
for _, v := range list[index] {
|
|
||||||
note = append(note, kit.Format(`%s: %s`, v["name"], v["text"]))
|
|
||||||
}
|
|
||||||
if len(note) > 1 {
|
if len(note) > 1 {
|
||||||
note[0] = kit.Format(`<div title="%s">%s<sup class="more">%d<sup><div>`, strings.Join(note[1:], "\n"), note[0], len(note)-1)
|
note[0] = kit.Format(`%s<sup class="more">%d</sup>`, note[0], len(note)-1)
|
||||||
} else {
|
} else {
|
||||||
note[0] = kit.Format(`%s<sup class="less">%s<sup>`, note[0], "")
|
note[0] = kit.Format(`%s<sup class="less">%s</sup>`, note[0], "")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if arg[0] == "month" {
|
||||||
|
m.Push(head[int(day.Weekday())], strings.Join(note, ""))
|
||||||
|
} else {
|
||||||
m.Push(head[int(day.Weekday())], note[0])
|
m.Push(head[int(day.Weekday())], note[0])
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// 下月开头
|
// 下月开头
|
||||||
tail := end.AddDate(0, 0, 6-int(end.Weekday())+1)
|
tail := end.AddDate(0, 0, 6-int(end.Weekday())+1)
|
||||||
for day := end; end.Weekday() != 0 && day.Before(tail); day = day.AddDate(0, 0, 1) {
|
for day := end; end.Weekday() != 0 && day.Before(tail); day = day.AddDate(0, 0, 1) {
|
||||||
m.Info("what %v", day)
|
|
||||||
m.Push(head[int(day.Weekday())], ShowDay(m, day))
|
m.Push(head[int(day.Weekday())], ShowDay(m, day))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,6 +56,7 @@ var Index = &ice.Context{Name: "wiki", Help: "文档中心",
|
|||||||
),
|
),
|
||||||
)),
|
)),
|
||||||
)},
|
)},
|
||||||
|
|
||||||
"order": {Name: "order", Help: "列表", Value: kit.Data("template", order)},
|
"order": {Name: "order", Help: "列表", Value: kit.Data("template", order)},
|
||||||
"table": {Name: "table", Help: "表格", Value: kit.Data("template", table)},
|
"table": {Name: "table", Help: "表格", Value: kit.Data("template", table)},
|
||||||
"stack": {Name: "stack", Help: "结构", Value: kit.Data("template", stack)},
|
"stack": {Name: "stack", Help: "结构", Value: kit.Data("template", stack)},
|
||||||
@ -237,7 +238,7 @@ var Index = &ice.Context{Name: "wiki", Help: "文档中心",
|
|||||||
m.Option("output", output)
|
m.Option("output", output)
|
||||||
m.Render(m.Conf(cmd, "meta.template"))
|
m.Render(m.Conf(cmd, "meta.template"))
|
||||||
}},
|
}},
|
||||||
"field": {Name: "field name text", Help: "列表", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
"field": {Name: "field name text", Help: "插件", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||||
m.Option(kit.MDB_TYPE, cmd)
|
m.Option(kit.MDB_TYPE, cmd)
|
||||||
m.Option(kit.MDB_NAME, arg[0])
|
m.Option(kit.MDB_NAME, arg[0])
|
||||||
m.Option(kit.MDB_TEXT, arg[1])
|
m.Option(kit.MDB_TEXT, arg[1])
|
||||||
@ -260,6 +261,7 @@ var Index = &ice.Context{Name: "wiki", Help: "文档中心",
|
|||||||
m.Option("meta", data)
|
m.Option("meta", data)
|
||||||
m.Render(m.Conf(cmd, "meta.template"))
|
m.Render(m.Conf(cmd, "meta.template"))
|
||||||
}},
|
}},
|
||||||
|
|
||||||
"order": {Name: "order name text", Help: "列表", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
"order": {Name: "order name text", Help: "列表", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||||
m.Option(kit.MDB_TYPE, cmd)
|
m.Option(kit.MDB_TYPE, cmd)
|
||||||
m.Option(kit.MDB_NAME, arg[0])
|
m.Option(kit.MDB_NAME, arg[0])
|
||||||
@ -383,7 +385,7 @@ var Index = &ice.Context{Name: "wiki", Help: "文档中心",
|
|||||||
reply(m, cmd, arg...)
|
reply(m, cmd, arg...)
|
||||||
}},
|
}},
|
||||||
"data": {Name: "data", Help: "数据表格", Meta: kit.Dict("remote", "pod", "display", "wiki/data"), List: kit.List(
|
"data": {Name: "data", Help: "数据表格", Meta: kit.Dict("remote", "pod", "display", "wiki/data"), List: kit.List(
|
||||||
kit.MDB_INPUT, "text", "name", "path",
|
kit.MDB_INPUT, "text", "name", "path", "action", "auto",
|
||||||
kit.MDB_INPUT, "button", "name", "执行", "action", "auto",
|
kit.MDB_INPUT, "button", "name", "执行", "action", "auto",
|
||||||
kit.MDB_INPUT, "button", "name", "返回", "cb", "Last",
|
kit.MDB_INPUT, "button", "name", "返回", "cb", "Last",
|
||||||
), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||||
@ -546,21 +548,10 @@ var Index = &ice.Context{Name: "wiki", Help: "文档中心",
|
|||||||
// 输入补全
|
// 输入补全
|
||||||
switch arg[2] {
|
switch arg[2] {
|
||||||
case "type":
|
case "type":
|
||||||
m.Push("type", []string{"spark", "label", "refer", "brief", "chapter", "section", "title"})
|
m.Push("type", []string{"spark", "order", "table", "label", "chain", "refer", "brief", "chapter", "section", "title"})
|
||||||
case "path":
|
case "path":
|
||||||
m.Option("_refresh", "true")
|
m.Option("_refresh", "true")
|
||||||
// 文件列表
|
reply(m, "word", arg[3:]...)
|
||||||
m.Option("dir_root", m.Conf("word", "meta.path"))
|
|
||||||
m.Option("dir_reg", m.Conf("word", "meta.regs"))
|
|
||||||
m.Cmdy("nfs.dir", kit.Select("./", arg, 3), "path")
|
|
||||||
m.Sort("time", "time_r")
|
|
||||||
if len(arg) == 3 || strings.HasSuffix(arg[3], "/") {
|
|
||||||
// 目录列表
|
|
||||||
m.Option("dir_reg", "")
|
|
||||||
m.Option("dir_type", "dir")
|
|
||||||
m.Cmdy("nfs.dir", kit.Select("./", arg, 3), "path")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -570,8 +561,8 @@ var Index = &ice.Context{Name: "wiki", Help: "文档中心",
|
|||||||
m.Cmdy("word", arg)
|
m.Cmdy("word", arg)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
m.Cmd("word", "action", "追加", arg)
|
m.Cmd("word", "action", "追加", arg)
|
||||||
|
|
||||||
m.Option("scan_mode", "scan")
|
m.Option("scan_mode", "scan")
|
||||||
m.Cmdy("ssh.scan", "some", "some", path.Join(m.Conf("word", "meta.path"), arg[0]))
|
m.Cmdy("ssh.scan", "some", "some", path.Join(m.Conf("word", "meta.path"), arg[0]))
|
||||||
}},
|
}},
|
||||||
|
136
misc/git/git.go
136
misc/git/git.go
@ -11,86 +11,69 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func add(m *ice.Message, n string, p string) {
|
||||||
|
if s, e := os.Stat(m.Option("cmd_dir", path.Join(p, ".git"))); e == nil && s.IsDir() {
|
||||||
|
ls := strings.SplitN(strings.Trim(m.Cmdx(ice.CLI_SYSTEM, "git", "log", "-n1", `--pretty=format:"%ad %s"`, "--date=iso"), "\""), " ", 4)
|
||||||
|
m.Rich("repos", nil, kit.Data(
|
||||||
|
"name", n, "path", p,
|
||||||
|
"last", ls[3], "time", strings.Join(ls[:2], " "),
|
||||||
|
"branch", strings.TrimSpace(m.Cmdx(ice.CLI_SYSTEM, "git", "branch")),
|
||||||
|
"remote", strings.TrimSpace(m.Cmdx(ice.CLI_SYSTEM, "git", "remote", "-v")),
|
||||||
|
))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var Index = &ice.Context{Name: "git", Help: "代码库",
|
var Index = &ice.Context{Name: "git", Help: "代码库",
|
||||||
Caches: map[string]*ice.Cache{},
|
Caches: map[string]*ice.Cache{},
|
||||||
Configs: map[string]*ice.Config{
|
Configs: map[string]*ice.Config{
|
||||||
"repos": {Name: "repos", Help: "仓库", Value: kit.Data(kit.MDB_SHORT, "name", "owner", "https://github.com/shylinux")},
|
"repos": {Name: "repos", Help: "仓库", Value: kit.Data(kit.MDB_SHORT, "name", "owner", "https://github.com/shylinux")},
|
||||||
|
"total": {Name: "repos", Help: "仓库", Value: kit.Data(kit.MDB_SHORT, "name", "skip", kit.Dict("wubi-dict", "true"))},
|
||||||
},
|
},
|
||||||
Commands: map[string]*ice.Command{
|
Commands: map[string]*ice.Command{
|
||||||
ice.ICE_INIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
ice.ICE_INIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||||
// 系统项目
|
// 系统项目
|
||||||
wd, _ := os.Getwd()
|
wd, _ := os.Getwd()
|
||||||
if s, e := os.Stat(".git"); e == nil && s.IsDir() {
|
add(m, path.Base(wd), wd)
|
||||||
m.Rich("repos", nil, kit.Data(
|
|
||||||
"name", path.Base(wd), "path", wd, "branch", "master",
|
|
||||||
"remote", strings.TrimSpace(m.Cmdx(ice.CLI_SYSTEM, "git", "remote", "-v")),
|
|
||||||
))
|
|
||||||
}
|
|
||||||
|
|
||||||
// 官方项目
|
// 官方项目
|
||||||
m.Cmd("nfs.dir", "usr", "name path").Table(func(index int, value map[string]string, head []string) {
|
m.Cmd("nfs.dir", "usr", "name path").Table(func(index int, value map[string]string, head []string) {
|
||||||
if s, e := os.Stat(m.Option("cmd_dir", path.Join(value["path"], ".git"))); e == nil && s.IsDir() {
|
add(m, value["name"], value["path"])
|
||||||
m.Rich("repos", nil, kit.Data(
|
|
||||||
"name", value["name"], "path", value["path"], "branch", "master",
|
|
||||||
"remote", strings.TrimSpace(m.Cmdx(ice.CLI_SYSTEM, "git", "remote", "-v")),
|
|
||||||
))
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
|
||||||
// 应用项目
|
// 应用项目
|
||||||
m.Cmd("nfs.dir", m.Conf(ice.WEB_DREAM, "meta.path"), "name path").Table(func(index int, value map[string]string, head []string) {
|
m.Cmd("nfs.dir", m.Conf(ice.WEB_DREAM, "meta.path"), "name path").Table(func(index int, value map[string]string, head []string) {
|
||||||
if s, e := os.Stat(m.Option("cmd_dir", path.Join(value["path"], ".git"))); e == nil && s.IsDir() {
|
add(m, value["name"], value["path"])
|
||||||
m.Rich("repos", nil, kit.Data(
|
|
||||||
"name", value["name"], "path", value["path"], "branch", "master",
|
|
||||||
"remote", strings.TrimSpace(m.Cmdx(ice.CLI_SYSTEM, "git", "remote", "-v")),
|
|
||||||
))
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
}},
|
}},
|
||||||
ice.ICE_EXIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {}},
|
ice.ICE_EXIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {}},
|
||||||
|
|
||||||
"repos": {Name: "repos [name [path]]", Help: "仓库", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
"repos": {Name: "repos [name [path [remote [branch]]]]", Help: "仓库", List: kit.List(
|
||||||
if len(arg) > 0 {
|
kit.MDB_INPUT, "text", "name", "name", "action", "auto",
|
||||||
m.Rich("repos", nil, kit.Data(
|
kit.MDB_INPUT, "button", "name", "查看", "action", "auto",
|
||||||
"name", arg[0], "path", kit.Select(path.Join("usr", arg[0]), arg, 1), "branch", "master",
|
kit.MDB_INPUT, "button", "name", "返回", "cb", "Last",
|
||||||
"remote", kit.Select(m.Conf("repos", "meta.owner")+"/"+arg[0], arg, 2),
|
), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||||
))
|
|
||||||
}
|
|
||||||
m.Richs("repos", nil, "*", func(key string, value map[string]interface{}) {
|
|
||||||
m.Push(key, value["meta"], []string{"time", "name", "branch", "path", "remote"})
|
|
||||||
})
|
|
||||||
m.Sort("name")
|
|
||||||
}},
|
|
||||||
"check": {Name: "check name [path [repos]]", Help: "检查", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
|
||||||
if len(arg) > 1 {
|
if len(arg) > 1 {
|
||||||
m.Cmd("repos", arg)
|
if _, e := os.Stat(m.Option("cmd_dir", path.Join(arg[1], ".git"))); e != nil && os.IsNotExist(e) {
|
||||||
|
// 下载仓库
|
||||||
|
m.Cmd(ice.CLI_SYSTEM, "git", "clone", "-b", kit.Select("master", arg, 3),
|
||||||
|
kit.Select(m.Conf("repos", "meta.owner")+"/"+arg[0], arg, 2), arg[1])
|
||||||
|
add(m, arg[0], arg[1])
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if len(arg) > 0 {
|
||||||
|
// 仓库详情
|
||||||
m.Richs("repos", nil, arg[0], func(key string, value map[string]interface{}) {
|
m.Richs("repos", nil, arg[0], func(key string, value map[string]interface{}) {
|
||||||
if _, e := os.Stat(kit.Format(kit.Value(value, "meta.path"))); e != nil && os.IsNotExist(e) {
|
m.Push("detail", value["meta"])
|
||||||
m.Cmd(ice.CLI_SYSTEM, "git", "clone", kit.Value(value, "meta.remote"),
|
|
||||||
"-b", kit.Value(value, "meta.branch"), kit.Value(value, "meta.path"))
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
}},
|
return
|
||||||
"branch": {Name: "branch", Help: "分支", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
|
||||||
prefix := []string{ice.CLI_SYSTEM, "git", "branch"}
|
|
||||||
m.Richs("repos", nil, kit.Select("*", arg, 0), func(key string, value map[string]interface{}) {
|
|
||||||
m.Option("cmd_dir", kit.Value(value, "meta.path"))
|
|
||||||
for _, v := range strings.Split(m.Cmdx(prefix, "-v"), "\n") {
|
|
||||||
if len(v) > 0 {
|
|
||||||
m.Push("repos", kit.Value(value, "meta.name"))
|
|
||||||
m.Push("tags", v[:2])
|
|
||||||
vs := strings.SplitN(strings.TrimSpace(v[2:]), " ", 2)
|
|
||||||
m.Push("branch", vs[0])
|
|
||||||
m.Push("last", m.Cmdx(ice.CLI_SYSTEM, "git", "log", "-n", "1", "--pretty=%ad", "--date=short"))
|
|
||||||
vs = strings.SplitN(strings.TrimSpace(vs[1]), " ", 2)
|
|
||||||
m.Push("hash", vs[0])
|
|
||||||
m.Push("note", strings.TrimSpace(vs[1]))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 仓库列表
|
||||||
|
m.Richs("repos", nil, "*", func(key string, value map[string]interface{}) {
|
||||||
|
m.Push(key, value["meta"], []string{"time", "name", "branch", "last"})
|
||||||
})
|
})
|
||||||
m.Sort("repos")
|
m.Sort("name")
|
||||||
}},
|
}},
|
||||||
"status": {Name: "status repos", Help: "状态", Meta: kit.Dict(
|
"status": {Name: "status repos", Help: "状态", Meta: kit.Dict(
|
||||||
"detail", []interface{}{"add", "reset", "remove", kit.Dict("name", "commit", "args", kit.List(
|
"detail", []interface{}{"add", "reset", "remove", kit.Dict("name", "commit", "args", kit.List(
|
||||||
@ -98,14 +81,14 @@ var Index = &ice.Context{Name: "git", Help: "代码库",
|
|||||||
kit.MDB_INPUT, "text", "name", "name", "value", "some",
|
kit.MDB_INPUT, "text", "name", "name", "value", "some",
|
||||||
))},
|
))},
|
||||||
), List: kit.List(
|
), List: kit.List(
|
||||||
kit.MDB_INPUT, "text", "name", "repos", "action", "auto",
|
kit.MDB_INPUT, "text", "name", "name", "action", "auto",
|
||||||
kit.MDB_INPUT, "button", "name", "查看", "action", "auto",
|
kit.MDB_INPUT, "button", "name", "查看", "action", "auto",
|
||||||
kit.MDB_INPUT, "button", "name", "返回", "cb", "Last", "action", "auto",
|
kit.MDB_INPUT, "button", "name", "返回", "cb", "Last",
|
||||||
), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||||
prefix := []string{ice.CLI_SYSTEM, "git"}
|
prefix := []string{ice.CLI_SYSTEM, "git"}
|
||||||
|
|
||||||
if len(arg) > 0 && arg[0] == "action" {
|
if len(arg) > 0 && arg[0] == "action" {
|
||||||
m.Richs("repos", nil, m.Option("repos"), func(key string, value map[string]interface{}) {
|
m.Richs("repos", nil, m.Option("name"), func(key string, value map[string]interface{}) {
|
||||||
m.Option("cmd_dir", kit.Value(value, "meta.path"))
|
m.Option("cmd_dir", kit.Value(value, "meta.path"))
|
||||||
switch arg[1] {
|
switch arg[1] {
|
||||||
case "add":
|
case "add":
|
||||||
@ -123,34 +106,41 @@ var Index = &ice.Context{Name: "git", Help: "代码库",
|
|||||||
|
|
||||||
m.Richs("repos", nil, kit.Select("*", arg, 0), func(key string, value map[string]interface{}) {
|
m.Richs("repos", nil, kit.Select("*", arg, 0), func(key string, value map[string]interface{}) {
|
||||||
if m.Option("cmd_dir", kit.Value(value, "meta.path")); len(arg) > 0 {
|
if m.Option("cmd_dir", kit.Value(value, "meta.path")); len(arg) > 0 {
|
||||||
|
// 更改详情
|
||||||
m.Echo(m.Cmdx(prefix, "diff"))
|
m.Echo(m.Cmdx(prefix, "diff"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 更改列表
|
||||||
for _, v := range strings.Split(strings.TrimSpace(m.Cmdx(prefix, "status", "-sb")), "\n") {
|
for _, v := range strings.Split(strings.TrimSpace(m.Cmdx(prefix, "status", "-sb")), "\n") {
|
||||||
vs := strings.SplitN(strings.TrimSpace(v), " ", 2)
|
vs := strings.SplitN(strings.TrimSpace(v), " ", 2)
|
||||||
m.Push("repos", kit.Value(value, "meta.name"))
|
m.Push("name", kit.Value(value, "meta.name"))
|
||||||
m.Push("tags", vs[0])
|
m.Push("tags", vs[0])
|
||||||
m.Push("file", vs[1])
|
m.Push("file", vs[1])
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}},
|
}},
|
||||||
"total": {Name: "total", Help: "统计", List: kit.List(
|
"total": {Name: "total", Help: "统计", List: kit.List(
|
||||||
kit.MDB_INPUT, "text", "name", "repos", "action", "auto",
|
kit.MDB_INPUT, "text", "name", "name", "action", "auto",
|
||||||
kit.MDB_INPUT, "button", "name", "查看", "action", "auto",
|
kit.MDB_INPUT, "button", "name", "查看", "action", "auto",
|
||||||
kit.MDB_INPUT, "button", "name", "返回", "cb", "Last",
|
kit.MDB_INPUT, "button", "name", "返回", "cb", "Last",
|
||||||
), 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.Richs("repos", nil, arg[0], func(key string, value map[string]interface{}) {
|
m.Richs("repos", nil, arg[0], func(key string, value map[string]interface{}) {
|
||||||
m.Cmdy("sum", kit.Value(value, "meta.path"), arg[1:])
|
m.Cmdy("sum", kit.Value(value, "meta.path"), arg[1:])
|
||||||
})
|
})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 提交统计
|
||||||
days := 0
|
days := 0
|
||||||
commit, adds, dels, rest := 0, 0, 0, 0
|
commit, adds, dels, rest := 0, 0, 0, 0
|
||||||
m.Richs("repos", nil, "*", func(key string, value map[string]interface{}) {
|
m.Richs("repos", nil, "*", func(key string, value map[string]interface{}) {
|
||||||
m.Push("repos", kit.Value(value, "meta.name"))
|
if m.Conf("total", kit.Keys("meta.skip", kit.Value(value, "meta.name"))) == "true" {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
m.Push("name", kit.Value(value, "meta.name"))
|
||||||
m.Copy(m.Cmd("sum", kit.Value(value, "meta.path"), "total", "10000").Table(func(index int, value map[string]string, head []string) {
|
m.Copy(m.Cmd("sum", kit.Value(value, "meta.path"), "total", "10000").Table(func(index int, value map[string]string, head []string) {
|
||||||
if kit.Int(value["days"]) > days {
|
if kit.Int(value["days"]) > days {
|
||||||
days = kit.Int(value["days"])
|
days = kit.Int(value["days"])
|
||||||
@ -161,7 +151,7 @@ var Index = &ice.Context{Name: "git", Help: "代码库",
|
|||||||
rest += kit.Int(value["rest"])
|
rest += kit.Int(value["rest"])
|
||||||
}))
|
}))
|
||||||
})
|
})
|
||||||
m.Push("repos", "total")
|
m.Push("name", "total")
|
||||||
m.Push("days", days)
|
m.Push("days", days)
|
||||||
m.Push("commit", commit)
|
m.Push("commit", commit)
|
||||||
m.Push("adds", adds)
|
m.Push("adds", adds)
|
||||||
@ -258,6 +248,32 @@ var Index = &ice.Context{Name: "git", Help: "代码库",
|
|||||||
}
|
}
|
||||||
m.Cmdy("total", arg)
|
m.Cmdy("total", arg)
|
||||||
}},
|
}},
|
||||||
|
|
||||||
|
"check": {Name: "check name [path [repos]]", Help: "检查", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||||
|
if len(arg) > 1 {
|
||||||
|
m.Cmd("repos", arg)
|
||||||
|
}
|
||||||
|
}},
|
||||||
|
"branch": {Name: "branch", Help: "分支", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||||
|
prefix := []string{ice.CLI_SYSTEM, "git", "branch"}
|
||||||
|
m.Richs("repos", nil, kit.Select("*", arg, 0), func(key string, value map[string]interface{}) {
|
||||||
|
m.Option("cmd_dir", kit.Value(value, "meta.path"))
|
||||||
|
for _, v := range strings.Split(m.Cmdx(prefix, "-v"), "\n") {
|
||||||
|
if len(v) > 0 {
|
||||||
|
m.Push("time", m.Cmdx(ice.CLI_SYSTEM, "git", "log", "-n", "1", "--pretty=%ad", "--date=iso"))
|
||||||
|
m.Push("name", kit.Value(value, "meta.name"))
|
||||||
|
|
||||||
|
m.Push("tags", v[:2])
|
||||||
|
vs := strings.SplitN(strings.TrimSpace(v[2:]), " ", 2)
|
||||||
|
m.Push("branch", vs[0])
|
||||||
|
vs = strings.SplitN(strings.TrimSpace(vs[1]), " ", 2)
|
||||||
|
m.Push("hash", vs[0])
|
||||||
|
m.Push("last", strings.TrimSpace(vs[1]))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
m.Sort("repos")
|
||||||
|
}},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
2
type.go
2
type.go
@ -1167,7 +1167,9 @@ func (m *Message) Rich(key string, chain interface{}, data interface{}) string {
|
|||||||
|
|
||||||
// 通用数据
|
// 通用数据
|
||||||
prefix := kit.Select("", "meta.", kit.Value(data, "meta") != nil)
|
prefix := kit.Select("", "meta.", kit.Value(data, "meta") != nil)
|
||||||
|
if kit.Value(data, prefix+kit.MDB_TIME) == nil {
|
||||||
kit.Value(data, prefix+kit.MDB_TIME, m.Time())
|
kit.Value(data, prefix+kit.MDB_TIME, m.Time())
|
||||||
|
}
|
||||||
|
|
||||||
// 生成键值
|
// 生成键值
|
||||||
h := ""
|
h := ""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user