mirror of
https://shylinux.com/x/icebergs
synced 2025-05-01 03:09:21 +08:00
add git
This commit is contained in:
parent
4b37df12e3
commit
2864019132
@ -41,7 +41,8 @@ func Process(m *ice.Message, key string, args ice.Any, arg ...string) {
|
|||||||
}
|
}
|
||||||
func ProcessField(m *ice.Message, cmd string, args ice.Any, arg ...string) *ice.Message {
|
func ProcessField(m *ice.Message, cmd string, args ice.Any, arg ...string) *ice.Message {
|
||||||
if cmd = kit.Select(m.ActionKey(), cmd); !kit.HasPrefixList(arg, ice.RUN) {
|
if cmd = kit.Select(m.ActionKey(), cmd); !kit.HasPrefixList(arg, ice.RUN) {
|
||||||
m.Cmdy(COMMAND, cmd).Push(ARGS, _process_args(m, args)).Options(ice.MSG_INDEX, m.PrefixKey()).ProcessField(ACTION, m.ActionKey(), ice.RUN)
|
m.Cmdy(COMMAND, cmd).Push(ARGS, kit.Format(_process_args(m, args))).Options(ice.MSG_INDEX, m.PrefixKey()).ProcessField(ACTION, m.ActionKey(), ice.RUN)
|
||||||
|
m.Debug("what %v", m.FormatMeta())
|
||||||
} else {
|
} else {
|
||||||
kit.If(aaa.Right(m, cmd, arg[1:]), func() { m.Cmdy(cmd, arg[1:]) })
|
kit.If(aaa.Right(m, cmd, arg[1:]), func() { m.Cmdy(cmd, arg[1:]) })
|
||||||
}
|
}
|
||||||
|
@ -33,6 +33,6 @@ func init() {
|
|||||||
mdb.PRUNES: {Hand: func(m *ice.Message, arg ...string) { mdb.HashPrunesValue(m, mdb.COUNT, "0") }},
|
mdb.PRUNES: {Hand: func(m *ice.Message, arg ...string) { mdb.HashPrunesValue(m, mdb.COUNT, "0") }},
|
||||||
HAPPEN: {Hand: func(m *ice.Message, arg ...string) { _timer_action(m, time.Now(), arg...) }},
|
HAPPEN: {Hand: func(m *ice.Message, arg ...string) { _timer_action(m, time.Now(), arg...) }},
|
||||||
RESTART: {Name: "restart count=3", Hand: func(m *ice.Message, arg ...string) { mdb.HashModify(m, m.OptionSimple(mdb.HashShort(m)), arg) }},
|
RESTART: {Name: "restart count=3", Hand: func(m *ice.Message, arg ...string) { mdb.HashModify(m, m.OptionSimple(mdb.HashShort(m)), arg) }},
|
||||||
}, mdb.HashAction(mdb.FIELD, "time,hash,name,delay,interval,count,cmd", TICK, "60s"))},
|
}, mdb.HashAction(mdb.FIELD, "time,hash,name,delay,interval,count,cmd", TICK, "600s"))},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -23,13 +23,13 @@ func _repos_cmd(m *ice.Message, name string, arg ...string) *ice.Message {
|
|||||||
}
|
}
|
||||||
func _repos_init(m *ice.Message, dir string) string {
|
func _repos_init(m *ice.Message, dir string) string {
|
||||||
os.MkdirAll(path.Join(dir, REFS_HEADS), ice.MOD_DIR)
|
os.MkdirAll(path.Join(dir, REFS_HEADS), ice.MOD_DIR)
|
||||||
os.MkdirAll(path.Join(dir, "objects/info/"), ice.MOD_DIR)
|
os.MkdirAll(path.Join(dir, OBJECTS_INFO), ice.MOD_DIR)
|
||||||
return m.Cmdx(nfs.SAVE, path.Join(dir, "HEAD"), "ref: refs/heads/master")
|
return m.Cmdx(nfs.SAVE, path.Join(dir, "HEAD"), "ref: refs/heads/master")
|
||||||
}
|
}
|
||||||
func _repos_insert(m *ice.Message, name string, path string) bool {
|
func _repos_insert(m *ice.Message, name string, path string) bool {
|
||||||
if repos, e := gogit.OpenRepository(_git_dir(path)); e == nil {
|
if repos, e := gogit.OpenRepository(_git_dir(path)); e == nil {
|
||||||
origin := kit.Select("", kit.Split(repos.GetOrigin()), -1)
|
origin := kit.Select("", kit.Split(repos.GetOrigin()), -1)
|
||||||
kit.If(origin == "", func() { origin = _configs_read(m, _git_dir(path, "config"))["remote.origin.url"] })
|
kit.If(origin == "", func() { origin = _configs_read(m, _git_dir(path, CONFIG))["remote.origin.url"] })
|
||||||
if ci, e := repos.GetCommit(); e == nil {
|
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, origin)
|
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, origin)
|
||||||
} else {
|
} else {
|
||||||
@ -44,11 +44,8 @@ func _repos_branch(m *ice.Message, dir string) {
|
|||||||
nfs.DirDeepAll(m, path.Join(dir, REFS_HEADS), "", func(value ice.Maps) {
|
nfs.DirDeepAll(m, path.Join(dir, REFS_HEADS), "", func(value ice.Maps) {
|
||||||
if refer, e := repos.LookupReference(REFS_HEADS + value[nfs.PATH]); !m.Warn(e, ice.ErrNotValid, value[nfs.PATH]) {
|
if refer, e := repos.LookupReference(REFS_HEADS + value[nfs.PATH]); !m.Warn(e, ice.ErrNotValid, value[nfs.PATH]) {
|
||||||
if ci, e := repos.LookupCommit(refer.Oid); !m.Warn(e, ice.ErrNotValid, refer.Oid.String()) {
|
if ci, e := repos.LookupCommit(refer.Oid); !m.Warn(e, ice.ErrNotValid, refer.Oid.String()) {
|
||||||
m.Push(mdb.TIME, ci.Author.When.Format(ice.MOD_TIME))
|
m.Push(mdb.TIME, ci.Author.When.Format(ice.MOD_TIME)).Push(BRANCH, value[nfs.PATH])
|
||||||
m.Push(BRANCH, value[nfs.PATH])
|
m.Push(COMMIT, ci.Oid.Short()).Push(AUTHOR, ci.Author.Name).Push(MESSAGE, ci.Message)
|
||||||
m.Push(COMMIT, ci.Oid.Short())
|
|
||||||
m.Push(AUTHOR, ci.Author.Name)
|
|
||||||
m.Push(MESSAGE, ci.Message)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, nfs.PATH)
|
}, nfs.PATH)
|
||||||
@ -58,18 +55,12 @@ func _repos_commit(m *ice.Message, dir, branch string, cb func(*gogit.Commit, *g
|
|||||||
if repos, e := gogit.OpenRepository(dir); !m.Warn(e, ice.ErrNotFound, dir) {
|
if repos, e := gogit.OpenRepository(dir); !m.Warn(e, ice.ErrNotFound, dir) {
|
||||||
if refer, e := repos.LookupReference(REFS_HEADS + branch); !m.Warn(e, ice.ErrNotFound, branch) {
|
if refer, e := repos.LookupReference(REFS_HEADS + branch); !m.Warn(e, ice.ErrNotFound, branch) {
|
||||||
if cb == nil {
|
if cb == nil {
|
||||||
m.Push(mdb.TIME, m.Time())
|
m.Push(mdb.TIME, m.Time()).Push(COMMIT, cli.PWD).Push(AUTHOR, kit.Select(m.Option(ice.MSG_USERNAME), m.Option(ice.MSG_USERNICK))).Push(MESSAGE, "opt some")
|
||||||
m.Push(COMMIT, cli.PWD)
|
|
||||||
m.Push(AUTHOR, kit.Select(m.Option(ice.MSG_USERNAME), m.Option(ice.MSG_USERNICK)))
|
|
||||||
m.Push(MESSAGE, "opt some")
|
|
||||||
}
|
}
|
||||||
for oid := refer.Oid; oid != nil; {
|
for oid := refer.Oid; oid != nil; {
|
||||||
if ci, e := repos.LookupCommit(oid); !m.Warn(e, ice.ErrNotValid, oid.String()) {
|
if ci, e := repos.LookupCommit(oid); !m.Warn(e, ice.ErrNotFound, oid.String()) {
|
||||||
if cb == nil {
|
if cb == nil {
|
||||||
m.Push(mdb.TIME, ci.Author.When.Format(ice.MOD_TIME))
|
m.Push(mdb.TIME, ci.Author.When.Format(ice.MOD_TIME)).Push(COMMIT, ci.Oid.Short()).Push(AUTHOR, ci.Author.Name).Push(MESSAGE, ci.Message)
|
||||||
m.Push(COMMIT, ci.Oid.Short())
|
|
||||||
m.Push(AUTHOR, ci.Author.Name)
|
|
||||||
m.Push(MESSAGE, ci.Message)
|
|
||||||
} else if cb(ci, repos) {
|
} else if cb(ci, repos) {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
@ -83,52 +74,46 @@ func _repos_commit(m *ice.Message, dir, branch string, cb func(*gogit.Commit, *g
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
func _repos_dir(m *ice.Message, dir, branch, commit, file string, cb func(*gogit.TreeEntry, *gogit.Repository) bool) {
|
func _repos_cid(m *ice.Message, dir, branch, commit string) string {
|
||||||
if commit == cli.PWD && strings.HasPrefix(dir, ".git") {
|
|
||||||
nfs.DirDeepAll(m, path.Dir(dir), file, nil, "time,line,path")
|
|
||||||
m.Option(cli.CMD_DIR, path.Dir(dir))
|
|
||||||
m.Echo(_git_cmds(m, DIFF))
|
|
||||||
return
|
|
||||||
} else if commit == cli.PWD {
|
|
||||||
if repos, e := gogit.OpenRepository(dir); !m.Warn(e, ice.ErrNotFound, dir) {
|
|
||||||
if refer, e := repos.LookupReference(REFS_HEADS + branch); !m.Warn(e, ice.ErrNotFound, branch) {
|
|
||||||
commit = refer.Oid.String()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if file == nfs.PWD {
|
|
||||||
file = ""
|
|
||||||
}
|
|
||||||
if repos, e := gogit.OpenRepository(dir); !m.Warn(e, ice.ErrNotFound, dir) {
|
if repos, e := gogit.OpenRepository(dir); !m.Warn(e, ice.ErrNotFound, dir) {
|
||||||
if refer, e := repos.LookupReference(REFS_TAGS + commit); e == nil {
|
if refer, e := repos.LookupReference(REFS_TAGS + commit); e == nil {
|
||||||
|
m.Logs(nfs.FIND, "tags", commit, "commit", refer.Oid.String())
|
||||||
commit = refer.Oid.String()
|
commit = refer.Oid.String()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return commit
|
||||||
|
}
|
||||||
|
func _repos_dir(m *ice.Message, dir, branch, commit, file string, cb func(*gogit.TreeEntry, *gogit.Repository) bool) {
|
||||||
|
if commit == cli.PWD {
|
||||||
|
nfs.DirDeepAll(m, path.Dir(dir), file, nil, "time,line,path")
|
||||||
|
m.Options(cli.CMD_DIR, path.Dir(dir)).Echo(_git_cmds(m, DIFF))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
commit = _repos_cid(m, dir, branch, commit)
|
||||||
_repos_commit(m, dir, branch, func(ci *gogit.Commit, repos *gogit.Repository) bool {
|
_repos_commit(m, dir, branch, func(ci *gogit.Commit, repos *gogit.Repository) bool {
|
||||||
if !strings.HasPrefix(ci.Oid.String(), commit) {
|
if !strings.HasPrefix(ci.Oid.String(), commit) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
prev := ice.Maps{}
|
prev := ice.Maps{}
|
||||||
if p := ci.ParentCommit(0); p != nil {
|
if p := ci.ParentCommit(0); p != nil {
|
||||||
if ci, e := repos.LookupCommit(p.Oid); e == nil {
|
if ci, e := repos.LookupCommit(p.Oid); !m.Warn(e, ice.ErrNotFound, p.Oid.String()) {
|
||||||
if tree, e := repos.LookupTree(ci.TreeId()); !m.Warn(e, ice.ErrNotValid, ci.TreeId().String) {
|
if tree, e := repos.LookupTree(ci.TreeId()); !m.Warn(e, ice.ErrNotFound, ci.TreeId().String) {
|
||||||
tree.Walk(func(p string, v *gogit.TreeEntry) bool {
|
tree.Walk(func(p string, v *gogit.TreeEntry) bool {
|
||||||
prev[path.Join(p, v.Name)+kit.Select("", ice.PS, v.Type == gogit.ObjectTree)] = v.Oid.String()
|
kit.If(v.Type == gogit.ObjectBlob, func() { prev[path.Join(p, v.Name)] = v.Oid.String() })
|
||||||
return false
|
return false
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if tree, e := repos.LookupTree(ci.TreeId()); !m.Warn(e, ice.ErrNotValid, ci.TreeId().String) {
|
if tree, e := repos.LookupTree(ci.TreeId()); !m.Warn(e, ice.ErrNotFound, ci.TreeId().String) {
|
||||||
m.Logs(mdb.SELECT, REPOS, dir, BRANCH, branch, COMMIT, commit, "tree", tree.Oid.Short())
|
m.Logs(nfs.FIND, REPOS, dir, BRANCH, branch, COMMIT, commit, TREE, tree.Oid.Short())
|
||||||
tree.Walk(func(p string, v *gogit.TreeEntry) bool {
|
tree.Walk(func(p string, v *gogit.TreeEntry) bool {
|
||||||
if pp := path.Join(p, v.Name) + kit.Select("", ice.PS, v.Type == gogit.ObjectTree); strings.HasPrefix(pp, file) {
|
if pp := path.Join(p, v.Name) + kit.Select("", ice.PS, v.Type == gogit.ObjectTree); strings.HasPrefix(pp, file) {
|
||||||
if cb == nil {
|
if v.Type == gogit.ObjectTree {
|
||||||
if path.Dir(file) != path.Dir(pp) {
|
return false
|
||||||
|
} else if cb == nil {
|
||||||
} else if v.Type == gogit.ObjectTree {
|
if id, ok := prev[pp]; ok && id == v.Oid.String() {
|
||||||
|
if m.Option(ice.MSG_INDEX) == web.CODE_INNER {
|
||||||
} else if id, ok := prev[pp]; ok && id == v.Oid.String() {
|
|
||||||
if m.Option("_index") == web.CODE_INNER {
|
|
||||||
m.Push(mdb.HASH, v.Oid.Short()).Push(nfs.PATH, pp).Push(mdb.STATUS, "")
|
m.Push(mdb.HASH, v.Oid.Short()).Push(nfs.PATH, pp).Push(mdb.STATUS, "")
|
||||||
}
|
}
|
||||||
} else if ok {
|
} else if ok {
|
||||||
@ -144,46 +129,36 @@ func _repos_dir(m *ice.Message, dir, branch, commit, file string, cb func(*gogit
|
|||||||
return false
|
return false
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
kit.For(prev, func(pp, id string) {
|
kit.For(prev, func(pp, id string) { m.Push(mdb.HASH, id[:6]).Push(nfs.PATH, pp).Push(mdb.STATUS, "---") })
|
||||||
if path.Dir(file) != path.Dir(pp) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
m.Push(mdb.HASH, id[:6]).Push(nfs.PATH, pp).Push(mdb.STATUS, "---")
|
|
||||||
})
|
|
||||||
if m.Sort(kit.Fields(mdb.STATUS, nfs.PATH), ice.STR_R, ice.STR); cb == nil {
|
if m.Sort(kit.Fields(mdb.STATUS, nfs.PATH), ice.STR_R, ice.STR); cb == nil {
|
||||||
m.Option(cli.CMD_DIR, dir)
|
m.Options(cli.CMD_DIR, dir).Echo(_git_cmds(m, DIFF, ci.Oid.String()+"^", ci.Oid.String()))
|
||||||
m.Echo(_git_cmds(m, DIFF, ci.Oid.String()+"^", ci.Oid.String()))
|
|
||||||
m.Status(mdb.TIME, ci.Author.When.Format(ice.MOD_TIME), DIFF, _git_cmds(m, DIFF, "--shortstat", ci.Oid.String()+"^", ci.Oid.String()), MESSAGE, ci.Message)
|
m.Status(mdb.TIME, ci.Author.When.Format(ice.MOD_TIME), DIFF, _git_cmds(m, DIFF, "--shortstat", ci.Oid.String()+"^", ci.Oid.String()), MESSAGE, ci.Message)
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
func _repos_cat(m *ice.Message, dir, branch, commit, file string) {
|
func _repos_cat(m *ice.Message, dir, branch, commit, file string) {
|
||||||
if commit == cli.PWD && strings.HasPrefix(dir, ".git") {
|
if commit == cli.PWD {
|
||||||
m.Cmdy(nfs.CAT, path.Join(path.Dir(dir), file))
|
m.Cmdy(nfs.CAT, path.Join(path.Dir(dir), file))
|
||||||
return
|
return
|
||||||
} else if commit == cli.PWD {
|
|
||||||
if repos, e := gogit.OpenRepository(dir); !m.Warn(e, ice.ErrNotFound, dir) {
|
|
||||||
if refer, e := repos.LookupReference(REFS_HEADS + branch); !m.Warn(e, ice.ErrNotFound, branch) {
|
|
||||||
commit = refer.Oid.String()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
commit = _repos_cid(m, dir, branch, commit)
|
||||||
_repos_dir(m, dir, branch, commit, file, func(v *gogit.TreeEntry, repos *gogit.Repository) bool {
|
_repos_dir(m, dir, branch, commit, file, func(v *gogit.TreeEntry, repos *gogit.Repository) bool {
|
||||||
if blob, e := repos.LookupBlob(v.Oid); e == nil {
|
if blob, e := repos.LookupBlob(v.Oid); e == nil {
|
||||||
m.Logs(mdb.IMPORT, REPOS, dir, BRANCH, branch, COMMIT, commit, "blob", v.Oid.Short())
|
m.Logs(nfs.LOAD, REPOS, dir, BRANCH, branch, COMMIT, commit, BLOB, v.Oid.Short()).Echo(string(blob.Contents()))
|
||||||
m.Echo(string(blob.Contents()))
|
|
||||||
} else {
|
} else {
|
||||||
m.Option(cli.CMD_DIR, dir)
|
m.Options(cli.CMD_DIR, dir).Echo(_git_cmds(m, "cat-file", "-p", v.Oid.String()))
|
||||||
m.Echo(_git_cmds(m, "cat-file", "-p", v.Oid.String()))
|
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
OBJECTS_INFO = "objects/info/"
|
||||||
REFS_HEADS = "refs/heads/"
|
REFS_HEADS = "refs/heads/"
|
||||||
REFS_TAGS = "refs/tags/"
|
REFS_TAGS = "refs/tags/"
|
||||||
|
TREE = "tree"
|
||||||
|
BLOB = "blob"
|
||||||
|
|
||||||
INIT = "init"
|
INIT = "init"
|
||||||
CONFIG = "config"
|
CONFIG = "config"
|
||||||
@ -240,9 +215,9 @@ func init() {
|
|||||||
mdb.HashInputs(m, arg)
|
mdb.HashInputs(m, arg)
|
||||||
}
|
}
|
||||||
}},
|
}},
|
||||||
mdb.CREATE: {Name: "create origin name path", Hand: func(m *ice.Message, arg ...string) {
|
mdb.CREATE: {Name: "create origin branch name path", Hand: func(m *ice.Message, arg ...string) {
|
||||||
m.OptionDefault(mdb.NAME, strings.TrimSuffix(path.Base(m.Option(ORIGIN)), ".git"))
|
m.OptionDefault(mdb.NAME, kit.TrimExt(m.Option(ORIGIN), GIT))
|
||||||
m.OptionDefault(nfs.PATH, path.Join(ice.USR, m.Option(mdb.NAME)))
|
m.OptionDefault(nfs.PATH, path.Join(nfs.USR, m.Option(mdb.NAME)))
|
||||||
if _repos_insert(m, m.Option(mdb.NAME), m.Option(nfs.PATH)) {
|
if _repos_insert(m, m.Option(mdb.NAME), m.Option(nfs.PATH)) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -255,19 +230,20 @@ func init() {
|
|||||||
_git_cmd(m, PULL, ORIGIN, m.OptionDefault(BRANCH, MASTER))
|
_git_cmd(m, PULL, ORIGIN, m.OptionDefault(BRANCH, MASTER))
|
||||||
}
|
}
|
||||||
}},
|
}},
|
||||||
"inner": {Help: "编辑器", Hand: func(m *ice.Message, arg ...string) {
|
DIFF: {Hand: func(m *ice.Message, arg ...string) {
|
||||||
if len(arg) == 0 || arg[0] != ice.RUN {
|
if len(arg) == 0 || arg[0] != ice.RUN {
|
||||||
arg = []string{_repos_path(arg[0]), kit.Select("README.md", arg, 3)}
|
arg = []string{path.Join(arg[:3]...), kit.Select("README.md", arg, 3)}
|
||||||
} else if kit.Select("", arg, 1) != ctx.ACTION {
|
} else if kit.Select("", arg, 1) != ctx.ACTION {
|
||||||
if dir := _git_dir(_repos_path(m.Option(REPOS))); len(arg) < 3 {
|
ls := kit.Split(kit.Select(arg[1], m.Option(nfs.DIR_ROOT)), nfs.PS)
|
||||||
_repos_dir(m, dir, m.Option(BRANCH), m.Option(COMMIT), kit.Select("", arg, 1), nil)
|
if dir := _git_dir(_repos_path(ls[0])); len(arg) < 3 {
|
||||||
|
_repos_dir(m, dir, ls[1], ls[2], kit.Select("", arg, 1), nil)
|
||||||
} else {
|
} else {
|
||||||
_repos_cat(m, dir, m.Option(BRANCH), m.Option(COMMIT), arg[2])
|
_repos_cat(m, dir, ls[1], ls[2], arg[2])
|
||||||
// ctx.DisplayLocal(m, "code/inner.js")
|
ctx.DisplayLocal(m, "code/inner.js")
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
ctx.ProcessField(m, "", arg, arg...)
|
ctx.ProcessField(m, web.CODE_INNER, arg, arg...)
|
||||||
}},
|
}},
|
||||||
}, mdb.HashAction(mdb.SHORT, REPOS, mdb.FIELD, "time,repos,branch,commit,origin"), mdb.ClearOnExitHashAction()), Hand: func(m *ice.Message, arg ...string) {
|
}, mdb.HashAction(mdb.SHORT, REPOS, mdb.FIELD, "time,repos,branch,commit,origin"), mdb.ClearOnExitHashAction()), Hand: func(m *ice.Message, arg ...string) {
|
||||||
if len(arg) == 0 || arg[0] == "" {
|
if len(arg) == 0 || arg[0] == "" {
|
||||||
@ -280,7 +256,7 @@ func init() {
|
|||||||
_repos_dir(m, dir, arg[1], arg[2], kit.Select("", arg, 3), nil)
|
_repos_dir(m, dir, arg[1], arg[2], kit.Select("", arg, 3), nil)
|
||||||
return
|
return
|
||||||
} else {
|
} else {
|
||||||
m.Cmdy("", "inner", arg)
|
m.Cmdy("", DIFF, arg)
|
||||||
}
|
}
|
||||||
m.StatusTimeCount()
|
m.StatusTimeCount()
|
||||||
}},
|
}},
|
||||||
|
@ -111,20 +111,21 @@ func _status_list(m *ice.Message) (files, adds, dels int, last time.Time) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
INSTEADOF = "insteadof"
|
||||||
|
OAUTH = "oauth"
|
||||||
PULL = "pull"
|
PULL = "pull"
|
||||||
PUSH = "push"
|
PUSH = "push"
|
||||||
DIFF = "diff"
|
DIFF = "diff"
|
||||||
TAGS = "tags"
|
|
||||||
STASH = "stash"
|
|
||||||
COMMIT = "commit"
|
|
||||||
|
|
||||||
ADD = "add"
|
ADD = "add"
|
||||||
OPT = "opt"
|
OPT = "opt"
|
||||||
FIX = "fix"
|
FIX = "fix"
|
||||||
|
COMMIT = "commit"
|
||||||
|
STASH = "stash"
|
||||||
TAG = "tag"
|
TAG = "tag"
|
||||||
|
|
||||||
COMMENT = "comment"
|
TAGS = "tags"
|
||||||
VERSION = "version"
|
VERSION = "version"
|
||||||
|
COMMENT = "comment"
|
||||||
)
|
)
|
||||||
const STATUS = "status"
|
const STATUS = "status"
|
||||||
|
|
||||||
@ -133,7 +134,7 @@ func init() {
|
|||||||
STATUS: {Name: "status repos:text auto", Help: "代码库", Actions: ice.MergeActions(ice.Actions{
|
STATUS: {Name: "status repos:text auto", Help: "代码库", Actions: ice.MergeActions(ice.Actions{
|
||||||
mdb.INPUTS: {Hand: func(m *ice.Message, arg ...string) {
|
mdb.INPUTS: {Hand: func(m *ice.Message, arg ...string) {
|
||||||
switch m.Option(ctx.ACTION) {
|
switch m.Option(ctx.ACTION) {
|
||||||
case "insteadof":
|
case INSTEADOF:
|
||||||
switch arg[0] {
|
switch arg[0] {
|
||||||
case nfs.FROM:
|
case nfs.FROM:
|
||||||
m.Push(arg[0], kit.MergeURL2(ice.Info.Make.Remote, ice.PS))
|
m.Push(arg[0], kit.MergeURL2(ice.Info.Make.Remote, ice.PS))
|
||||||
@ -162,8 +163,14 @@ func init() {
|
|||||||
_configs_set(m, USER_NAME, m.Option(aaa.USERNAME))
|
_configs_set(m, USER_NAME, m.Option(aaa.USERNAME))
|
||||||
_configs_set(m, USER_EMAIL, m.Option(aaa.EMAIL))
|
_configs_set(m, USER_EMAIL, m.Option(aaa.EMAIL))
|
||||||
}},
|
}},
|
||||||
INIT: {Name: "init origin*='https://shylinux.com/x/volcanos' name path", Help: "克隆", Hand: func(m *ice.Message, arg ...string) {
|
INSTEADOF: {Name: "insteadof from* to", Help: "代理", Hand: func(m *ice.Message, arg ...string) {
|
||||||
m.Cmdy(REPOS, mdb.CREATE)
|
m.Cmd(CONFIGS, func(value ice.Maps) {
|
||||||
|
kit.If(value[mdb.VALUE] == m.Option(nfs.FROM), func() { _configs_set(m, "--unset", value[mdb.NAME]) })
|
||||||
|
})
|
||||||
|
kit.If(m.Option(nfs.TO), func() { _git_cmd(m, CONFIG, "--global", "url."+m.Option(nfs.TO)+".insteadof", m.Option(nfs.FROM)) })
|
||||||
|
}},
|
||||||
|
OAUTH: {Help: "授权", Hand: func(m *ice.Message, arg ...string) {
|
||||||
|
m.ProcessOpen(kit.MergeURL2(kit.Select(ice.Info.Make.Remote, _git_remote(m)), "/chat/cmd/web.code.git.token", aaa.USERNAME, m.Option(ice.MSG_USERNAME), tcp.HOST, web.UserHost(m)))
|
||||||
}},
|
}},
|
||||||
PULL: {Help: "下载", Hand: func(m *ice.Message, arg ...string) {
|
PULL: {Help: "下载", Hand: func(m *ice.Message, arg ...string) {
|
||||||
_status_each(m, "", cli.SYSTEM, GIT, PULL)
|
_status_each(m, "", cli.SYSTEM, GIT, PULL)
|
||||||
@ -180,28 +187,17 @@ func init() {
|
|||||||
_repos_cmd(m, m.Option(REPOS), COMMIT, "-am", m.Option(ctx.ACTION)+ice.SP+m.Option(COMMENT))
|
_repos_cmd(m, m.Option(REPOS), COMMIT, "-am", m.Option(ctx.ACTION)+ice.SP+m.Option(COMMENT))
|
||||||
m.ProcessBack()
|
m.ProcessBack()
|
||||||
}},
|
}},
|
||||||
|
STASH: {Help: "缓存", Hand: func(m *ice.Message, arg ...string) { _repos_cmd(m, kit.Select(m.Option(REPOS), arg, 0), STASH) }},
|
||||||
TAG: {Name: "tag version", Help: "标签", Hand: func(m *ice.Message, arg ...string) {
|
TAG: {Name: "tag version", Help: "标签", Hand: func(m *ice.Message, arg ...string) {
|
||||||
kit.If(m.Option(VERSION) == "", func() { m.Option(VERSION, _status_tag(m, m.Option(TAGS))) })
|
kit.If(m.Option(VERSION) == "", func() { m.Option(VERSION, _status_tag(m, m.Option(TAGS))) })
|
||||||
_repos_cmd(m, m.Option(REPOS), TAG, m.Option(VERSION))
|
_repos_cmd(m, m.Option(REPOS), TAG, m.Option(VERSION))
|
||||||
_repos_cmd(m, m.Option(REPOS), PUSH, "--tags")
|
_repos_cmd(m, m.Option(REPOS), PUSH, "--tags")
|
||||||
ctx.ProcessRefresh(m)
|
ctx.ProcessRefresh(m)
|
||||||
}},
|
}},
|
||||||
STASH: {Help: "缓存", Hand: func(m *ice.Message, arg ...string) {
|
|
||||||
_repos_cmd(m, kit.Select(m.Option(REPOS), arg, 0), STASH)
|
|
||||||
}},
|
|
||||||
nfs.TRASH: {Hand: func(m *ice.Message, arg ...string) {
|
nfs.TRASH: {Hand: func(m *ice.Message, arg ...string) {
|
||||||
m.Assert(m.Option(REPOS) != "" && m.Option(nfs.FILE) != "")
|
m.Assert(m.Option(REPOS) != "" && m.Option(nfs.FILE) != "")
|
||||||
nfs.Trash(m, path.Join(_repos_path(m.Option(REPOS)), m.Option(nfs.FILE)))
|
nfs.Trash(m, path.Join(_repos_path(m.Option(REPOS)), m.Option(nfs.FILE)))
|
||||||
}},
|
}},
|
||||||
"insteadof": {Name: "insteadof from* to", Help: "代理", Hand: func(m *ice.Message, arg ...string) {
|
|
||||||
m.Cmd(CONFIGS, func(value ice.Maps) {
|
|
||||||
kit.If(value[mdb.VALUE] == m.Option(nfs.FROM), func() { _configs_set(m, "--unset", value[mdb.NAME]) })
|
|
||||||
})
|
|
||||||
kit.If(m.Option(nfs.TO), func() { _git_cmd(m, CONFIG, "--global", "url."+m.Option(nfs.TO)+".insteadof", m.Option(nfs.FROM)) })
|
|
||||||
}},
|
|
||||||
"oauth": {Help: "授权", Hand: func(m *ice.Message, arg ...string) {
|
|
||||||
m.ProcessOpen(kit.MergeURL2(kit.Select(ice.Info.Make.Remote, _git_remote(m)), "/chat/cmd/web.code.git.token", aaa.USERNAME, m.Option(ice.MSG_USERNAME), tcp.HOST, web.UserHost(m)))
|
|
||||||
}},
|
|
||||||
web.DREAM_TABLES: {Hand: func(m *ice.Message, arg ...string) {
|
web.DREAM_TABLES: {Hand: func(m *ice.Message, arg ...string) {
|
||||||
if m.Option(mdb.TYPE) != web.WORKER {
|
if m.Option(mdb.TYPE) != web.WORKER {
|
||||||
return
|
return
|
||||||
|
Loading…
x
Reference in New Issue
Block a user