forked from x/icebergs
opt git.service
This commit is contained in:
parent
b9464d2b43
commit
f36fa0d148
@ -42,18 +42,18 @@ func init() {
|
|||||||
var _release = ""
|
var _release = ""
|
||||||
|
|
||||||
func release(m *ice.Message) string {
|
func release(m *ice.Message) string {
|
||||||
osid := runtime.GOOS
|
list := []string{runtime.GOOS}
|
||||||
if osid != LINUX || !nfs.Exists(m, "/etc/os-release") {
|
if list[0] != LINUX || !nfs.Exists(m, "/etc/os-release") {
|
||||||
return osid
|
return list[0]
|
||||||
}
|
}
|
||||||
m.Option(nfs.CAT_CONTENT, _release)
|
m.Option(nfs.CAT_CONTENT, _release)
|
||||||
_release = m.Cmdx(nfs.CAT, "/etc/os-release", kit.Dict(ice.MSG_USERROLE, aaa.ROOT), func(text string, _ int) string {
|
_release = m.Cmdx(nfs.CAT, "/etc/os-release", kit.Dict(ice.MSG_USERROLE, aaa.ROOT), func(text string, _ int) string {
|
||||||
if ls := kit.Split(text, mdb.EQ); len(ls) > 1 {
|
if ls := kit.Split(text, mdb.EQ); len(ls) > 1 {
|
||||||
kit.Switch(ls[0], []string{"ID", "ID_LIKE"}, func() { osid = strings.TrimSpace(ls[1] + lex.SP + osid) })
|
kit.Switch(ls[0], []string{"ID", "ID_LIKE"}, func() { list = append(list, strings.TrimSpace(ls[1])) })
|
||||||
}
|
}
|
||||||
return text
|
return text
|
||||||
})
|
})
|
||||||
return osid
|
return strings.Join(list, lex.SP)
|
||||||
}
|
}
|
||||||
func insert(m *ice.Message, sys, cmd string, arg ...string) bool {
|
func insert(m *ice.Message, sys, cmd string, arg ...string) bool {
|
||||||
if !strings.Contains(release(m), sys) {
|
if !strings.Contains(release(m), sys) {
|
||||||
|
@ -42,6 +42,7 @@ func _runtime_init(m *ice.Message) {
|
|||||||
ice.Info.Hostname = m.Conf(RUNTIME, kit.Keys(BOOT, HOSTNAME))
|
ice.Info.Hostname = m.Conf(RUNTIME, kit.Keys(BOOT, HOSTNAME))
|
||||||
ice.Info.Pathname = m.Conf(RUNTIME, kit.Keys(BOOT, PATHNAME))
|
ice.Info.Pathname = m.Conf(RUNTIME, kit.Keys(BOOT, PATHNAME))
|
||||||
ice.Info.Username = m.Conf(RUNTIME, kit.Keys(BOOT, USERNAME))
|
ice.Info.Username = m.Conf(RUNTIME, kit.Keys(BOOT, USERNAME))
|
||||||
|
ice.Info.System = m.Conf(RUNTIME, kit.Keys(HOST, OSID))
|
||||||
aaa.UserRoot(ice.Pulse, "", ice.Info.Username, aaa.ROOT, ice.OPS)
|
aaa.UserRoot(ice.Pulse, "", ice.Info.Username, aaa.ROOT, ice.OPS)
|
||||||
aaa.UserRoot(ice.Pulse, "", ice.Info.Make.Username, aaa.TECH, ice.DEV)
|
aaa.UserRoot(ice.Pulse, "", ice.Info.Make.Username, aaa.TECH, ice.DEV)
|
||||||
if runtime.GOARCH != MIPSLE {
|
if runtime.GOARCH != MIPSLE {
|
||||||
|
@ -150,6 +150,9 @@ func _config_make(m *ice.Message, key string, arg ...string) {
|
|||||||
msg := m.Spawn(m.Source())
|
msg := m.Spawn(m.Source())
|
||||||
if len(arg) > 1 {
|
if len(arg) > 1 {
|
||||||
kit.If(strings.HasPrefix(arg[1], mdb.AT), func() { arg[1] = msg.Cmdx(nfs.CAT, arg[1][1:]) })
|
kit.If(strings.HasPrefix(arg[1], mdb.AT), func() { arg[1] = msg.Cmdx(nfs.CAT, arg[1][1:]) })
|
||||||
|
if !kit.IsIn(strings.Split(arg[0], nfs.PT)[0], mdb.META, mdb.HASH, mdb.LIST) {
|
||||||
|
arg[0] = kit.Keys(mdb.META, arg[0])
|
||||||
|
}
|
||||||
mdb.Confv(msg, key, arg[0], kit.Parse(nil, "", arg[1:]...))
|
mdb.Confv(msg, key, arg[0], kit.Parse(nil, "", arg[1:]...))
|
||||||
}
|
}
|
||||||
if len(arg) > 0 {
|
if len(arg) > 0 {
|
||||||
|
@ -63,7 +63,7 @@ func _autogen_version(m *ice.Message) string {
|
|||||||
}
|
}
|
||||||
m.Cmd(nfs.DEFS, ".gitignore", nfs.Template(m, "gitignore"))
|
m.Cmd(nfs.DEFS, ".gitignore", nfs.Template(m, "gitignore"))
|
||||||
m.Cmd(nfs.DEFS, ice.SRC_BINPACK_GO, nfs.Template(m, ice.SRC_BINPACK_GO))
|
m.Cmd(nfs.DEFS, ice.SRC_BINPACK_GO, nfs.Template(m, ice.SRC_BINPACK_GO))
|
||||||
m.Cmd(nfs.SAVE, ice.SRC_VERSION_GO, kit.Format(nfs.Template(m, ice.SRC_VERSION_GO), _autogen_gits(m, nfs.MODULE, _autogen_mod(m, ice.GO_MOD), tcp.HOSTNAME, ice.Info.Hostname)))
|
m.Cmd(nfs.SAVE, ice.SRC_VERSION_GO, kit.Format(nfs.Template(m, ice.SRC_VERSION_GO), _autogen_gits(m)))
|
||||||
m.Cmd(cli.SYSTEM, "gofmt", "-w", ice.SRC_VERSION_GO)
|
m.Cmd(cli.SYSTEM, "gofmt", "-w", ice.SRC_VERSION_GO)
|
||||||
m.Cmdy(nfs.DIR, ice.SRC_BINPACK_GO)
|
m.Cmdy(nfs.DIR, ice.SRC_BINPACK_GO)
|
||||||
m.Cmdy(nfs.DIR, ice.SRC_VERSION_GO)
|
m.Cmdy(nfs.DIR, ice.SRC_VERSION_GO)
|
||||||
@ -79,11 +79,12 @@ func _autogen_gits(m *ice.Message, arg ...string) string {
|
|||||||
}
|
}
|
||||||
func _autogen_git(m *ice.Message, arg ...string) ice.Map {
|
func _autogen_git(m *ice.Message, arg ...string) ice.Map {
|
||||||
msg := m.Cmd("web.code.git.repos", "remote")
|
msg := m.Cmd("web.code.git.repos", "remote")
|
||||||
return kit.Dict(arg,
|
return kit.Dict(arg, aaa.USERNAME, ice.Info.Username, tcp.HOSTNAME, ice.Info.Hostname, nfs.PATH, kit.Path("")+nfs.PS, mdb.TIME, m.Time(),
|
||||||
mdb.TIME, m.Time(), nfs.PATH, kit.Path("")+nfs.PS, web.DOMAIN, tcp.PublishLocalhost(m, m.Option(ice.MSG_USERWEB)),
|
GIT, m.Cmdx(cli.SYSTEM, GIT, VERSION), GO, m.Cmdx(cli.SYSTEM, GO, 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),
|
msg.AppendSimple("remote,branch,version,forword,author,email,hash,when,message"),
|
||||||
aaa.EMAIL, msg.Append(aaa.EMAIL), aaa.USERNAME, msg.Append(aaa.USERNAME),
|
web.DOMAIN, tcp.PublishLocalhost(m, m.Option(ice.MSG_USERWEB)),
|
||||||
msg.AppendSimple("when,message,forword"),
|
nfs.MODULE, _autogen_mod(m, ice.GO_MOD),
|
||||||
|
cli.SYSTEM, ice.Info.System,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
func _autogen_mod(m *ice.Message, file string) (mod string) {
|
func _autogen_mod(m *ice.Message, file string) (mod string) {
|
||||||
@ -100,12 +101,12 @@ func _autogen_mod(m *ice.Message, file string) (mod string) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const (
|
||||||
|
VERSION = "version"
|
||||||
|
)
|
||||||
const AUTOGEN = "autogen"
|
const AUTOGEN = "autogen"
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
const (
|
|
||||||
VERSION = "version"
|
|
||||||
)
|
|
||||||
Index.MergeCommands(ice.Commands{
|
Index.MergeCommands(ice.Commands{
|
||||||
AUTOGEN: {Name: "autogen path auto script module version", Help: "生成", Actions: ice.Actions{
|
AUTOGEN: {Name: "autogen path auto script module version", Help: "生成", Actions: ice.Actions{
|
||||||
mdb.INPUTS: {Hand: func(m *ice.Message, arg ...string) {
|
mdb.INPUTS: {Hand: func(m *ice.Message, arg ...string) {
|
||||||
|
35
info.go
35
info.go
@ -10,31 +10,38 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type MakeInfo struct {
|
type MakeInfo struct {
|
||||||
Hash string
|
|
||||||
Time string
|
|
||||||
Path string
|
|
||||||
Module string
|
|
||||||
Domain string
|
|
||||||
Remote string
|
|
||||||
Branch string
|
|
||||||
Version string
|
|
||||||
Hostname string
|
|
||||||
Username string
|
Username string
|
||||||
Email string
|
Hostname string
|
||||||
When string
|
Path string
|
||||||
Message string
|
Time string
|
||||||
Forword string
|
Git string
|
||||||
|
Go string
|
||||||
|
|
||||||
|
Remote string
|
||||||
|
Branch string
|
||||||
|
Version string
|
||||||
|
Forword string
|
||||||
|
Author string
|
||||||
|
Email string
|
||||||
|
Hash string
|
||||||
|
When string
|
||||||
|
Message string
|
||||||
|
|
||||||
|
Domain string
|
||||||
|
Module string
|
||||||
|
System string
|
||||||
}
|
}
|
||||||
|
|
||||||
var Info = struct {
|
var Info = struct {
|
||||||
Make MakeInfo
|
Make MakeInfo
|
||||||
|
|
||||||
|
Username string
|
||||||
Hostname string
|
Hostname string
|
||||||
Pathname string
|
Pathname string
|
||||||
Username string
|
|
||||||
PidPath string
|
PidPath string
|
||||||
Colors bool
|
Colors bool
|
||||||
|
|
||||||
|
System string
|
||||||
Domain string
|
Domain string
|
||||||
NodeType string
|
NodeType string
|
||||||
NodeName string
|
NodeName string
|
||||||
|
@ -555,20 +555,18 @@ 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 {
|
if refer := _repos_recent(m, repos); refer != nil {
|
||||||
m.Push(nfs.VERSION, refer.Name().Short())
|
m.Push(nfs.VERSION, refer.Name().Short())
|
||||||
version = refer.Hash().String()
|
m.Push("forword", _repos_forword(m, repos, 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 commit, err := repos.CommitObject(refer.Hash()); err == nil {
|
||||||
m.Push(aaa.USERNAME, commit.Author.Name)
|
|
||||||
m.Push(aaa.EMAIL, commit.Author.Email)
|
m.Push(aaa.EMAIL, commit.Author.Email)
|
||||||
|
m.Push("author", commit.Author.Name)
|
||||||
m.Push("when", commit.Author.When)
|
m.Push("when", commit.Author.When)
|
||||||
m.Push("message", commit.Message)
|
m.Push("message", commit.Message)
|
||||||
m.Push("forword", _repos_forword(m, repos, version))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}},
|
}},
|
||||||
|
@ -54,7 +54,10 @@ func _service_param(m *ice.Message, arg ...string) (string, string) {
|
|||||||
repos, service := arg[0], kit.Select(arg[len(arg)-1], m.Option(SERVICE))
|
repos, service := arg[0], kit.Select(arg[len(arg)-1], m.Option(SERVICE))
|
||||||
return _service_path(m, repos), strings.TrimPrefix(service, "git-")
|
return _service_path(m, repos), strings.TrimPrefix(service, "git-")
|
||||||
}
|
}
|
||||||
func _service_repos2(m *ice.Message, arg ...string) error {
|
func _service_repos(m *ice.Message, arg ...string) error {
|
||||||
|
if mdb.Conf(m, "web.code.git.service", "meta.cmd") == "git" {
|
||||||
|
return _service_repos0(m, arg...)
|
||||||
|
}
|
||||||
repos, service := _service_param(m, arg...)
|
repos, service := _service_param(m, arg...)
|
||||||
m.Logs(m.R.Method, service, repos)
|
m.Logs(m.R.Method, service, repos)
|
||||||
info := false
|
info := false
|
||||||
@ -81,9 +84,7 @@ func _service_repos2(m *ice.Message, arg ...string) error {
|
|||||||
return ServeUploadPack(info, stream, repos)
|
return ServeUploadPack(info, stream, repos)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
func _service_repos(m *ice.Message, arg ...string) error {
|
func _service_repos0(m *ice.Message, arg ...string) error {
|
||||||
return _service_repos2(m, arg...)
|
|
||||||
|
|
||||||
repos, service := _service_param(m, arg...)
|
repos, service := _service_param(m, arg...)
|
||||||
m.Logs(m.R.Method, service, repos)
|
m.Logs(m.R.Method, service, repos)
|
||||||
if m.Option(cli.CMD_DIR, repos); strings.HasSuffix(path.Join(arg...), INFO_REFS) {
|
if m.Option(cli.CMD_DIR, repos); strings.HasSuffix(path.Join(arg...), INFO_REFS) {
|
||||||
@ -191,6 +192,9 @@ func init() {
|
|||||||
mdb.HashSelect(m, arg...).Table(func(value ice.Maps) {
|
mdb.HashSelect(m, arg...).Table(func(value ice.Maps) {
|
||||||
m.PushScript(kit.Format("git clone %s", tcp.PublishLocalhost(m, kit.Split(web.MergeURL2(m, "/x/"+value[REPOS]+".git"), mdb.QS)[0])))
|
m.PushScript(kit.Format("git clone %s", tcp.PublishLocalhost(m, kit.Split(web.MergeURL2(m, "/x/"+value[REPOS]+".git"), mdb.QS)[0])))
|
||||||
}).Sort(REPOS).Echo(strings.ReplaceAll(m.Cmdx("web.code.publish", ice.CONTEXTS), "app username", "dev username"))
|
}).Sort(REPOS).Echo(strings.ReplaceAll(m.Cmdx("web.code.publish", ice.CONTEXTS), "app username", "dev username"))
|
||||||
|
m.Table(func(value ice.Maps) {
|
||||||
|
m.Push(nfs.SIZE, kit.Split(m.Cmdx(cli.SYSTEM, "du", "-sh", path.Join(ice.USR_LOCAL_REPOS, value[REPOS])))[0])
|
||||||
|
})
|
||||||
} else if len(arg) == 1 {
|
} else if len(arg) == 1 {
|
||||||
_repos_branch(m, _repos_open(m, arg[0]))
|
_repos_branch(m, _repos_open(m, arg[0]))
|
||||||
m.EchoScript(tcp.PublishLocalhost(m, kit.Split(web.MergeURL2(m, "/x/"+arg[0]), mdb.QS)[0]))
|
m.EchoScript(tcp.PublishLocalhost(m, kit.Split(web.MergeURL2(m, "/x/"+arg[0]), mdb.QS)[0]))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user