forked from x/icebergs
33 lines
1002 B
Go
33 lines
1002 B
Go
package git
|
|
|
|
import (
|
|
git "shylinux.com/x/go-git/v5"
|
|
ice "shylinux.com/x/icebergs"
|
|
"shylinux.com/x/icebergs/base/ctx"
|
|
"shylinux.com/x/icebergs/base/nfs"
|
|
"shylinux.com/x/icebergs/base/web"
|
|
kit "shylinux.com/x/toolkits"
|
|
)
|
|
|
|
func init() {
|
|
Index.MergeCommands(ice.Commands{
|
|
nfs.SOURCE: {Name: "source repos path file auto", Actions: ice.Actions{
|
|
CLONE: {Hand: func(m *ice.Message, arg ...string) {
|
|
kit.If(!kit.HasPrefix(m.Option(REPOS), "http"), func() { m.Option(REPOS, "https://"+m.Option(REPOS)) })
|
|
if _, err := git.PlainClone(m.Option(nfs.PATH), false, &git.CloneOptions{URL: m.Option(REPOS)}); m.WarnNotValid(err) {
|
|
m.ProcessRefresh()
|
|
}
|
|
}},
|
|
}, Hand: func(m *ice.Message, arg ...string) {
|
|
if len(arg) < 3 || arg[0] == ctx.ACTION {
|
|
m.Cmdy(web.CODE_INNER, arg)
|
|
} else if !nfs.Exists(m, arg[1]) {
|
|
m.EchoInfoButton("please clone repos", CLONE)
|
|
} else {
|
|
m.Options(nfs.PATH, arg[1], nfs.FILE, arg[2])
|
|
m.Cmdy(web.CODE_INNER, arg[1:])
|
|
}
|
|
}},
|
|
})
|
|
}
|