1
0
mirror of https://shylinux.com/x/icebergs synced 2025-05-02 03:29:25 +08:00
This commit is contained in:
harveyshao 2021-05-08 21:48:38 +08:00
parent 6e20674f86
commit 578d0067bf
2 changed files with 15 additions and 7 deletions

View File

@ -1,7 +1,6 @@
package git package git
import ( import (
"os"
"path" "path"
"strings" "strings"
@ -25,6 +24,11 @@ func _spide_for(text string, cb func([]string)) {
func _spide_go(m *ice.Message, file string) { func _spide_go(m *ice.Message, file string) {
_spide_for(m.Cmdx(cli.SYSTEM, "gotags", file), func(ls []string) { _spide_for(m.Cmdx(cli.SYSTEM, "gotags", file), func(ls []string) {
switch ls[3] { switch ls[3] {
case "i":
return
case "w", "e":
return
ls[0] = "-" + ls[0] + ":" + strings.TrimPrefix(ls[len(ls)-1], "type:")
case "m": case "m":
if strings.HasPrefix(ls[5], "ctype") { if strings.HasPrefix(ls[5], "ctype") {
ls[0] = strings.TrimPrefix(ls[5], "ctype:") + ":" + ls[0] ls[0] = strings.TrimPrefix(ls[5], "ctype:") + ":" + ls[0]
@ -33,8 +37,6 @@ func _spide_go(m *ice.Message, file string) {
} else { } else {
ls[0] = ls[3] + ":" + ls[0] ls[0] = ls[3] + ":" + ls[0]
} }
case "w":
ls[0] = "-" + ls[0] + ":" + strings.TrimPrefix(ls[len(ls)-1], "type:")
default: default:
ls[0] = ls[3] + ":" + ls[0] ls[0] = ls[3] + ":" + ls[0]
} }
@ -69,7 +71,7 @@ func init() {
return return
} }
if wd, _ := os.Getwd(); arg[0] == path.Base(wd) { if arg[0] == path.Base(kit.Pwd()) {
m.Option(nfs.DIR_ROOT, path.Join(kit.SSH_SRC)) m.Option(nfs.DIR_ROOT, path.Join(kit.SSH_SRC))
} else { } else {
m.Option(nfs.DIR_ROOT, path.Join(kit.SSH_USR, arg[0])) m.Option(nfs.DIR_ROOT, path.Join(kit.SSH_USR, arg[0]))
@ -78,6 +80,7 @@ func init() {
if len(arg) == 1 { // 目录列表 if len(arg) == 1 { // 目录列表
m.Option(nfs.DIR_DEEP, "true") m.Option(nfs.DIR_DEEP, "true")
nfs.Dir(m, kit.MDB_PATH) nfs.Dir(m, kit.MDB_PATH)
color := []string{"yellow", "blue", "cyan", "red"} color := []string{"yellow", "blue", "cyan", "red"}
m.Table(func(index int, value map[string]string, head []string) { m.Table(func(index int, value map[string]string, head []string) {
m.Push(kit.MDB_COLOR, color[strings.Count(value[kit.MDB_PATH], "/")%len(color)]) m.Push(kit.MDB_COLOR, color[strings.Count(value[kit.MDB_PATH], "/")%len(color)])

View File

@ -2,6 +2,7 @@ package git
import ( import (
"strings" "strings"
"time"
ice "github.com/shylinux/icebergs" ice "github.com/shylinux/icebergs"
"github.com/shylinux/icebergs/base/cli" "github.com/shylinux/icebergs/base/cli"
@ -49,7 +50,7 @@ func _status_stat(m *ice.Message, files, adds, dels int) (int, int, int) {
} }
return files, adds, dels return files, adds, dels
} }
func _status_list(m *ice.Message) (files, adds, dels int) { func _status_list(m *ice.Message) (files, adds, dels int, last time.Time) {
m.Cmd(REPOS, ice.OptionFields("name,path")).Table(func(index int, value map[string]string, head []string) { m.Cmd(REPOS, ice.OptionFields("name,path")).Table(func(index int, value map[string]string, head []string) {
m.Option(cli.CMD_DIR, value[kit.MDB_PATH]) m.Option(cli.CMD_DIR, value[kit.MDB_PATH])
diff := m.Cmdx(cli.SYSTEM, GIT, STATUS, "-sb") diff := m.Cmdx(cli.SYSTEM, GIT, STATUS, "-sb")
@ -77,6 +78,10 @@ func _status_list(m *ice.Message) (files, adds, dels int) {
} }
files, adds, dels = _status_stat(m, files, adds, dels) files, adds, dels = _status_stat(m, files, adds, dels)
now, _ := time.Parse("2006-01-02 15:04:05 -0700", strings.TrimSpace(m.Cmdx(cli.SYSTEM, GIT, "log", `--pretty=%cd`, "--date=iso", "-n1")))
if now.After(last) {
last = now
}
}) })
return return
} }
@ -135,8 +140,8 @@ func init() {
if len(arg) == 0 { if len(arg) == 0 {
m.Action(PULL, MAKE, PUSH) m.Action(PULL, MAKE, PUSH)
files, adds, dels := _status_list(m) files, adds, dels, last := _status_list(m)
m.Status("files", files, "adds", adds, "dels", dels) m.Status("files", files, "adds", adds, "dels", dels, "last", last.Format(ice.MOD_TIME))
m.Toast(kit.Format("files: %d, adds: %d, dels: %d", files, adds, dels), ice.CONTEXTS, "3s") m.Toast(kit.Format("files: %d, adds: %d, dels: %d", files, adds, dels), ice.CONTEXTS, "3s")
return return
} }