1
0
forked from x/icebergs
This commit is contained in:
IT 老营长 @云轩领航-创始人 2022-03-15 03:41:14 +08:00
parent e9253f9ac1
commit b2232d458c
4 changed files with 15 additions and 10 deletions

View File

@ -95,9 +95,8 @@ func _autogen_mod(m *ice.Message, file string) (mod string) {
} else {
host = path.Join(host, "x", path.Base(kit.Path("")))
}
m.Debug("what %v", host)
m.Cmd(nfs.DEFS, ice.GO_MOD, kit.Format(`module %s
m.Cmd(nfs.DEFS, file, kit.Format(`module %s
go 1.11
`, host))
@ -126,11 +125,10 @@ func _autogen_gits(m *ice.Message, arg ...string) string {
return kit.Join(res, ice.NL)
}
func _autogen_version(m *ice.Message) {
if !kit.FileExists(".git") {
if mod := _autogen_mod(m, ice.GO_MOD); !kit.FileExists(".git") {
m.Cmdy(cli.SYSTEM, GIT, ice.INIT)
}
if !kit.FileExists("go.mod") {
m.Cmdy(cli.SYSTEM, GO, "mod", ice.INIT, path.Base(kit.Path("")))
m.Cmdy(cli.SYSTEM, GIT, "remote", "add", "origin", "https://"+mod)
m.Cmd("web.code.git.repos", mdb.CREATE, "repos", "https://"+mod, "name", path.Base(mod), "path", "./")
}
m.Cmd(nfs.DEFS, ice.SRC_BINPACK_GO, kit.Format(`package main
@ -179,6 +177,7 @@ func init() {
_autogen_source(m, m.Option(cli.MAIN), p)
}
m.Option(nfs.FILE, path.Join(m.Option(mdb.ZONE), kit.Keys(m.Option(mdb.NAME), GO)))
_autogen_version(m.Spawn())
}},
ssh.SCRIPT: {Name: "script", Help: "脚本:生成 etc/miss.sh", Hand: func(m *ice.Message, arg ...string) {
m.Cmd(nfs.DEFS, ice.ETC_MISS_SH, m.Conf(web.DREAM, kit.Keym("miss")))

View File

@ -20,6 +20,7 @@ var Index = &ice.Context{Name: GIT, Help: "代码库", Configs: map[string]*ice.
code.INSTALL: {Name: "install", Help: "安装", Hand: func(m *ice.Message, arg ...string) {
cli.PushStream(m)
defer m.ProcessInner()
m.Cmdy(cli.SYSTEM, "yum", "install", "-y", "git")
}},
cli.ORDER: {Name: "order", Help: "加载", Hand: func(m *ice.Message, arg ...string) {

View File

@ -68,6 +68,7 @@ func init() {
m.Option(BRANCH, ls[1])
}
_repos_insert(m, m.Option(mdb.NAME), m.Option(nfs.PATH))
if s, e := os.Stat(path.Join(m.Option(nfs.PATH), ".git")); e == nil && s.IsDir() {
return
}
@ -79,11 +80,10 @@ func init() {
m.Cmd(cli.SYSTEM, GIT, REMOTE, ADD, ORIGIN, m.Option(REPOS))
m.Cmd(cli.SYSTEM, GIT, PULL, ORIGIN, MASTER)
} else {
m.Option(cli.CMD_DIR, "")
m.Cmd(cli.SYSTEM, GIT, CLONE, "-b", kit.Select(MASTER, m.Option(BRANCH)),
m.Option(REPOS), m.Option(nfs.PATH))
}
_repos_insert(m, m.Option(mdb.NAME), m.Option(nfs.PATH))
}},
}, mdb.HashAction()), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
if len(arg) == 0 { // 仓库列表

View File

@ -152,7 +152,7 @@ func _status_list(m *ice.Message) (files, adds, dels int, last time.Time) {
list = append(list, TAG)
}
if strings.Contains(vs[1], "ahead") {
if strings.Contains(vs[1], "ahead") || !strings.Contains(vs[1], "...") {
list = append(list, PUSH)
} else if strings.Contains(tags, "-") {
list = append(list, TAG)
@ -239,7 +239,12 @@ func init() {
return
}
_repos_cmd(m, m.Option(REPOS), PUSH)
if strings.TrimSpace(m.Cmdx(cli.SYSTEM, GIT, "rev-parse", "--abbrev-ref", "--symbolic-full-name", "@{u}", ice.Option{cli.CMD_DIR, _repos_path(m.Option(REPOS))})) == "" {
_repos_cmd(m, m.Option(REPOS), PUSH, "--set-upstream", "origin", "master")
} else {
_repos_cmd(m, m.Option(REPOS), PUSH)
}
_repos_cmd(m, m.Option(REPOS), PUSH, "--tags")
m.ProcessRefresh3ms()
}},