forked from x/icebergs
opt git
This commit is contained in:
parent
72c79bc279
commit
ba581c4ea7
51
base/nfs/hex.go
Normal file
51
base/nfs/hex.go
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
package nfs
|
||||||
|
|
||||||
|
import (
|
||||||
|
"compress/gzip"
|
||||||
|
"compress/zlib"
|
||||||
|
"encoding/hex"
|
||||||
|
"io"
|
||||||
|
"os"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
ice "shylinux.com/x/icebergs"
|
||||||
|
"shylinux.com/x/icebergs/base/mdb"
|
||||||
|
kit "shylinux.com/x/toolkits"
|
||||||
|
)
|
||||||
|
|
||||||
|
const HEX = "hex"
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
Index.MergeCommands(ice.Commands{HEX: {Name: "hex path compress=raw,gzip,zlib size auto", Help: "二进制", Hand: func(m *ice.Message, arg ...string) {
|
||||||
|
if len(arg) == 0 || arg[0] == "" || strings.HasSuffix(arg[0], ice.PS) {
|
||||||
|
m.Cmdy(DIR, kit.Slice(arg, 0, 1))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if f, e := os.Open(arg[0]); !m.Warn(e, ice.ErrNotFound, arg[0]) {
|
||||||
|
defer f.Close()
|
||||||
|
s, _ := f.Stat()
|
||||||
|
var r io.Reader = f
|
||||||
|
switch arg[1] {
|
||||||
|
case "gzip":
|
||||||
|
if g, e := gzip.NewReader(r); !m.Warn(e) {
|
||||||
|
r = g
|
||||||
|
}
|
||||||
|
case "zlib":
|
||||||
|
if z, e := zlib.NewReader(r); !m.Warn(e) {
|
||||||
|
r = z
|
||||||
|
}
|
||||||
|
}
|
||||||
|
buf := make([]byte, kit.Int(kit.Select("1024", arg, 2)))
|
||||||
|
n, _ := r.Read(buf)
|
||||||
|
for i := 0; i < n; i++ {
|
||||||
|
if i%8 == 0 {
|
||||||
|
m.Push("n", kit.Format("%04d", i))
|
||||||
|
}
|
||||||
|
if m.Push(kit.Format(i%8), hex.EncodeToString(buf[i:i+1])); i%8 == 7 {
|
||||||
|
m.Push("text", string(buf[i-7:i+1]))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
m.Status(mdb.TIME, s.ModTime().Format(ice.MOD_TIME), FILE, arg[0], SIZE, kit.FmtSize(s.Size()))
|
||||||
|
}
|
||||||
|
}}})
|
||||||
|
}
|
@ -126,6 +126,7 @@ func init() {
|
|||||||
_inner_list(m, kit.Ext(arg[1]), arg[1], arg[0])
|
_inner_list(m, kit.Ext(arg[1]), arg[1], arg[0])
|
||||||
m.Cmd(FAVOR, mdb.INSERT, mdb.ZONE, "_recent_file", nfs.PATH, arg[0], nfs.FILE, arg[1])
|
m.Cmd(FAVOR, mdb.INSERT, mdb.ZONE, "_recent_file", nfs.PATH, arg[0], nfs.FILE, arg[1])
|
||||||
m.Options("tabs", m.Config("show.tabs"), "plug", m.Config("show.plug"), "exts", m.Config("show.exts"))
|
m.Options("tabs", m.Config("show.tabs"), "plug", m.Config("show.plug"), "exts", m.Config("show.exts"))
|
||||||
|
m.Option("repos", kit.Join(m.Cmd("web.code.git.repos", ice.OptionFields(nfs.PATH)).Sort(nfs.PATH).Appendv(nfs.PATH)))
|
||||||
ctx.DisplayLocal(m, "")
|
ctx.DisplayLocal(m, "")
|
||||||
}},
|
}},
|
||||||
})
|
})
|
||||||
|
@ -28,6 +28,7 @@ func init() {
|
|||||||
WordAlias(m, CHAPTER, TITLE, CHAPTER)
|
WordAlias(m, CHAPTER, TITLE, CHAPTER)
|
||||||
WordAlias(m, SECTION, TITLE, SECTION)
|
WordAlias(m, SECTION, TITLE, SECTION)
|
||||||
WordAlias(m, ENDMENU, TITLE, ENDMENU)
|
WordAlias(m, ENDMENU, TITLE, ENDMENU)
|
||||||
|
WordAlias(m, SHELL, SPARK, SHELL)
|
||||||
WordAlias(m, LABEL, CHART, LABEL)
|
WordAlias(m, LABEL, CHART, LABEL)
|
||||||
WordAlias(m, CHAIN, CHART, CHAIN)
|
WordAlias(m, CHAIN, CHART, CHAIN)
|
||||||
WordAlias(m, SEQUENCE, CHART, SEQUENCE)
|
WordAlias(m, SEQUENCE, CHART, SEQUENCE)
|
||||||
@ -41,7 +42,12 @@ func init() {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
}}, "play": {Name: "play", Help: "演示"},
|
}}, "play": {Name: "play", Help: "演示"},
|
||||||
ice.STORY: {Hand: func(m *ice.Message, arg ...string) { m.Cmdy(arg[0], ice.RUN, arg[2:]) }},
|
ice.STORY: {Hand: func(m *ice.Message, arg ...string) {
|
||||||
|
if kit.Ext(m.Option(nfs.PATH)) == nfs.SHY {
|
||||||
|
m.Option(nfs.PATH, "")
|
||||||
|
}
|
||||||
|
m.Cmdy(arg[0], ice.RUN, arg[2:])
|
||||||
|
}},
|
||||||
}, WikiAction("", nfs.SHY), ctx.CmdAction(), aaa.RoleAction("story.field")), Hand: func(m *ice.Message, arg ...string) {
|
}, WikiAction("", nfs.SHY), ctx.CmdAction(), aaa.RoleAction("story.field")), Hand: func(m *ice.Message, arg ...string) {
|
||||||
if m.Option(nfs.DIR_DEEP, ice.TRUE); len(arg) == 0 {
|
if m.Option(nfs.DIR_DEEP, ice.TRUE); len(arg) == 0 {
|
||||||
arg = append(arg, "src/")
|
arg = append(arg, "src/")
|
||||||
|
2
go.mod
2
go.mod
@ -5,6 +5,6 @@ go 1.11
|
|||||||
require (
|
require (
|
||||||
shylinux.com/x/creackpty v0.0.1
|
shylinux.com/x/creackpty v0.0.1
|
||||||
shylinux.com/x/go-qrcode v0.0.1
|
shylinux.com/x/go-qrcode v0.0.1
|
||||||
shylinux.com/x/toolkits v0.7.0
|
shylinux.com/x/toolkits v0.7.1
|
||||||
shylinux.com/x/websocket v0.0.1
|
shylinux.com/x/websocket v0.0.1
|
||||||
)
|
)
|
||||||
|
4
go.sum
4
go.sum
@ -2,7 +2,7 @@ shylinux.com/x/creackpty v0.0.1 h1:o+qDE39jFsHLZB9BRAm0EI6qScjw5PuvdkROqhTcupM=
|
|||||||
shylinux.com/x/creackpty v0.0.1/go.mod h1:d7DnPv3oGc23WlzrN8hW7p88wNLPAO/XG4ICVEq96i0=
|
shylinux.com/x/creackpty v0.0.1/go.mod h1:d7DnPv3oGc23WlzrN8hW7p88wNLPAO/XG4ICVEq96i0=
|
||||||
shylinux.com/x/go-qrcode v0.0.1 h1:/eOGqMj1qtgs9Ymd12zTUa1gcJZs9S92kj2lb0QzKsE=
|
shylinux.com/x/go-qrcode v0.0.1 h1:/eOGqMj1qtgs9Ymd12zTUa1gcJZs9S92kj2lb0QzKsE=
|
||||||
shylinux.com/x/go-qrcode v0.0.1/go.mod h1:KAbtU+KwiiABMZ/CJ0zh9PI2AX82Uf9rRYcQ4ODm4po=
|
shylinux.com/x/go-qrcode v0.0.1/go.mod h1:KAbtU+KwiiABMZ/CJ0zh9PI2AX82Uf9rRYcQ4ODm4po=
|
||||||
shylinux.com/x/toolkits v0.7.0 h1:DrfnY78IYlrJJX+N0DrmI46y5PuvfffYoDJrsZd0RvQ=
|
shylinux.com/x/toolkits v0.7.1 h1:XzF7lyKBtb9xzqgRDODf5cEDFoQKeOZnB1ARkMZWyKs=
|
||||||
shylinux.com/x/toolkits v0.7.0/go.mod h1:8LbYHe7oxBIqb6s4MSOD+4d28QvPdvkyCVtwB/JW7AA=
|
shylinux.com/x/toolkits v0.7.1/go.mod h1:8LbYHe7oxBIqb6s4MSOD+4d28QvPdvkyCVtwB/JW7AA=
|
||||||
shylinux.com/x/websocket v0.0.1 h1:OBc21DxqsGlQ2+Pz76xqLyDNo1LV+PUUqfWi+1PZPDE=
|
shylinux.com/x/websocket v0.0.1 h1:OBc21DxqsGlQ2+Pz76xqLyDNo1LV+PUUqfWi+1PZPDE=
|
||||||
shylinux.com/x/websocket v0.0.1/go.mod h1:AaSpMToOxbMULKQytzczeHPuqb708vK1vrAzCxLo/XE=
|
shylinux.com/x/websocket v0.0.1/go.mod h1:AaSpMToOxbMULKQytzczeHPuqb708vK1vrAzCxLo/XE=
|
||||||
|
@ -6,26 +6,25 @@ import (
|
|||||||
kit "shylinux.com/x/toolkits"
|
kit "shylinux.com/x/toolkits"
|
||||||
)
|
)
|
||||||
|
|
||||||
func _configs_set(m *ice.Message, key, value string) string {
|
func _configs_set(m *ice.Message, k, v string) string { return _git_cmds(m, CONFIG, "--global", k, v) }
|
||||||
return _git_cmds(m, "config", "--global", key, value)
|
func _configs_get(m *ice.Message, k string) string { return _git_cmds(m, CONFIG, "--global", k) }
|
||||||
}
|
func _configs_list(m *ice.Message) *ice.Message {
|
||||||
func _configs_get(m *ice.Message, key string) string {
|
|
||||||
return _git_cmds(m, "config", "--global", key)
|
|
||||||
}
|
|
||||||
func _configs_list(m *ice.Message) {
|
|
||||||
kit.SplitKV(ice.EQ, ice.NL, _configs_get(m, "--list"), func(text string, ls []string) {
|
kit.SplitKV(ice.EQ, ice.NL, _configs_get(m, "--list"), func(text string, ls []string) {
|
||||||
m.Push(mdb.NAME, ls[0]).Push(mdb.VALUE, ls[1]).PushButton(mdb.REMOVE)
|
m.Push(mdb.NAME, ls[0]).Push(mdb.VALUE, ls[1]).PushButton(mdb.REMOVE)
|
||||||
})
|
})
|
||||||
mdb.HashSelectValue(m, func(value ice.Maps) { m.Push("", value, kit.Split("name,value")).PushButton(mdb.CREATE) })
|
return mdb.HashSelectValue(m, func(value ice.Maps) { m.Push("", value, kit.Split("name,value")).PushButton(mdb.CREATE) })
|
||||||
m.StatusTimeCount()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const (
|
||||||
|
USER_NAME = "user.name"
|
||||||
|
USER_EMAIL = "user.email"
|
||||||
|
)
|
||||||
const CONFIGS = "configs"
|
const CONFIGS = "configs"
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
Index.MergeCommands(ice.Commands{
|
Index.MergeCommands(ice.Commands{
|
||||||
CONFIGS: {Name: "configs name value auto create import", Help: "配置键", Actions: ice.MergeActions(ice.Actions{
|
CONFIGS: {Name: "configs name value auto create init", Help: "配置键", Actions: ice.MergeActions(ice.Actions{
|
||||||
mdb.IMPORT: {Help: "初始化", Hand: func(m *ice.Message, arg ...string) {
|
ice.INIT: {Help: "初始化", Hand: func(m *ice.Message, arg ...string) {
|
||||||
kit.Fetch(m.Configv(ice.INIT), func(p string, v ice.Any) {
|
kit.Fetch(m.Configv(ice.INIT), func(p string, v ice.Any) {
|
||||||
kit.Fetch(v, func(k string, v string) { _configs_set(m, kit.Keys(p, k), v) })
|
kit.Fetch(v, func(k string, v string) { _configs_set(m, kit.Keys(p, k), v) })
|
||||||
})
|
})
|
||||||
@ -44,17 +43,13 @@ func init() {
|
|||||||
_configs_set(m, m.Option(mdb.NAME), arg[1])
|
_configs_set(m, m.Option(mdb.NAME), arg[1])
|
||||||
}
|
}
|
||||||
}},
|
}},
|
||||||
}, mdb.HashAction(
|
}, mdb.HashAction(mdb.SHORT, mdb.NAME, mdb.FIELD, "time,name,value", ice.INIT, kit.Dict(
|
||||||
mdb.SHORT, mdb.NAME, mdb.FIELD, "time,name,value", ice.INIT, kit.Dict(
|
"alias", kit.Dict("s", "status", "b", "branch", "l", "log --oneline --decorate"),
|
||||||
"alias", kit.Dict("s", "status", "b", "branch", "l", "log --oneline --decorate"),
|
"push", kit.Dict("default", "simple"), "credential", kit.Dict("helper", "store"),
|
||||||
"credential", kit.Dict("helper", "store"),
|
"core", kit.Dict("quotepath", "false"), "color", kit.Dict("ui", "always"),
|
||||||
"core", kit.Dict("quotepath", "false"),
|
))), Hand: func(m *ice.Message, arg ...string) {
|
||||||
"push", kit.Dict("default", "simple"),
|
|
||||||
"color", kit.Dict("ui", "always"),
|
|
||||||
),
|
|
||||||
)), Hand: func(m *ice.Message, arg ...string) {
|
|
||||||
if len(arg) == 0 {
|
if len(arg) == 0 {
|
||||||
_configs_list(m)
|
_configs_list(m).StatusTimeCount()
|
||||||
} else if len(arg) == 1 {
|
} else if len(arg) == 1 {
|
||||||
m.Echo(_configs_get(m, arg[0]))
|
m.Echo(_configs_get(m, arg[0]))
|
||||||
} else {
|
} else {
|
||||||
|
@ -12,29 +12,22 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func _count_count(m *ice.Message, arg []string, cb func(string)) {
|
func _count_count(m *ice.Message, arg []string, cb func(string)) {
|
||||||
if len(arg) == 0 || arg[0] == "usr/" {
|
if m.Warn(len(arg) == 0 || arg[0] == "usr/", ice.ErrNotValid, nfs.DIR, "to many files, please select sub dir") {
|
||||||
m.Echo("to many file, please choice sub dir")
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
m.Cmdy(nfs.DIR, arg, kit.Dict(nfs.DIR_DEEP, ice.TRUE, nfs.DIR_TYPE, nfs.TYPE_CAT), func(file string) {
|
nfs.DirDeepAll(m, "", arg[0], func(value ice.Maps) {
|
||||||
if strings.Contains(file, "node_modules/") {
|
file := value[nfs.PATH]
|
||||||
return
|
for _, p := range []string{"node_modules/", "bin/", "var/", "tags"} {
|
||||||
}
|
if strings.Contains(file, p) {
|
||||||
if strings.Contains(file, "bin/") {
|
return
|
||||||
return
|
}
|
||||||
}
|
|
||||||
if strings.Contains(file, "var/") {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if strings.Contains(file, "tags") {
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
switch kit.Ext(file) {
|
switch kit.Ext(file) {
|
||||||
case "sum", "log":
|
case "sum", "log":
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
cb(file)
|
cb(file)
|
||||||
})
|
}, nfs.PATH)
|
||||||
}
|
}
|
||||||
|
|
||||||
const COUNT = "count"
|
const COUNT = "count"
|
||||||
@ -42,6 +35,28 @@ const COUNT = "count"
|
|||||||
func init() {
|
func init() {
|
||||||
Index.MergeCommands(ice.Commands{
|
Index.MergeCommands(ice.Commands{
|
||||||
COUNT: {Name: "count path auto count order tags", Help: "代码行", Actions: ice.Actions{
|
COUNT: {Name: "count path auto count order tags", Help: "代码行", Actions: ice.Actions{
|
||||||
|
COUNT: {Help: "计数", Hand: func(m *ice.Message, arg ...string) {
|
||||||
|
files := map[string]int{}
|
||||||
|
lines := map[string]int{}
|
||||||
|
_count_count(m, arg, func(file string) {
|
||||||
|
files[mdb.TOTAL]++
|
||||||
|
files[kit.Ext(file)]++
|
||||||
|
m.Cmdy(nfs.CAT, file, func(text string) {
|
||||||
|
if kit.Ext(file) == code.GO {
|
||||||
|
switch {
|
||||||
|
case strings.HasPrefix(text, "func "):
|
||||||
|
lines["_func"]++
|
||||||
|
case strings.HasPrefix(text, "type "):
|
||||||
|
lines["_type"]++
|
||||||
|
}
|
||||||
|
}
|
||||||
|
lines[mdb.TOTAL]++
|
||||||
|
lines[kit.Ext(file)]++
|
||||||
|
})
|
||||||
|
})
|
||||||
|
kit.Fetch(lines, func(k string, v int) { m.Push(mdb.TYPE, k).Push("files", files[k]).Push("lines", lines[k]) })
|
||||||
|
m.StatusTimeCount().SortIntR("lines")
|
||||||
|
}},
|
||||||
"order": {Help: "排行", Hand: func(m *ice.Message, arg ...string) {
|
"order": {Help: "排行", Hand: func(m *ice.Message, arg ...string) {
|
||||||
files := map[string]int{}
|
files := map[string]int{}
|
||||||
_count_count(m, arg, func(file string) {
|
_count_count(m, arg, func(file string) {
|
||||||
@ -62,29 +77,7 @@ func init() {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
kit.Fetch(count, func(k string, v int) { m.Push(mdb.TYPE, k).Push(mdb.COUNT, v) })
|
kit.Fetch(count, func(k string, v int) { m.Push(mdb.TYPE, k).Push(mdb.COUNT, v) })
|
||||||
m.SortIntR(mdb.COUNT)
|
m.StatusTimeCount().SortIntR(mdb.COUNT)
|
||||||
}},
|
|
||||||
COUNT: {Help: "计数", Hand: func(m *ice.Message, arg ...string) {
|
|
||||||
files := map[string]int{}
|
|
||||||
lines := map[string]int{}
|
|
||||||
_count_count(m, arg, func(file string) {
|
|
||||||
files[mdb.TOTAL]++
|
|
||||||
files[kit.Ext(file)]++
|
|
||||||
m.Cmdy(nfs.CAT, file, func(text string) {
|
|
||||||
if kit.Ext(file) == code.GO {
|
|
||||||
switch {
|
|
||||||
case strings.HasPrefix(text, "func"):
|
|
||||||
lines["_func"]++
|
|
||||||
case strings.HasPrefix(text, "type"):
|
|
||||||
lines["_type"]++
|
|
||||||
}
|
|
||||||
}
|
|
||||||
lines[mdb.TOTAL]++
|
|
||||||
lines[kit.Ext(file)]++
|
|
||||||
})
|
|
||||||
})
|
|
||||||
kit.Fetch(lines, func(k string, v int) { m.Push(mdb.TYPE, k).Push("files", files[k]).Push("lines", lines[k]) })
|
|
||||||
m.StatusTime().SortIntR("lines")
|
|
||||||
}},
|
}},
|
||||||
}, Hand: func(m *ice.Message, arg ...string) { m.Cmdy(nfs.DIR, arg) }},
|
}, Hand: func(m *ice.Message, arg ...string) { m.Cmdy(nfs.DIR, arg) }},
|
||||||
})
|
})
|
||||||
|
@ -12,7 +12,7 @@ import (
|
|||||||
kit "shylinux.com/x/toolkits"
|
kit "shylinux.com/x/toolkits"
|
||||||
)
|
)
|
||||||
|
|
||||||
func _git_url(m *ice.Message, repos string) string { return web.MergeLink(m, "/x/"+repos+".git") }
|
func _git_url(m *ice.Message, repos string) string { return web.MergeLink(m, "/x/"+path.Join(repos)+".git") }
|
||||||
func _git_dir(arg ...string) string { return path.Join(path.Join(arg...), ".git") }
|
func _git_dir(arg ...string) string { return path.Join(path.Join(arg...), ".git") }
|
||||||
func _git_cmd(m *ice.Message, arg ...string) *ice.Message { return m.Cmd(cli.SYSTEM, GIT, arg) }
|
func _git_cmd(m *ice.Message, arg ...string) *ice.Message { return m.Cmd(cli.SYSTEM, GIT, arg) }
|
||||||
func _git_cmds(m *ice.Message, arg ...string) string {
|
func _git_cmds(m *ice.Message, arg ...string) string {
|
||||||
|
@ -22,10 +22,10 @@ func _repos_cmd(m *ice.Message, name string, arg ...string) *ice.Message {
|
|||||||
m.Option(cli.CMD_DIR, _repos_path(name))
|
m.Option(cli.CMD_DIR, _repos_path(name))
|
||||||
return m.Copy(_git_cmd(m, arg...))
|
return m.Copy(_git_cmd(m, arg...))
|
||||||
}
|
}
|
||||||
func _repos_init(m *ice.Message, p string) string {
|
func _repos_init(m *ice.Message, dir string) string {
|
||||||
os.MkdirAll(path.Join(p, REFS_HEADS), ice.MOD_DIR)
|
os.MkdirAll(path.Join(dir, REFS_HEADS), ice.MOD_DIR)
|
||||||
os.MkdirAll(path.Join(p, "objects/info/"), ice.MOD_DIR)
|
os.MkdirAll(path.Join(dir, "objects/info/"), ice.MOD_DIR)
|
||||||
return m.Cmdx(nfs.SAVE, path.Join(p, "HEAD"), "ref: refs/heads/master")
|
return m.Cmdx(nfs.SAVE, path.Join(dir, "HEAD"), "ref: refs/heads/master")
|
||||||
}
|
}
|
||||||
func _repos_insert(m *ice.Message, name string, path string) bool {
|
func _repos_insert(m *ice.Message, name string, path string) bool {
|
||||||
if repos, e := gogit.OpenRepository(_git_dir(path)); e == nil {
|
if repos, e := gogit.OpenRepository(_git_dir(path)); e == nil {
|
||||||
@ -47,7 +47,7 @@ func _repos_branch(m *ice.Message, dir string) {
|
|||||||
if ci, e := repos.LookupCommit(refer.Oid); !m.Warn(e, ice.ErrNotValid, refer.Oid.String()) {
|
if ci, e := repos.LookupCommit(refer.Oid); !m.Warn(e, ice.ErrNotValid, refer.Oid.String()) {
|
||||||
m.Push(mdb.TIME, ci.Author.When.Format(ice.MOD_TIME))
|
m.Push(mdb.TIME, ci.Author.When.Format(ice.MOD_TIME))
|
||||||
m.Push(BRANCH, value[nfs.PATH])
|
m.Push(BRANCH, value[nfs.PATH])
|
||||||
m.Push(COMMIT, ci.Oid.String()[:6])
|
m.Push(COMMIT, ci.Oid.Short())
|
||||||
m.Push(AUTHOR, ci.Author.Name)
|
m.Push(AUTHOR, ci.Author.Name)
|
||||||
m.Push(MESSAGE, ci.Message)
|
m.Push(MESSAGE, ci.Message)
|
||||||
}
|
}
|
||||||
@ -68,13 +68,13 @@ func _repos_commit(m *ice.Message, dir, branch string, cb func(*gogit.Commit, *g
|
|||||||
if ci, e := repos.LookupCommit(oid); !m.Warn(e, ice.ErrNotValid, oid.String()) {
|
if ci, e := repos.LookupCommit(oid); !m.Warn(e, ice.ErrNotValid, oid.String()) {
|
||||||
if cb == nil {
|
if cb == nil {
|
||||||
m.Push(mdb.TIME, ci.Author.When.Format(ice.MOD_TIME))
|
m.Push(mdb.TIME, ci.Author.When.Format(ice.MOD_TIME))
|
||||||
m.Push(COMMIT, ci.Oid.String()[:6])
|
m.Push(COMMIT, ci.Oid.Short())
|
||||||
m.Push(AUTHOR, ci.Author.Name)
|
m.Push(AUTHOR, ci.Author.Name)
|
||||||
m.Push(MESSAGE, ci.Message)
|
m.Push(MESSAGE, ci.Message)
|
||||||
} else if cb(ci, repos) {
|
} else if cb(ci, repos) {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
if p := ci.Parent(0); p != nil {
|
if p := ci.ParentCommit(0); p != nil {
|
||||||
oid = p.Oid
|
oid = p.Oid
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@ -97,47 +97,46 @@ func _repos_dir(m *ice.Message, dir, branch, commit, file string, cb func(*gogit
|
|||||||
if !strings.HasPrefix(ci.Oid.String(), commit) {
|
if !strings.HasPrefix(ci.Oid.String(), commit) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
list := ice.Maps{}
|
prev := ice.Maps{}
|
||||||
if p := ci.Parent(0); p != nil {
|
if p := ci.ParentCommit(0); p != nil {
|
||||||
if ci, e := repos.LookupCommit(p.Oid); e == nil {
|
if ci, e := repos.LookupCommit(p.Oid); e == nil {
|
||||||
if tree, e := repos.LookupTree(ci.TreeId()); !m.Warn(e, ice.ErrNotValid, ci.TreeId().String) {
|
if tree, e := repos.LookupTree(ci.TreeId()); !m.Warn(e, ice.ErrNotValid, ci.TreeId().String) {
|
||||||
tree.Walk(func(p string, v *gogit.TreeEntry) int {
|
tree.Walk(func(p string, v *gogit.TreeEntry) bool {
|
||||||
list[path.Join(p, v.Name)+kit.Select("", ice.PS, v.Type == gogit.ObjectTree)] = v.Id.String()
|
prev[path.Join(p, v.Name)+kit.Select("", ice.PS, v.Type == gogit.ObjectTree)] = v.Oid.String()
|
||||||
return 0
|
return false
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if tree, e := repos.LookupTree(ci.TreeId()); !m.Warn(e, ice.ErrNotValid, ci.TreeId().String) {
|
if tree, e := repos.LookupTree(ci.TreeId()); !m.Warn(e, ice.ErrNotValid, ci.TreeId().String) {
|
||||||
m.Logs(mdb.SELECT, REPOS, dir, BRANCH, branch, COMMIT, commit, "tree", tree.Oid.String()[:6])
|
m.Logs(mdb.SELECT, REPOS, dir, BRANCH, branch, COMMIT, commit, "tree", tree.Oid.Short())
|
||||||
tree.Walk(func(p string, v *gogit.TreeEntry) int {
|
tree.Walk(func(p string, v *gogit.TreeEntry) bool {
|
||||||
if strings.HasPrefix(path.Join(p, v.Name), file) {
|
if pp := path.Join(p, v.Name) + kit.Select("", ice.PS, v.Type == gogit.ObjectTree); strings.HasPrefix(pp, file) {
|
||||||
if cb == nil {
|
if cb == nil {
|
||||||
pp := path.Join(p, v.Name) + kit.Select("", ice.PS, v.Type == gogit.ObjectTree)
|
|
||||||
if v.Type == gogit.ObjectTree {
|
if v.Type == gogit.ObjectTree {
|
||||||
|
|
||||||
} else if id, ok := list[pp]; ok && id == v.Id.String() {
|
} else if id, ok := prev[pp]; ok && id == v.Oid.String() {
|
||||||
if m.Option("_index") == web.CODE_INNER {
|
if m.Option("_index") == web.CODE_INNER {
|
||||||
m.Push(mdb.HASH, v.Id.String()[:6]).Push(nfs.PATH, pp).Push(mdb.STATUS, "")
|
m.Push(mdb.HASH, v.Oid.Short()).Push(nfs.PATH, pp).Push(mdb.STATUS, "")
|
||||||
}
|
}
|
||||||
} else if ok {
|
} else if ok {
|
||||||
m.Push(mdb.HASH, v.Id.String()[:6]).Push(nfs.PATH, pp).Push(mdb.STATUS, "~~~")
|
m.Push(mdb.HASH, v.Oid.Short()).Push(nfs.PATH, pp).Push(mdb.STATUS, "~~~")
|
||||||
} else {
|
} else {
|
||||||
m.Push(mdb.HASH, v.Id.String()[:6]).Push(nfs.PATH, pp).Push(mdb.STATUS, "+++")
|
m.Push(mdb.HASH, v.Oid.Short()).Push(nfs.PATH, pp).Push(mdb.STATUS, "+++")
|
||||||
}
|
}
|
||||||
delete(list, pp)
|
delete(prev, pp)
|
||||||
} else if cb(v, repos) {
|
} else if cb(v, repos) {
|
||||||
return -1
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0
|
return false
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
kit.Fetch(list, func(pp, id string) { m.Push(mdb.HASH, id[:6]).Push(nfs.PATH, pp).Push(mdb.STATUS, "---") })
|
kit.Fetch(prev, func(pp, id string) { m.Push(mdb.HASH, id[:6]).Push(nfs.PATH, pp).Push(mdb.STATUS, "---") })
|
||||||
if m.Sort(kit.Fields(mdb.STATUS, nfs.PATH), ice.STR_R, ice.STR); cb == nil {
|
if m.Sort(kit.Fields(mdb.STATUS, nfs.PATH), ice.STR_R, ice.STR); cb == nil {
|
||||||
m.Option(cli.CMD_DIR, dir)
|
m.Option(cli.CMD_DIR, dir)
|
||||||
m.Echo(_git_cmds(m, DIFF, ci.Oid.String()+"^", ci.Oid.String()))
|
m.Echo(_git_cmds(m, DIFF, ci.Oid.String()+"^", ci.Oid.String()))
|
||||||
m.Status(mdb.TIME, ci.Author.When.Format(ice.MOD_TIME), "stat", _git_cmds(m, DIFF, "--shortstat", ci.Oid.String()+"^", ci.Oid.String()), "message", ci.Message)
|
m.Status(mdb.TIME, ci.Author.When.Format(ice.MOD_TIME), DIFF, _git_cmds(m, DIFF, "--shortstat", ci.Oid.String()+"^", ci.Oid.String()), MESSAGE, ci.Message)
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
})
|
})
|
||||||
@ -148,12 +147,12 @@ func _repos_cat(m *ice.Message, dir, branch, commit, file string) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
_repos_dir(m, dir, branch, commit, file, func(v *gogit.TreeEntry, repos *gogit.Repository) bool {
|
_repos_dir(m, dir, branch, commit, file, func(v *gogit.TreeEntry, repos *gogit.Repository) bool {
|
||||||
if blob, e := repos.LookupBlob(v.Id); e == nil {
|
if blob, e := repos.LookupBlob(v.Oid); e == nil {
|
||||||
m.Logs(mdb.IMPORT, REPOS, dir, BRANCH, branch, COMMIT, commit, "blob", v.Id.String()[:6])
|
m.Logs(mdb.IMPORT, REPOS, dir, BRANCH, branch, COMMIT, commit, "blob", v.Oid.Short())
|
||||||
m.Echo(string(blob.Contents()))
|
m.Echo(string(blob.Contents()))
|
||||||
} else {
|
} else {
|
||||||
m.Option(cli.CMD_DIR, dir)
|
m.Option(cli.CMD_DIR, dir)
|
||||||
m.Echo(_git_cmds(m, "cat-file", "-p", v.Id.String()))
|
m.Echo(_git_cmds(m, "cat-file", "-p", v.Oid.String()))
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
})
|
})
|
||||||
@ -162,13 +161,13 @@ func _repos_cat(m *ice.Message, dir, branch, commit, file string) {
|
|||||||
const (
|
const (
|
||||||
REFS_HEADS = "refs/heads/"
|
REFS_HEADS = "refs/heads/"
|
||||||
|
|
||||||
|
INIT = "init"
|
||||||
CONFIG = "config"
|
CONFIG = "config"
|
||||||
ORIGIN = "origin"
|
ORIGIN = "origin"
|
||||||
BRANCH = "branch"
|
BRANCH = "branch"
|
||||||
MASTER = "master"
|
MASTER = "master"
|
||||||
AUTHOR = "author"
|
AUTHOR = "author"
|
||||||
MESSAGE = "message"
|
MESSAGE = "message"
|
||||||
INIT = "init"
|
|
||||||
)
|
)
|
||||||
const REPOS = "repos"
|
const REPOS = "repos"
|
||||||
|
|
||||||
@ -190,6 +189,8 @@ func init() {
|
|||||||
m.Cmdy("", m.Option(REPOS), m.Option(BRANCH)).Cut("commit,author,message,time")
|
m.Cmdy("", m.Option(REPOS), m.Option(BRANCH)).Cut("commit,author,message,time")
|
||||||
case nfs.PATH:
|
case nfs.PATH:
|
||||||
m.Cmdy("", m.Option(REPOS), m.Option(BRANCH), m.Option(COMMIT)).Cut("path,hash,status")
|
m.Cmdy("", m.Option(REPOS), m.Option(BRANCH), m.Option(COMMIT)).Cut("path,hash,status")
|
||||||
|
default:
|
||||||
|
mdb.HashInputs(m, arg)
|
||||||
}
|
}
|
||||||
}},
|
}},
|
||||||
mdb.CREATE: {Name: "create origin name path", Hand: func(m *ice.Message, arg ...string) {
|
mdb.CREATE: {Name: "create origin name path", Hand: func(m *ice.Message, arg ...string) {
|
||||||
|
@ -104,7 +104,7 @@ func init() {
|
|||||||
return
|
return
|
||||||
} else if !nfs.ExistsFile(m, repos) {
|
} else if !nfs.ExistsFile(m, repos) {
|
||||||
m.Logs(mdb.CREATE, REPOS, repos)
|
m.Logs(mdb.CREATE, REPOS, repos)
|
||||||
_repos_init(m, path.Join(ice.USR_LOCAL_REPOS, repos))
|
_repos_init(m, repos)
|
||||||
}
|
}
|
||||||
case "upload-pack":
|
case "upload-pack":
|
||||||
if m.Warn(!nfs.ExistsFile(m, repos), ice.ErrNotFound, arg[0]) {
|
if m.Warn(!nfs.ExistsFile(m, repos), ice.ErrNotFound, arg[0]) {
|
||||||
@ -114,7 +114,7 @@ func init() {
|
|||||||
m.Warn(_server_repos(m, arg...), ice.ErrNotValid)
|
m.Warn(_server_repos(m, arg...), ice.ErrNotValid)
|
||||||
}}})
|
}}})
|
||||||
Index.MergeCommands(ice.Commands{
|
Index.MergeCommands(ice.Commands{
|
||||||
SERVER: {Name: "server path auto create import", Help: "服务器", Actions: ice.MergeActions(ice.Actions{
|
SERVER: {Name: "server path commit auto create import", Help: "服务器", Actions: ice.MergeActions(ice.Actions{
|
||||||
mdb.CREATE: {Name: "create name*", Hand: func(m *ice.Message, arg ...string) {
|
mdb.CREATE: {Name: "create name*", Hand: func(m *ice.Message, arg ...string) {
|
||||||
_repos_init(m, path.Join(ice.USR_LOCAL_REPOS, m.Option(mdb.NAME)))
|
_repos_init(m, path.Join(ice.USR_LOCAL_REPOS, m.Option(mdb.NAME)))
|
||||||
}},
|
}},
|
||||||
@ -133,9 +133,7 @@ func init() {
|
|||||||
web.DREAM_INPUTS: {Hand: func(m *ice.Message, arg ...string) {
|
web.DREAM_INPUTS: {Hand: func(m *ice.Message, arg ...string) {
|
||||||
switch arg[0] {
|
switch arg[0] {
|
||||||
case nfs.REPOS:
|
case nfs.REPOS:
|
||||||
m.Cmd("", func(value ice.Maps) {
|
m.Cmd("", func(value ice.Maps) { m.Push(nfs.PATH, _git_url(m, value[nfs.PATH])) })
|
||||||
m.Push(nfs.PATH, _git_url(m, value[nfs.PATH]))
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}},
|
}},
|
||||||
}, gdb.EventAction(web.DREAM_INPUTS)), Hand: func(m *ice.Message, arg ...string) {
|
}, gdb.EventAction(web.DREAM_INPUTS)), Hand: func(m *ice.Message, arg ...string) {
|
||||||
|
@ -22,7 +22,7 @@ func init() {
|
|||||||
SPIDE: {Name: "spide repos auto depend", Help: "构架图", Actions: ice.MergeActions(ice.Actions{
|
SPIDE: {Name: "spide repos auto depend", Help: "构架图", Actions: ice.MergeActions(ice.Actions{
|
||||||
"depend": {Name: "depend path*=icebergs/base pkg=shy,all", Help: "依赖", Hand: func(m *ice.Message, arg ...string) {
|
"depend": {Name: "depend path*=icebergs/base pkg=shy,all", Help: "依赖", Hand: func(m *ice.Message, arg ...string) {
|
||||||
list, keys := map[string]map[string]bool{}, map[string]bool{}
|
list, keys := map[string]map[string]bool{}, map[string]bool{}
|
||||||
kit.SplitKV(ice.TB, ice.NL, m.Cmdx(cli.SYSTEM, "gotags", "-R", path.Join(ice.USR, m.Option(nfs.PATH)) + ice.PS), func(text string, ls []string) {
|
kit.SplitKV(ice.TB, ice.NL, m.Cmdx(cli.SYSTEM, "gotags", "-R", path.Join(ice.USR, m.Option(nfs.PATH))+ice.PS), func(text string, ls []string) {
|
||||||
if strings.HasPrefix(text, "!_") {
|
if strings.HasPrefix(text, "!_") {
|
||||||
return
|
return
|
||||||
} else if kit.Select("", ls, 3) != "i" {
|
} else if kit.Select("", ls, 3) != "i" {
|
||||||
@ -52,7 +52,7 @@ func init() {
|
|||||||
m.Cmdy(REPOS)
|
m.Cmdy(REPOS)
|
||||||
} else if len(arg) == 1 {
|
} else if len(arg) == 1 {
|
||||||
color := []string{cli.YELLOW, cli.BLUE, cli.CYAN, cli.RED}
|
color := []string{cli.YELLOW, cli.BLUE, cli.CYAN, cli.RED}
|
||||||
ctx.DisplayStory(m, "spide.js", mdb.FIELD, nfs.PATH, aaa.ROOT, arg[0])
|
ctx.DisplayStory(m, "", mdb.FIELD, nfs.PATH, aaa.ROOT, arg[0])
|
||||||
nfs.DirDeepAll(m, _repos_path(arg[0]), "", func(value ice.Maps) {
|
nfs.DirDeepAll(m, _repos_path(arg[0]), "", func(value ice.Maps) {
|
||||||
m.Push(cli.COLOR, color[strings.Count(value[nfs.PATH], ice.PS)%len(color)])
|
m.Push(cli.COLOR, color[strings.Count(value[nfs.PATH], ice.PS)%len(color)])
|
||||||
m.Push("", value, []string{nfs.PATH})
|
m.Push("", value, []string{nfs.PATH})
|
||||||
|
@ -30,8 +30,9 @@ func _status_tag(m *ice.Message, tags string) string {
|
|||||||
return kit.Format("v%v.%v.0", ls[0], v+1)
|
return kit.Format("v%v.%v.0", ls[0], v+1)
|
||||||
} else if v := kit.Int(ls[0]); v < 9 {
|
} else if v := kit.Int(ls[0]); v < 9 {
|
||||||
return kit.Format("v%v.0.0", v+1)
|
return kit.Format("v%v.0.0", v+1)
|
||||||
|
} else {
|
||||||
|
return "v0.0.1"
|
||||||
}
|
}
|
||||||
return "v0.0.1"
|
|
||||||
}
|
}
|
||||||
func _status_tags(m *ice.Message) {
|
func _status_tags(m *ice.Message) {
|
||||||
vs := ice.Maps{}
|
vs := ice.Maps{}
|
||||||
@ -58,7 +59,7 @@ func _status_tags(m *ice.Message) {
|
|||||||
if len(ls) < 2 || !strings.Contains(ls[0], ice.PS) || !strings.Contains(ls[1], ice.PT) {
|
if len(ls) < 2 || !strings.Contains(ls[0], ice.PS) || !strings.Contains(ls[1], ice.PT) {
|
||||||
return text
|
return text
|
||||||
}
|
}
|
||||||
if v, ok := vs[kit.Slice(strings.Split(ls[0], ice.PS), -1)[0]]; ok && ls[1] != v {
|
if v, ok := vs[kit.Select("", strings.Split(ls[0], ice.PS), -1)]; ok && ls[1] != v {
|
||||||
m.Logs(mdb.MODIFY, REPOS, ls[0], "from", ls[1], "to", v)
|
m.Logs(mdb.MODIFY, REPOS, ls[0], "from", ls[1], "to", v)
|
||||||
text, change = strings.ReplaceAll(text, ls[1], v), true
|
text, change = strings.ReplaceAll(text, ls[1], v), true
|
||||||
}
|
}
|
||||||
@ -85,7 +86,7 @@ func _status_each(m *ice.Message, title string, cmds ...string) {
|
|||||||
ReposList(m).Tables(func(value ice.Maps) {
|
ReposList(m).Tables(func(value ice.Maps) {
|
||||||
toast(value[REPOS], count, total)
|
toast(value[REPOS], count, total)
|
||||||
if msg := m.Cmd(cmds, kit.Dict(cli.CMD_DIR, value[nfs.PATH])); !cli.IsSuccess(msg) {
|
if msg := m.Cmd(cmds, kit.Dict(cli.CMD_DIR, value[nfs.PATH])); !cli.IsSuccess(msg) {
|
||||||
web.Toast3s(m, msg.Append(cli.CMD_ERR), "error: "+value[REPOS]).Sleep3s()
|
web.Toast3s(m, msg.Append(cli.CMD_ERR)+msg.Append(cli.CMD_OUT), "error: "+value[REPOS]).Sleep3s()
|
||||||
list = append(list, value[REPOS])
|
list = append(list, value[REPOS])
|
||||||
}
|
}
|
||||||
count++
|
count++
|
||||||
@ -98,17 +99,17 @@ func _status_each(m *ice.Message, title string, cmds ...string) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
func _status_stat(m *ice.Message, files, adds, dels int) (int, int, int) {
|
func _status_stat(m *ice.Message, files, adds, dels int) (int, int, int) {
|
||||||
for _, v := range kit.Split(_git_cmds(m, DIFF, "--shortstat") , ice.FS, ice.FS) {
|
kit.SplitKV(ice.SP, ice.FS, _git_cmds(m, DIFF, "--shortstat"), func(text string, ls []string) {
|
||||||
n := kit.Int(kit.Split(strings.TrimSpace(v))[0])
|
n := kit.Int(ls[0])
|
||||||
switch {
|
switch {
|
||||||
case strings.Contains(v, "file"):
|
case strings.Contains(text, "file"):
|
||||||
files += n
|
files += n
|
||||||
case strings.Contains(v, "inser"):
|
case strings.Contains(text, "inser"):
|
||||||
adds += n
|
adds += n
|
||||||
case strings.Contains(v, "delet"):
|
case strings.Contains(text, "delet"):
|
||||||
dels += n
|
dels += n
|
||||||
}
|
}
|
||||||
}
|
})
|
||||||
return files, adds, dels
|
return files, adds, dels
|
||||||
}
|
}
|
||||||
func _status_list(m *ice.Message) (files, adds, dels int, last time.Time) {
|
func _status_list(m *ice.Message) (files, adds, dels int, last time.Time) {
|
||||||
@ -122,18 +123,14 @@ func _status_list(m *ice.Message) (files, adds, dels int, last time.Time) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
tags := kit.Format(mdb.Cache(m, m.PrefixKey(value[REPOS], TAGS), func() ice.Any { return _git_cmds(m, "describe", "--tags") }))
|
tags := kit.Format(mdb.Cache(m, m.PrefixKey(value[REPOS], TAGS), func() ice.Any { return _git_cmds(m, "describe", "--tags") }))
|
||||||
for _, v := range strings.Split(strings.TrimSpace(_git_cmds(m, STATUS, "-sb")), ice.NL) {
|
kit.SplitKV(ice.SP, ice.NL, _git_cmds(m, STATUS, "-sb"), func(text string, ls []string) {
|
||||||
if v == "" {
|
switch kit.Ext(ls[1]) {
|
||||||
continue
|
|
||||||
}
|
|
||||||
vs := strings.SplitN(strings.TrimSpace(v), ice.SP, 2)
|
|
||||||
switch kit.Ext(vs[1]) {
|
|
||||||
case "swp", "swo", ice.BIN, ice.VAR:
|
case "swp", "swo", ice.BIN, ice.VAR:
|
||||||
continue
|
return
|
||||||
}
|
}
|
||||||
switch m.Push(REPOS, value[REPOS]).Push(mdb.TYPE, vs[0]).Push(nfs.FILE, vs[1]); vs[0] {
|
switch m.Push(REPOS, value[REPOS]).Push(mdb.TYPE, ls[0]).Push(nfs.FILE, ls[1]); ls[0] {
|
||||||
case "##":
|
case "##":
|
||||||
if m.Push(TAGS, strings.TrimSpace(tags)); strings.Contains(vs[1], "ahead") || !strings.Contains(vs[1], "...") {
|
if m.Push(TAGS, tags); strings.Contains(ls[1], "ahead") || !strings.Contains(ls[1], "...") {
|
||||||
m.PushButton(PUSH)
|
m.PushButton(PUSH)
|
||||||
} else if tags == "" || strings.Contains(tags, "-") {
|
} else if tags == "" || strings.Contains(tags, "-") {
|
||||||
m.PushButton(TAG)
|
m.PushButton(TAG)
|
||||||
@ -141,13 +138,13 @@ func _status_list(m *ice.Message) (files, adds, dels int, last time.Time) {
|
|||||||
m.PushButton("")
|
m.PushButton("")
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
if m.Push(TAGS, ""); strings.Contains(vs[0], "??") {
|
if m.Push(TAGS, ""); strings.Contains(ls[0], "??") {
|
||||||
m.PushButton(ADD, nfs.TRASH)
|
m.PushButton(ADD, nfs.TRASH)
|
||||||
} else {
|
} else {
|
||||||
m.PushButton(COMMIT)
|
m.PushButton(COMMIT)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
})
|
||||||
})
|
})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -182,20 +179,16 @@ func init() {
|
|||||||
m.Push(mdb.TEXT, v)
|
m.Push(mdb.TEXT, v)
|
||||||
}
|
}
|
||||||
case VERSION, TAGS:
|
case VERSION, TAGS:
|
||||||
if m.Option(TAGS) == "" {
|
m.Push(VERSION, _status_tag(m, m.Option(TAGS)))
|
||||||
m.Push(VERSION, "v0.0.1")
|
|
||||||
} else {
|
|
||||||
m.Push(VERSION, _status_tag(m, m.Option(TAGS)))
|
|
||||||
}
|
|
||||||
case aaa.EMAIL:
|
case aaa.EMAIL:
|
||||||
m.Push(arg[0], _configs_get(m, "user.email"))
|
m.Push(arg[0], _configs_get(m, USER_EMAIL))
|
||||||
case aaa.USERNAME:
|
case aaa.USERNAME:
|
||||||
m.Push(arg[0], kit.Select(m.Option(ice.MSG_USERNAME), _configs_get(m, "user.name")))
|
m.Push(arg[0], kit.Select(m.Option(ice.MSG_USERNAME), _configs_get(m, USER_NAME)))
|
||||||
}
|
}
|
||||||
}},
|
}},
|
||||||
CONFIGS: {Name: "configs email username", Help: "配置", Hand: func(m *ice.Message, arg ...string) {
|
CONFIGS: {Name: "configs email username", Help: "配置", Hand: func(m *ice.Message, arg ...string) {
|
||||||
_configs_set(m, "user.name", m.Option(aaa.USERNAME))
|
_configs_set(m, USER_NAME, m.Option(aaa.USERNAME))
|
||||||
_configs_set(m, "user.email", m.Option(aaa.EMAIL))
|
_configs_set(m, USER_EMAIL, m.Option(aaa.EMAIL))
|
||||||
}},
|
}},
|
||||||
INIT: {Name: "init origin*='https://shylinux.com/x/volcanos' name path", Help: "克隆", Hand: func(m *ice.Message, arg ...string) {
|
INIT: {Name: "init origin*='https://shylinux.com/x/volcanos' name path", Help: "克隆", Hand: func(m *ice.Message, arg ...string) {
|
||||||
m.Cmdy(REPOS, mdb.CREATE)
|
m.Cmdy(REPOS, mdb.CREATE)
|
||||||
@ -220,10 +213,11 @@ func init() {
|
|||||||
_repos_cmd(m, m.Option(REPOS), ADD, m.Option(nfs.FILE))
|
_repos_cmd(m, m.Option(REPOS), ADD, m.Option(nfs.FILE))
|
||||||
}}, OPT: {Help: "优化"}, PRO: {Help: "升级"},
|
}}, OPT: {Help: "优化"}, PRO: {Help: "升级"},
|
||||||
COMMIT: {Name: "commit action=opt,add,pro comment=some", Help: "提交", Hand: func(m *ice.Message, arg ...string) {
|
COMMIT: {Name: "commit action=opt,add,pro comment=some", Help: "提交", Hand: func(m *ice.Message, arg ...string) {
|
||||||
_repos_cmd(m, m.Option(REPOS), COMMIT, "-am", m.Option("action")+ice.SP+m.Option(COMMENT))
|
_repos_cmd(m, m.Option(REPOS), COMMIT, "-am", m.Option(ctx.ACTION)+ice.SP+m.Option(COMMENT))
|
||||||
mdb.Cache(m, m.PrefixKey(m.Option(REPOS), TAGS), nil)
|
mdb.Cache(m, m.PrefixKey(m.Option(REPOS), TAGS), nil)
|
||||||
m.ProcessBack()
|
m.ProcessBack()
|
||||||
}},
|
}},
|
||||||
|
PIE: {Help: "饼图", Hand: func(m *ice.Message, arg ...string) { m.Cmdy(TOTAL, PIE) }},
|
||||||
TAG: {Name: "tag version", Help: "标签", Hand: func(m *ice.Message, arg ...string) {
|
TAG: {Name: "tag version", Help: "标签", Hand: func(m *ice.Message, arg ...string) {
|
||||||
if m.Option(VERSION) == "" {
|
if m.Option(VERSION) == "" {
|
||||||
m.Option(VERSION, _status_tag(m, m.Option(TAGS)))
|
m.Option(VERSION, _status_tag(m, m.Option(TAGS)))
|
||||||
@ -234,7 +228,6 @@ func init() {
|
|||||||
ctx.ProcessRefresh(m)
|
ctx.ProcessRefresh(m)
|
||||||
}},
|
}},
|
||||||
TAGS: {Help: "标签", Hand: func(m *ice.Message, arg ...string) { _status_tags(m) }},
|
TAGS: {Help: "标签", Hand: func(m *ice.Message, arg ...string) { _status_tags(m) }},
|
||||||
PIE: {Help: "饼图", Hand: func(m *ice.Message, arg ...string) { m.Cmdy(TOTAL, PIE) }},
|
|
||||||
STASH: {Help: "缓存", Hand: func(m *ice.Message, arg ...string) {
|
STASH: {Help: "缓存", Hand: func(m *ice.Message, arg ...string) {
|
||||||
if len(arg) == 0 && m.Option(REPOS) == "" {
|
if len(arg) == 0 && m.Option(REPOS) == "" {
|
||||||
_status_each(m, STASH, cli.SYSTEM, GIT, STASH)
|
_status_each(m, STASH, cli.SYSTEM, GIT, STASH)
|
||||||
@ -255,6 +248,7 @@ func init() {
|
|||||||
_repos_cmd(m, m.Option(REPOS), "checkout", m.Option(BRANCH))
|
_repos_cmd(m, m.Option(REPOS), "checkout", m.Option(BRANCH))
|
||||||
}},
|
}},
|
||||||
nfs.TRASH: {Hand: func(m *ice.Message, arg ...string) {
|
nfs.TRASH: {Hand: func(m *ice.Message, arg ...string) {
|
||||||
|
m.Assert(m.Option(REPOS) != "" && m.Option(nfs.FILE) != "")
|
||||||
nfs.Trash(m, path.Join(_repos_path(m.Option(REPOS)), m.Option(nfs.FILE)))
|
nfs.Trash(m, path.Join(_repos_path(m.Option(REPOS)), m.Option(nfs.FILE)))
|
||||||
}},
|
}},
|
||||||
code.COMPILE: {Help: "编译", Hand: func(m *ice.Message, arg ...string) {
|
code.COMPILE: {Help: "编译", Hand: func(m *ice.Message, arg ...string) {
|
||||||
@ -290,13 +284,14 @@ func init() {
|
|||||||
m.Push(mdb.TEXT, strings.Join(text, ", "))
|
m.Push(mdb.TEXT, strings.Join(text, ", "))
|
||||||
}},
|
}},
|
||||||
}, gdb.EventAction(web.DREAM_TABLES), ctx.CmdAction(), aaa.RoleAction()), Hand: func(m *ice.Message, arg ...string) {
|
}, gdb.EventAction(web.DREAM_TABLES), ctx.CmdAction(), aaa.RoleAction()), Hand: func(m *ice.Message, arg ...string) {
|
||||||
if _configs_get(m, "user.email") == "" {
|
if _configs_get(m, USER_EMAIL) == "" {
|
||||||
m.Echo("please config user.email").Action(CONFIGS)
|
m.Echo("please config user.email").Action(CONFIGS)
|
||||||
} else if len(arg) == 0 {
|
} else if len(arg) == 0 {
|
||||||
defer web.ToastProcess(m)()
|
defer web.ToastProcess(m)()
|
||||||
files, adds, dels, last := _status_list(m)
|
files, adds, dels, last := _status_list(m)
|
||||||
m.StatusTimeCount("files", files, "adds", adds, "dels", dels, "last", last.Format(ice.MOD_TIME))
|
m.StatusTimeCount("files", files, "adds", adds, "dels", dels, "last", last.Format(ice.MOD_TIME))
|
||||||
m.Action(PULL, PUSH, TAGS, PIE, code.COMPILE, code.PUBLISH)
|
m.Action(PULL, PUSH, TAGS, PIE, code.COMPILE, code.PUBLISH)
|
||||||
|
m.Sort("repos,type,file")
|
||||||
} else {
|
} else {
|
||||||
_repos_cmd(m, arg[0], DIFF)
|
_repos_cmd(m, arg[0], DIFF)
|
||||||
files, adds, dels := _status_stat(m, 0, 0, 0)
|
files, adds, dels := _status_stat(m, 0, 0, 0)
|
||||||
|
@ -20,10 +20,10 @@ func init() {
|
|||||||
const (
|
const (
|
||||||
FROM = "from"
|
FROM = "from"
|
||||||
DAYS = "days"
|
DAYS = "days"
|
||||||
COMMIT = "commit"
|
|
||||||
ADDS = "adds"
|
ADDS = "adds"
|
||||||
DELS = "dels"
|
DELS = "dels"
|
||||||
REST = "rest"
|
REST = "rest"
|
||||||
|
COMMIT = "commit"
|
||||||
)
|
)
|
||||||
Index.MergeCommands(ice.Commands{
|
Index.MergeCommands(ice.Commands{
|
||||||
TOTAL: {Name: "total repos auto pie", Help: "统计量", Actions: ice.MergeActions(ice.Actions{
|
TOTAL: {Name: "total repos auto pie", Help: "统计量", Actions: ice.MergeActions(ice.Actions{
|
||||||
@ -31,7 +31,7 @@ func init() {
|
|||||||
defer ctx.DisplayStory(m, "pie.js")
|
defer ctx.DisplayStory(m, "pie.js")
|
||||||
m.Cmd("", func(value ice.Maps) {
|
m.Cmd("", func(value ice.Maps) {
|
||||||
if value[REPOS] != mdb.TOTAL {
|
if value[REPOS] != mdb.TOTAL {
|
||||||
m.Push(REPOS, value[REPOS]).Push(mdb.VALUE, value[REST]).Push("", value, []string{FROM, DAYS, COMMIT, ADDS, DELS})
|
m.Push(REPOS, value[REPOS]).Push(mdb.VALUE, value[REST]).Push("", value, []string{FROM, DAYS, ADDS, DELS, COMMIT})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}},
|
}},
|
||||||
@ -40,10 +40,10 @@ func init() {
|
|||||||
ReposList(m).Tables(func(value ice.Maps) {
|
ReposList(m).Tables(func(value ice.Maps) {
|
||||||
kit.If(value[REPOS] == arg[0], func() { m.Cmdy("_sum", value[nfs.PATH], arg[1:]) })
|
kit.If(value[REPOS] == arg[0], func() { m.Cmdy("_sum", value[nfs.PATH], arg[1:]) })
|
||||||
})
|
})
|
||||||
m.StatusTimeCount(FROM, m.Append(FROM))
|
m.StatusTimeCount(m.AppendSimple(FROM))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
from, days, commit, adds, dels, rest := "", 0, 0, 0, 0, 0
|
from, days, adds, dels, rest, commit := "", 0, 0, 0, 0, 0
|
||||||
ReposList(m).TableGo(func(value ice.Maps, lock *task.Lock) {
|
ReposList(m).TableGo(func(value ice.Maps, lock *task.Lock) {
|
||||||
if m.Config(kit.Keys("skip", value[REPOS])) == ice.TRUE {
|
if m.Config(kit.Keys("skip", value[REPOS])) == ice.TRUE {
|
||||||
return
|
return
|
||||||
@ -54,19 +54,19 @@ func init() {
|
|||||||
if kit.Int(value[DAYS]) > days {
|
if kit.Int(value[DAYS]) > days {
|
||||||
from, days = value[FROM], kit.Int(value[DAYS])
|
from, days = value[FROM], kit.Int(value[DAYS])
|
||||||
}
|
}
|
||||||
commit += kit.Int(value[COMMIT])
|
|
||||||
adds += kit.Int(value[ADDS])
|
adds += kit.Int(value[ADDS])
|
||||||
dels += kit.Int(value[DELS])
|
dels += kit.Int(value[DELS])
|
||||||
rest += kit.Int(value[REST])
|
rest += kit.Int(value[REST])
|
||||||
|
commit += kit.Int(value[COMMIT])
|
||||||
})
|
})
|
||||||
m.Push(REPOS, value[REPOS]).Copy(msg)
|
m.Push(REPOS, value[REPOS]).Copy(msg)
|
||||||
})
|
})
|
||||||
m.Push(REPOS, mdb.TOTAL).Push(TAGS, "v3.0.0").Push(FROM, from).Push(DAYS, days).Push(COMMIT, commit).Push(ADDS, adds).Push(DELS, dels).Push(REST, rest)
|
m.Push(REPOS, mdb.TOTAL).Push(TAGS, "v3.0.0").Push(FROM, from).Push(DAYS, days).Push(ADDS, adds).Push(DELS, dels).Push(REST, rest).Push(COMMIT, commit)
|
||||||
m.StatusTimeCount().SortIntR(REST)
|
m.StatusTimeCount().SortIntR(REST)
|
||||||
}},
|
}},
|
||||||
"_sum": {Name: "_sum [path] [total] [count|date] args...", Help: "统计量", Hand: func(m *ice.Message, arg ...string) {
|
"_sum": {Name: "_sum [path] [total] [count|date] args...", Help: "统计量", Hand: func(m *ice.Message, arg ...string) {
|
||||||
if len(arg) > 0 {
|
if len(arg) > 0 {
|
||||||
if nfs.ExistsFile(m, _git_dir(arg[0])) || nfs.ExistsFile(m, path.Join(arg[0], "refs/heads")) {
|
if nfs.ExistsFile(m, _git_dir(arg[0])) || nfs.ExistsFile(m, path.Join(arg[0], REFS_HEADS)) {
|
||||||
m.Option(cli.CMD_DIR, arg[0])
|
m.Option(cli.CMD_DIR, arg[0])
|
||||||
arg = arg[1:]
|
arg = arg[1:]
|
||||||
}
|
}
|
||||||
@ -83,12 +83,9 @@ func init() {
|
|||||||
} else {
|
} else {
|
||||||
args = append(args, "-n", "30")
|
args = append(args, "-n", "30")
|
||||||
}
|
}
|
||||||
from, days, commit, adds, dels := "", time.Second, 0, 0, 0
|
from, days, adds, dels, commit := "", 0, 0, 0, 0
|
||||||
for i, v := range strings.Split(_git_cmds(m, args...), "commit: ") {
|
kit.SplitKV(ice.NL, "commit:", _git_cmds(m, args...), func(text string, ls []string) {
|
||||||
ls := strings.Split(strings.TrimSpace(v), ice.NL)
|
m.Debug("what %v %v", text, ls)
|
||||||
if len(ls) < 2 {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
add, del := "0", "0"
|
add, del := "0", "0"
|
||||||
for _, v := range kit.Split(strings.TrimSpace(kit.Select("", ls, -1)), ice.FS) {
|
for _, v := range kit.Split(strings.TrimSpace(kit.Select("", ls, -1)), ice.FS) {
|
||||||
switch {
|
switch {
|
||||||
@ -98,31 +95,31 @@ func init() {
|
|||||||
del = kit.Split(v)[0]
|
del = kit.Split(v)[0]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
hs := strings.Split(ls[0], ice.SP)
|
|
||||||
if total {
|
if total {
|
||||||
if commit++; i == 1 {
|
if commit++; from == "" {
|
||||||
|
hs := strings.Split(ls[0], ice.SP)
|
||||||
if t, e := time.Parse("2006-01-02", hs[0]); e == nil {
|
if t, e := time.Parse("2006-01-02", hs[0]); e == nil {
|
||||||
from, days = hs[0], time.Now().Sub(t)
|
from, days = hs[0], int(time.Now().Sub(t).Hours())/24
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
adds += kit.Int(add)
|
adds += kit.Int(add)
|
||||||
dels += kit.Int(del)
|
dels += kit.Int(del)
|
||||||
continue
|
return
|
||||||
}
|
}
|
||||||
m.Push(FROM, ls[0])
|
m.Push(FROM, ls[0])
|
||||||
m.Push(ADDS, add)
|
m.Push(ADDS, add)
|
||||||
m.Push(DELS, del)
|
m.Push(DELS, del)
|
||||||
m.Push(REST, kit.Int(add)-kit.Int(del))
|
m.Push(REST, kit.Int(add)-kit.Int(del))
|
||||||
m.Push(COMMIT, ls[1])
|
m.Push(COMMIT, ls[1])
|
||||||
}
|
})
|
||||||
if total {
|
if total {
|
||||||
m.Push(TAGS, _git_cmds(m, "describe", "--tags"))
|
m.Push(TAGS, _git_cmds(m, "describe", "--tags"))
|
||||||
m.Push(FROM, from)
|
m.Push(FROM, from)
|
||||||
m.Push(DAYS, int(days.Hours())/24)
|
m.Push(DAYS, days)
|
||||||
m.Push(COMMIT, commit)
|
|
||||||
m.Push(ADDS, adds)
|
m.Push(ADDS, adds)
|
||||||
m.Push(DELS, dels)
|
m.Push(DELS, dels)
|
||||||
m.Push(REST, adds-dels)
|
m.Push(REST, adds-dels)
|
||||||
|
m.Push(COMMIT, commit)
|
||||||
}
|
}
|
||||||
}},
|
}},
|
||||||
})
|
})
|
||||||
|
@ -1,18 +1,16 @@
|
|||||||
git
|
git
|
||||||
tmux
|
|
||||||
bash
|
|
||||||
vim
|
|
||||||
ssh
|
ssh
|
||||||
|
vim
|
||||||
|
bash
|
||||||
|
tmux
|
||||||
mp
|
mp
|
||||||
wx
|
wx
|
||||||
lark
|
lark
|
||||||
wework
|
wework
|
||||||
webview
|
webview
|
||||||
chrome
|
chrome
|
||||||
coder
|
|
||||||
input
|
|
||||||
alpha
|
alpha
|
||||||
|
input
|
||||||
|
coder
|
||||||
java
|
java
|
||||||
node
|
node
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user