1
0
mirror of https://shylinux.com/x/icebergs synced 2025-04-25 17:18:05 +08:00
This commit is contained in:
IT 老营长 @云轩领航-创始人 2023-07-12 22:47:19 +08:00
parent 3283cbc479
commit fadc244701
7 changed files with 53 additions and 17 deletions

View File

@ -118,7 +118,7 @@ func _dir_list(m *ice.Message, root string, dir string, level int, deep bool, di
} }
if deep && isDir { if deep && isDir {
switch s.Name() { switch s.Name() {
case "node_modules", "pluged": case "pluged":
continue continue
} }
_dir_list(m, root, pp, level+1, deep, dir_type, dir_reg, fields) _dir_list(m, root, pp, level+1, deep, dir_type, dir_reg, fields)

View File

@ -10,6 +10,7 @@ import (
ice "shylinux.com/x/icebergs" ice "shylinux.com/x/icebergs"
"shylinux.com/x/icebergs/base/ctx" "shylinux.com/x/icebergs/base/ctx"
"shylinux.com/x/icebergs/base/log"
"shylinux.com/x/icebergs/base/mdb" "shylinux.com/x/icebergs/base/mdb"
"shylinux.com/x/icebergs/base/nfs" "shylinux.com/x/icebergs/base/nfs"
"shylinux.com/x/icebergs/base/tcp" "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 RenderCmd(m *ice.Message, cmd string, arg ...ice.Any) { RenderPodCmd(m, "", cmd, arg...) }
func RenderVersion(m *ice.Message) string { func RenderVersion(m *ice.Message) string {
if ice.Info.Make.Hash == "" { if ice.Info.Make.Hash == "" {
return "" 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 ( const (

View File

@ -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.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), 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), 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) { func _autogen_mod(m *ice.Message, file string) (mod string) {

View File

@ -20,7 +20,7 @@ func _binpack_file(m *ice.Message, w io.Writer, arg ...string) {
if kit.IsIn(kit.Ext(arg[0]), "zip", "gz") { if kit.IsIn(kit.Ext(arg[0]), "zip", "gz") {
return return
} }
if kit.Contains(arg[0], "/node_modules/", "/dist/", "/bin/", "/log/") { if kit.Contains(arg[0], "/dist/", "/bin/", "/log/") {
return return
} }
if strings.HasPrefix(arg[0], "usr/volcanos/publish/") && !strings.HasSuffix(arg[0], "/proto.js") { if strings.HasPrefix(arg[0], "usr/volcanos/publish/") && !strings.HasSuffix(arg[0], "/proto.js") {

View File

@ -21,6 +21,9 @@ type MakeInfo struct {
Hostname string Hostname string
Username string Username string
Email string Email string
When string
Message string
Forword string
} }
var Info = struct { var Info = struct {

View File

@ -17,9 +17,9 @@ type field struct {
list string `name:"list domain id auto insert" help:"插件"` list string `name:"list domain id auto insert" help:"插件"`
} }
func (s field) Inputs(m *ice.Message, arg ...string) { func (s field) Init(m *ice.Message, arg ...string) { s.Zone.Imports(m) }
s.daemon.Inputs(m, arg...) 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) { 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) { 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 { if len(arg) == 0 {
@ -36,7 +36,6 @@ func (s field) Run(m *ice.Message, arg ...string) {
m.Cmdy(value[mdb.INDEX], arg[1:]) m.Cmdy(value[mdb.INDEX], arg[1:])
}) })
} }
func (s field) List(m *ice.Message, arg ...string) { func (s field) List(m *ice.Message, arg ...string) { s.Zone.List(m, arg...) }
s.Zone.List(m, arg...)
}
func init() { ice.CodeCtxCmd(field{}) } func init() { ice.CodeCtxCmd(field{}) }

View File

@ -49,6 +49,24 @@ func _repos_recent(m *ice.Message, repos *git.Repository) (r *plumbing.Reference
} }
return 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) { func _repos_insert(m *ice.Message, p string) {
if repos, err := git.PlainOpen(p); err == nil { if repos, err := git.PlainOpen(p); err == nil {
args := []string{REPOS, path.Base(p), nfs.PATH, p} 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 { 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 { if remote, err := repos.Remote("origin"); err == nil {
args = append(args, ORIGIN, remote.Config().URLs[0]) args = append(args, ORIGIN, remote.Config().URLs[0])
@ -507,16 +529,21 @@ func init() {
if _remote, err := repos.Remote(ORIGIN); err == nil { if _remote, err := repos.Remote(ORIGIN); err == nil {
m.Push(REMOTE, kit.Select("", _remote.Config().URLs, 0)) 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 { if refer, err := repos.Head(); err == nil {
m.Push(BRANCH, refer.Name().Short()) m.Push(BRANCH, refer.Name().Short())
m.Push(mdb.HASH, refer.Hash().String()) m.Push(mdb.HASH, refer.Hash().String())
} if commit, err := repos.CommitObject(refer.Hash()); err == nil {
if refer := _repos_recent(m, repos); refer != nil { m.Push(aaa.USERNAME, commit.Author.Name)
m.Push(nfs.VERSION, refer.Name().Short()) m.Push(aaa.EMAIL, commit.Author.Email)
} m.Push("when", commit.Author.When)
if cfg, err := config.LoadConfig(config.GlobalScope); err == nil { m.Push("message", commit.Message)
m.Push(aaa.EMAIL, kit.Select(m.Option(ice.MSG_USERNAME)+"@163.com", cfg.User.Email)) m.Push("forword", _repos_forword(m, repos, version))
m.Push(aaa.USERNAME, kit.Select(m.Option(ice.MSG_USERNAME), cfg.User.Name)) }
} }
}}, }},
TOTAL: {Hand: func(m *ice.Message, arg ...string) { TOTAL: {Hand: func(m *ice.Message, arg ...string) {