mirror of
https://shylinux.com/x/icebergs
synced 2025-04-26 17:44:05 +08:00
opt some
This commit is contained in:
parent
096553967d
commit
be89a05922
@ -289,7 +289,7 @@ func init() {
|
|||||||
_repos_cmd(m, m.Option(REPOS), "checkout", m.Option(BRANCH))
|
_repos_cmd(m, m.Option(REPOS), "checkout", m.Option(BRANCH))
|
||||||
}},
|
}},
|
||||||
"oauth": {Help: "授权", Hand: func(m *ice.Message, arg ...string) {
|
"oauth": {Help: "授权", Hand: func(m *ice.Message, arg ...string) {
|
||||||
m.ProcessOpen(kit.MergeURL2(ice.Info.Make.Remote, "/chat/cmd/web.code.git.token",
|
m.ProcessOpen(kit.MergeURL2(m.Cmdx(cli.SYSTEM, "git", "remote", "get-url", "origin"), "/chat/cmd/web.code.git.token",
|
||||||
aaa.USERNAME, m.Option(ice.MSG_USERNAME),
|
aaa.USERNAME, m.Option(ice.MSG_USERNAME),
|
||||||
tcp.HOST, m.Option(ice.MSG_USERHOST)))
|
tcp.HOST, m.Option(ice.MSG_USERHOST)))
|
||||||
}},
|
}},
|
||||||
@ -336,7 +336,7 @@ func init() {
|
|||||||
defer web.ToastProcess(m)()
|
defer web.ToastProcess(m)()
|
||||||
files, adds, dels, last := _status_list(m)
|
files, adds, dels, last := _status_list(m)
|
||||||
m.StatusTimeCount("files", files, "adds", adds, "dels", dels, "last", last.Format(ice.MOD_TIME))
|
m.StatusTimeCount("files", files, "adds", adds, "dels", dels, "last", last.Format(ice.MOD_TIME))
|
||||||
m.Action(PULL, PUSH, "insteadof", TOKEN, "oauth")
|
m.Action(PULL, PUSH, "insteadof", "oauth")
|
||||||
m.Sort("repos,type,file")
|
m.Sort("repos,type,file")
|
||||||
} else {
|
} else {
|
||||||
_repos_cmd(m, arg[0], DIFF)
|
_repos_cmd(m, arg[0], DIFF)
|
||||||
|
@ -15,16 +15,25 @@ import (
|
|||||||
const TOKEN = "token"
|
const TOKEN = "token"
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
const (
|
||||||
|
SET = "set"
|
||||||
|
GET = "get"
|
||||||
|
SID = "sid"
|
||||||
|
)
|
||||||
|
const FILE = ".git-credentials"
|
||||||
Index.MergeCommands(ice.Commands{
|
Index.MergeCommands(ice.Commands{
|
||||||
TOKEN: {Name: "token username auto prunes", Actions: ice.MergeActions(ice.Actions{
|
TOKEN: {Name: "token username auto prunes", Actions: ice.MergeActions(ice.Actions{
|
||||||
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { aaa.White(m, "token.sid") }},
|
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { aaa.White(m, kit.Keys(TOKEN, SID)) }},
|
||||||
web.PP("set"): {Hand: func(m *ice.Message, arg ...string) {
|
web.PP(SET): {Hand: func(m *ice.Message, arg ...string) {
|
||||||
list := []string{m.Option(TOKEN)}
|
list := []string{m.Option(TOKEN)}
|
||||||
m.Cmd(nfs.CAT, kit.HomePath(".git-credentials"), func(line string) { list = append(list, line) })
|
m.Cmd(nfs.CAT, kit.HomePath(FILE), func(line string) {
|
||||||
m.Cmd(nfs.SAVE, kit.HomePath(".git-credentials"), strings.Join(list, ice.NL)+ice.NL)
|
kit.If(line != list[0], func() { list = append(list, line) })
|
||||||
|
})
|
||||||
|
m.Cmd(nfs.SAVE, kit.HomePath(FILE), strings.Join(list, ice.NL)+ice.NL)
|
||||||
|
m.RenderResult(m.Cmdx(nfs.CAT, ice.SRC_TEMPLATE+"web/close.html"))
|
||||||
}},
|
}},
|
||||||
web.PP("get"): {Hand: func(m *ice.Message, arg ...string) {
|
web.PP(GET): {Hand: func(m *ice.Message, arg ...string) {
|
||||||
m.Cmd(nfs.CAT, kit.HomePath(".git-credentials"), func(text string) {
|
m.Cmd(nfs.CAT, kit.HomePath(FILE), func(text string) {
|
||||||
if strings.HasSuffix(text, ice.AT+arg[0]) {
|
if strings.HasSuffix(text, ice.AT+arg[0]) {
|
||||||
u := kit.ParseURL(text)
|
u := kit.ParseURL(text)
|
||||||
if p, ok := u.User.Password(); ok {
|
if p, ok := u.User.Password(); ok {
|
||||||
@ -34,8 +43,8 @@ func init() {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
}},
|
}},
|
||||||
web.PP("sid"): {Hand: func(m *ice.Message, arg ...string) {
|
web.PP(SID): {Hand: func(m *ice.Message, arg ...string) {
|
||||||
if m.Cmd(TOKEN, arg[0]).Append(TOKEN) == arg[1] {
|
if len(arg) > 1 && m.Cmd(TOKEN, arg[0]).Append(TOKEN) == arg[1] {
|
||||||
web.RenderCookie(m, aaa.SessCreate(m, arg[0]))
|
web.RenderCookie(m, aaa.SessCreate(m, arg[0]))
|
||||||
m.Echo(ice.OK)
|
m.Echo(ice.OK)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user