forked from x/icebergs
opt some
This commit is contained in:
parent
3283cbc479
commit
fadc244701
@ -118,7 +118,7 @@ func _dir_list(m *ice.Message, root string, dir string, level int, deep bool, di
|
||||
}
|
||||
if deep && isDir {
|
||||
switch s.Name() {
|
||||
case "node_modules", "pluged":
|
||||
case "pluged":
|
||||
continue
|
||||
}
|
||||
_dir_list(m, root, pp, level+1, deep, dir_type, dir_reg, fields)
|
||||
|
@ -10,6 +10,7 @@ import (
|
||||
|
||||
ice "shylinux.com/x/icebergs"
|
||||
"shylinux.com/x/icebergs/base/ctx"
|
||||
"shylinux.com/x/icebergs/base/log"
|
||||
"shylinux.com/x/icebergs/base/mdb"
|
||||
"shylinux.com/x/icebergs/base/nfs"
|
||||
"shylinux.com/x/icebergs/base/tcp"
|
||||
@ -137,11 +138,16 @@ func RenderPodCmd(m *ice.Message, pod, cmd string, arg ...ice.Any) {
|
||||
))
|
||||
}
|
||||
func RenderCmd(m *ice.Message, cmd string, arg ...ice.Any) { RenderPodCmd(m, "", cmd, arg...) }
|
||||
|
||||
func RenderVersion(m *ice.Message) string {
|
||||
if ice.Info.Make.Hash == "" {
|
||||
return ""
|
||||
}
|
||||
return kit.Format("?_v=%s-%s", ice.Info.Make.Version, ice.Info.Make.Hash[:6])
|
||||
ls := []string{ice.Info.Make.Version, ice.Info.Make.Forword, ice.Info.Make.Hash[:6]}
|
||||
if m.Option(log.DEBUG) == ice.TRUE || m.R != nil && strings.Contains(m.R.URL.RawQuery, "debug=true") {
|
||||
ls = append(ls, kit.Format("%d", time.Now().Unix()-kit.Time(ice.Info.Make.When)/int64(time.Second)))
|
||||
}
|
||||
return "?_v=" + strings.Join(ls, "-")
|
||||
}
|
||||
|
||||
const (
|
||||
|
@ -83,6 +83,7 @@ func _autogen_git(m *ice.Message, arg ...string) ice.Map {
|
||||
mdb.TIME, m.Time(), nfs.PATH, kit.Path("")+nfs.PS, web.DOMAIN, tcp.PublishLocalhost(m, m.Option(ice.MSG_USERWEB)),
|
||||
mdb.HASH, msg.Append(mdb.HASH), nfs.REMOTE, msg.Append(nfs.REMOTE), nfs.BRANCH, msg.Append(nfs.BRANCH), nfs.VERSION, msg.Append(nfs.VERSION),
|
||||
aaa.EMAIL, msg.Append(aaa.EMAIL), aaa.USERNAME, msg.Append(aaa.USERNAME),
|
||||
msg.AppendSimple("when,message,forword"),
|
||||
)
|
||||
}
|
||||
func _autogen_mod(m *ice.Message, file string) (mod string) {
|
||||
|
@ -20,7 +20,7 @@ func _binpack_file(m *ice.Message, w io.Writer, arg ...string) {
|
||||
if kit.IsIn(kit.Ext(arg[0]), "zip", "gz") {
|
||||
return
|
||||
}
|
||||
if kit.Contains(arg[0], "/node_modules/", "/dist/", "/bin/", "/log/") {
|
||||
if kit.Contains(arg[0], "/dist/", "/bin/", "/log/") {
|
||||
return
|
||||
}
|
||||
if strings.HasPrefix(arg[0], "usr/volcanos/publish/") && !strings.HasSuffix(arg[0], "/proto.js") {
|
||||
|
3
info.go
3
info.go
@ -21,6 +21,9 @@ type MakeInfo struct {
|
||||
Hostname string
|
||||
Username string
|
||||
Email string
|
||||
When string
|
||||
Message string
|
||||
Forword string
|
||||
}
|
||||
|
||||
var Info = struct {
|
||||
|
@ -17,9 +17,9 @@ type field struct {
|
||||
list string `name:"list domain id auto insert" help:"插件"`
|
||||
}
|
||||
|
||||
func (s field) Inputs(m *ice.Message, arg ...string) {
|
||||
s.daemon.Inputs(m, arg...)
|
||||
}
|
||||
func (s field) Init(m *ice.Message, arg ...string) { s.Zone.Imports(m) }
|
||||
func (s field) Exit(m *ice.Message, arg ...string) { s.Zone.Exports(m) }
|
||||
func (s field) Inputs(m *ice.Message, arg ...string) { s.daemon.Inputs(m, arg...) }
|
||||
func (s field) Command(m *ice.Message, arg ...string) {
|
||||
s.Zone.List(m.Spawn(), kit.Simple(m.Option(web.DOMAIN), arg)...).Table(func(index int, value ice.Maps, head []string) {
|
||||
if len(arg) == 0 {
|
||||
@ -36,7 +36,6 @@ func (s field) Run(m *ice.Message, arg ...string) {
|
||||
m.Cmdy(value[mdb.INDEX], arg[1:])
|
||||
})
|
||||
}
|
||||
func (s field) List(m *ice.Message, arg ...string) {
|
||||
s.Zone.List(m, arg...)
|
||||
}
|
||||
func (s field) List(m *ice.Message, arg ...string) { s.Zone.List(m, arg...) }
|
||||
|
||||
func init() { ice.CodeCtxCmd(field{}) }
|
||||
|
@ -49,6 +49,24 @@ func _repos_recent(m *ice.Message, repos *git.Repository) (r *plumbing.Reference
|
||||
}
|
||||
return
|
||||
}
|
||||
func _repos_forword(m *ice.Message, repos *git.Repository, version string) int {
|
||||
if refer, err := repos.Head(); err == nil {
|
||||
if commit, err := repos.CommitObject(refer.Hash()); err == nil {
|
||||
n := 0
|
||||
for {
|
||||
if commit.Hash.String() == version {
|
||||
break
|
||||
}
|
||||
if commit, err = commit.Parent(0); err != nil || commit == nil {
|
||||
break
|
||||
}
|
||||
n++
|
||||
}
|
||||
return n
|
||||
}
|
||||
}
|
||||
return 0
|
||||
}
|
||||
func _repos_insert(m *ice.Message, p string) {
|
||||
if repos, err := git.PlainOpen(p); err == nil {
|
||||
args := []string{REPOS, path.Base(p), nfs.PATH, p}
|
||||
@ -59,7 +77,11 @@ func _repos_insert(m *ice.Message, p string) {
|
||||
}
|
||||
}
|
||||
if refer := _repos_recent(m, repos); refer != nil {
|
||||
args = append(args, VERSION, refer.Name().Short())
|
||||
if n := _repos_forword(m, repos, refer.Hash().String()); n > 0 {
|
||||
args = append(args, VERSION, kit.Format("%s-%d", refer.Name().Short(), n))
|
||||
} else {
|
||||
args = append(args, VERSION, refer.Name().Short())
|
||||
}
|
||||
}
|
||||
if remote, err := repos.Remote("origin"); err == nil {
|
||||
args = append(args, ORIGIN, remote.Config().URLs[0])
|
||||
@ -507,16 +529,21 @@ func init() {
|
||||
if _remote, err := repos.Remote(ORIGIN); err == nil {
|
||||
m.Push(REMOTE, kit.Select("", _remote.Config().URLs, 0))
|
||||
}
|
||||
version := ""
|
||||
if refer := _repos_recent(m, repos); refer != nil {
|
||||
m.Push(nfs.VERSION, refer.Name().Short())
|
||||
version = refer.Hash().String()
|
||||
}
|
||||
if refer, err := repos.Head(); err == nil {
|
||||
m.Push(BRANCH, refer.Name().Short())
|
||||
m.Push(mdb.HASH, refer.Hash().String())
|
||||
}
|
||||
if refer := _repos_recent(m, repos); refer != nil {
|
||||
m.Push(nfs.VERSION, refer.Name().Short())
|
||||
}
|
||||
if cfg, err := config.LoadConfig(config.GlobalScope); err == nil {
|
||||
m.Push(aaa.EMAIL, kit.Select(m.Option(ice.MSG_USERNAME)+"@163.com", cfg.User.Email))
|
||||
m.Push(aaa.USERNAME, kit.Select(m.Option(ice.MSG_USERNAME), cfg.User.Name))
|
||||
if commit, err := repos.CommitObject(refer.Hash()); err == nil {
|
||||
m.Push(aaa.USERNAME, commit.Author.Name)
|
||||
m.Push(aaa.EMAIL, commit.Author.Email)
|
||||
m.Push("when", commit.Author.When)
|
||||
m.Push("message", commit.Message)
|
||||
m.Push("forword", _repos_forword(m, repos, version))
|
||||
}
|
||||
}
|
||||
}},
|
||||
TOTAL: {Hand: func(m *ice.Message, arg ...string) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user