diff --git a/base/web/space.go b/base/web/space.go index 751648d4..78837e7d 100644 --- a/base/web/space.go +++ b/base/web/space.go @@ -378,7 +378,7 @@ func init() { }) m.Sort("", kit.Simple(aaa.LOGIN, WEIXIN, PORTAL, WORKER, SERVER, ORIGIN)) } else { - if arg[0] == "" { + if kit.IsIn(arg[0], "", ice.CONTEXTS) { m.Cmdy(arg[1:]) return } diff --git a/core/code/version.go b/core/code/version.go index b4de0789..44b5a014 100644 --- a/core/code/version.go +++ b/core/code/version.go @@ -29,10 +29,12 @@ func init() { }}, "sync": {Help: "同步", Hand: func(m *ice.Message, arg ...string) { repos := map[string]string{} + m.Cmds("web.code.git.repos").Table(func(value ice.Maps) { repos[strings.Split(value[web.ORIGIN], "://")[1]] = value[nfs.VERSION] }) m.Cmd("web.code.mod", mdb.RENDER, MOD, ice.GO_MOD, nfs.PWD).Table(func(value ice.Maps) { repos[value[REQUIRE]] = value[VERSION] }) res := m.Cmdx(nfs.CAT, path.Join(nfs.USR_LOCAL_WORK, m.Option(SPACE), ice.GO_MOD), func(ls []string, text string) string { - if len(ls) == 2 { + if len(ls) > 1 { if v, ok := repos[ls[0]]; ok { + m.Debug("what %v %v => %v", ls[0], ls[1], repos[ls[0]]) text = lex.TB + ls[0] + lex.SP + v } } @@ -41,15 +43,22 @@ func init() { m.Cmd(nfs.SAVE, path.Join(nfs.USR_LOCAL_WORK, m.Option(SPACE), ice.GO_MOD), res) m.Cmd(SPACE, m.Option(SPACE), cli.SYSTEM, GO, MOD, "tidy") }}, - "add": {Name: "add version", Hand: func(m *ice.Message, arg ...string) { + "tag": {Name: "tag version", Hand: func(m *ice.Message, arg ...string) { m.Cmd(SPACE, m.Option(SPACE), cli.SYSTEM, GIT, TAG, m.Option(VERSION)) m.Cmd(SPACE, m.Option(SPACE), VIMER, COMPILE) m.Sleep3s() }}, + "xterm": {Hand: func(m *ice.Message, arg ...string) { + web.ProcessPodCmd(m, m.Option(web.SPACE), m.ActionKey(), cli.SH, arg...) + }}, + "status": {Hand: func(m *ice.Message, arg ...string) { + web.ProcessPodCmd(m, m.Option(web.SPACE), m.ActionKey(), nil, arg...) + }}, }), Hand: func(m *ice.Message, arg ...string) { repos := map[string]string{} list := map[string]map[string]string{} list[ice.Info.Pathname] = map[string]string{} + m.Cmds("web.code.git.repos").Table(func(value ice.Maps) { repos[strings.Split(value[web.ORIGIN], "://")[1]] = value[nfs.VERSION] }) m.Cmd("web.code.mod", mdb.RENDER, MOD, ice.GO_MOD, nfs.PWD).Table(func(value ice.Maps) { list[ice.Info.Pathname][value[REQUIRE]] = value[VERSION] if value[REPLACE] == nfs.PWD { @@ -74,24 +83,46 @@ func init() { for space, v := range list { diff := false m.Push(web.SPACE, space) - m.Push(MODULE, list[space][MODULE]) - m.Push(VERSION, list[space][VERSION]) + m.Push(MODULE, v[MODULE]) + m.Push(VERSION, v[VERSION]) kit.For(repos, func(k, _v string) { - m.Push(k, v[k]) - kit.If(v[k] != "" && v[k] != _v, func() { diff = true }) - }) - m.Push("diff", list[space]["diff"]) - if diff { - m.Push(mdb.STATUS, html.DANGER).PushButton("sync", "add") - } else { - if strings.Contains(list[space][VERSION], "-") { - m.Push(mdb.STATUS, "").PushButton("add") - } else { - m.Push(mdb.STATUS, "").PushButton("") + if kit.IsIn(k, + "shylinux.com/x/go-qrcode", + "shylinux.com/x/websocket", + ) { + return } + if k == v[MODULE] || v[k] == "" { + m.Push(k, "") + } else if v[k] == _v { + m.Push(k, v[k]) + } else { + m.Push(k, v[k]+" => "+_v) + diff = true + } + }) + button, status := []ice.Any{}, "" + if diff { + button, status = append(button, "sync"), html.DANGER + } + if list[space]["diff"] != "" { + button = append(button, "status") + } + if strings.Contains(list[space][VERSION], "-") { + button = append(button, "tag") + } + if len(button) > 0 { + button = append(button, "xterm") + } + m.Push("diff", list[space]["diff"]).Push(mdb.STATUS, status).PushButton(button...) + } + fields := []string{} + for _, k := range m.Appendv(ice.MSG_APPEND) { + if len(kit.TrimArg(m.Appendv(k)...)) > 0 { + fields = append(fields, k) } } - m.Sort(web.SPACE, ice.STR_R) + m.Cut(fields...).Sort(web.SPACE, ice.STR_R) }}, }) diff --git a/misc/git/repos.go b/misc/git/repos.go index a6eeabcf..8cc2b0b3 100644 --- a/misc/git/repos.go +++ b/misc/git/repos.go @@ -613,6 +613,10 @@ func init() { } }}, TAG: {Name: "tag version", Hand: func(m *ice.Message, arg ...string) { + m.Option(cli.CMD_DIR, _repos_path(m, m.Option(nfs.REPOS))) + _git_cmd(m, "tag", m.Option(VERSION)) + _repos_insert(m.Spawn(), m.Option(cli.CMD_DIR)) + return repos := _repos_open(m, m.Option(REPOS)) if refer, err := repos.Head(); !m.Warn(err) { kit.If(m.Option(VERSION) == "", func() { m.Option(VERSION, _repos_tag(m, m.Option(TAGS))) })