mirror of
https://shylinux.com/x/icebergs
synced 2025-04-26 01:24:05 +08:00
opt some
This commit is contained in:
parent
90037da808
commit
132dc7c758
@ -64,13 +64,18 @@ func _dream_show(m *ice.Message, name string) {
|
||||
SPACE, tcp.DIAL, ice.DEV, ice.OPS, mdb.TYPE, WORKER, m.OptionSimple(mdb.NAME, RIVER), cli.DAEMON, ice.OPS)
|
||||
}
|
||||
func _dream_template(m *ice.Message, p string) {
|
||||
nfs.MkdirAll(m, p)
|
||||
if m.Option(nfs.REPOS) != "" {
|
||||
m.Cmd(cli.SYSTEM, "git", "clone", m.Option(nfs.REPOS), p)
|
||||
} else {
|
||||
nfs.MkdirAll(m, p)
|
||||
}
|
||||
if m.Option(nfs.TEMPLATE) == "" {
|
||||
return
|
||||
}
|
||||
for _, file := range []string{
|
||||
ice.ETC_MISS_SH, ice.SRC_MAIN_SHY, ice.SRC_MAIN_GO,
|
||||
ice.GO_MOD, ice.MAKEFILE, ice.README_MD,
|
||||
ice.ETC_MISS_SH, ice.MAKEFILE, ice.GO_MOD, ice.GO_SUM,
|
||||
ice.SRC_MAIN_GO, ice.SRC_MAIN_SHY, ice.SRC_MAIN_JS,
|
||||
ice.README_MD,
|
||||
} {
|
||||
if nfs.ExistsFile(m, path.Join(p, file)) {
|
||||
continue
|
||||
|
@ -1,8 +1,11 @@
|
||||
package git
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
ice "shylinux.com/x/icebergs"
|
||||
"shylinux.com/x/icebergs/base/mdb"
|
||||
"shylinux.com/x/icebergs/base/nfs"
|
||||
kit "shylinux.com/x/toolkits"
|
||||
)
|
||||
|
||||
@ -14,6 +17,18 @@ func _configs_list(m *ice.Message) *ice.Message {
|
||||
})
|
||||
return mdb.HashSelectValue(m, func(value ice.Maps) { m.Push("", value, kit.Split("name,value")).PushButton(mdb.CREATE) })
|
||||
}
|
||||
func _configs_read(m *ice.Message, p string) ice.Maps {
|
||||
res, block := ice.Maps{}, ""
|
||||
m.Cmd(nfs.CAT, p, func(text string) {
|
||||
if strings.HasPrefix(text, "[") {
|
||||
block = kit.Join(kit.Split(text, " []"), ".")
|
||||
return
|
||||
}
|
||||
ls := kit.Split(text, " =")
|
||||
res[kit.Keys(block, ls[0])] = ls[1]
|
||||
})
|
||||
return res
|
||||
}
|
||||
|
||||
const (
|
||||
USER_NAME = "user.name"
|
||||
|
@ -29,12 +29,16 @@ func _repos_init(m *ice.Message, dir string) string {
|
||||
}
|
||||
func _repos_insert(m *ice.Message, name string, path string) bool {
|
||||
if repos, e := gogit.OpenRepository(_git_dir(path)); e == nil {
|
||||
origin := kit.Select("", kit.Split(repos.GetOrigin()), -1)
|
||||
if origin == "" {
|
||||
origin = _configs_read(m, _git_dir(path, "config"))["remote.origin.url"]
|
||||
}
|
||||
if ci, e := repos.GetCommit(); e == nil {
|
||||
mdb.HashCreate(m, REPOS, name, nfs.PATH, path, mdb.TIME, ci.Author.When.Format(ice.MOD_TIME), COMMIT, strings.TrimSpace(ci.Message),
|
||||
BRANCH, repos.GetBranch(), ORIGIN, kit.Select("", kit.Split(repos.GetOrigin()), -1))
|
||||
BRANCH, repos.GetBranch(), ORIGIN, origin)
|
||||
} else {
|
||||
mdb.HashCreate(m, REPOS, name, nfs.PATH, path, mdb.TIME, m.Time(),
|
||||
BRANCH, repos.GetBranch(), ORIGIN, kit.Select("", kit.Split(repos.GetOrigin()), -1))
|
||||
BRANCH, repos.GetBranch(), ORIGIN, origin)
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user