forked from x/icebergs
opt some
This commit is contained in:
parent
2864019132
commit
6a7433f0e5
@ -94,7 +94,7 @@ func _system_exec(m *ice.Message, cmd *exec.Cmd) {
|
|||||||
if m.IsErr() {
|
if m.IsErr() {
|
||||||
m.Option(ice.MSG_ARGS, kit.Simple(http.StatusBadRequest, cmd.Args, err.String()))
|
m.Option(ice.MSG_ARGS, kit.Simple(http.StatusBadRequest, cmd.Args, err.String()))
|
||||||
m.Echo(strings.TrimRight(err.String(), ice.NL))
|
m.Echo(strings.TrimRight(err.String(), ice.NL))
|
||||||
// m.Debug("%s %s", err, out)
|
m.Debug("%s %s", err, out)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
4
exec.go
4
exec.go
@ -35,6 +35,10 @@ func (m *Message) Assert(expr Any) bool {
|
|||||||
switch e := expr.(type) {
|
switch e := expr.(type) {
|
||||||
case nil:
|
case nil:
|
||||||
return true
|
return true
|
||||||
|
case string:
|
||||||
|
if expr != "" {
|
||||||
|
return true
|
||||||
|
}
|
||||||
case bool:
|
case bool:
|
||||||
if e == true {
|
if e == true {
|
||||||
return true
|
return true
|
||||||
|
@ -43,19 +43,22 @@ func _server_login(m *ice.Message) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
func _server_param(m *ice.Message, arg ...string) (string, string) {
|
func _server_param(m *ice.Message, arg ...string) (string, string) {
|
||||||
repos, service := path.Join(arg...), kit.Select(arg[len(arg)-1], m.Option("service"))
|
repos, service := path.Join(kit.Slice(arg, 0, 1)...), kit.Select(arg[len(arg)-1], m.Option("service"))
|
||||||
switch {
|
switch {
|
||||||
case strings.HasSuffix(repos, INFO_REFS):
|
case strings.HasSuffix(repos, INFO_REFS):
|
||||||
repos = strings.TrimSuffix(repos, INFO_REFS)
|
repos = strings.TrimSuffix(repos, INFO_REFS)
|
||||||
default:
|
default:
|
||||||
repos = strings.TrimSuffix(repos, service)
|
repos = strings.TrimSuffix(repos, service)
|
||||||
}
|
}
|
||||||
|
m.Debug("what %v", repos)
|
||||||
return kit.Path(ice.USR_LOCAL_REPOS, strings.TrimSuffix(repos, ".git/")), strings.TrimPrefix(service, "git-")
|
return kit.Path(ice.USR_LOCAL_REPOS, strings.TrimSuffix(repos, ".git/")), strings.TrimPrefix(service, "git-")
|
||||||
}
|
}
|
||||||
func _server_repos(m *ice.Message, arg ...string) error {
|
func _server_repos(m *ice.Message, arg ...string) error {
|
||||||
repos, service := _server_param(m, arg...)
|
repos, service := _server_param(m, arg...)
|
||||||
if m.Option(cli.CMD_DIR, repos); strings.HasSuffix(path.Join(arg...), INFO_REFS) {
|
if m.Option(cli.CMD_DIR, repos); strings.HasSuffix(path.Join(arg...), INFO_REFS) {
|
||||||
web.RenderType(m.W, "", kit.Format("application/x-git-%s-advertisement", service))
|
web.RenderType(m.W, "", kit.Format("application/x-git-%s-advertisement", service))
|
||||||
|
// _server_writer(m, "# service=git-"+service+ice.NL, m.Cmd(cli.SYSTEM, "ice.bin", "web.git.repos", service, repos).Results())
|
||||||
|
// return nil
|
||||||
_server_writer(m, "# service=git-"+service+ice.NL, _git_cmds(m, service, "--stateless-rpc", "--advertise-refs", ice.PT))
|
_server_writer(m, "# service=git-"+service+ice.NL, _git_cmds(m, service, "--stateless-rpc", "--advertise-refs", ice.PT))
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -66,6 +69,10 @@ func _server_repos(m *ice.Message, arg ...string) error {
|
|||||||
defer reader.Close()
|
defer reader.Close()
|
||||||
m.Options(cli.CMD_INPUT, reader, cli.CMD_OUTPUT, m.W)
|
m.Options(cli.CMD_INPUT, reader, cli.CMD_OUTPUT, m.W)
|
||||||
web.RenderType(m.W, "", kit.Format("application/x-git-%s-result", service))
|
web.RenderType(m.W, "", kit.Format("application/x-git-%s-result", service))
|
||||||
|
|
||||||
|
// m.Cmd(cli.SYSTEM, "ice.bin", "web.git.repos", service, repos)
|
||||||
|
// return nil
|
||||||
|
//
|
||||||
_git_cmd(m, service, "--stateless-rpc", ice.PT)
|
_git_cmd(m, service, "--stateless-rpc", ice.PT)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user