1
0
forked from x/icebergs
This commit is contained in:
shaoying 2020-12-02 09:58:08 +08:00
parent 019b7426da
commit ecb21797b9
3 changed files with 45 additions and 8 deletions

View File

@ -15,6 +15,9 @@ import (
)
func _system_show(m *ice.Message, cmd *exec.Cmd) {
if r, ok := m.Optionv("input").(io.Reader); ok {
cmd.Stdin = r
}
if w, ok := m.Optionv("output").(io.WriteCloser); ok {
cmd.Stderr = w
cmd.Stdout = w

5
go.sum
View File

@ -3,7 +3,6 @@ github.com/Baozisoftware/qrcode-terminal-go v0.0.0-20170407111555-c0650d8dff0f/g
github.com/google/uuid v1.1.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc=
github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
github.com/kr/pty v1.1.1 h1:VkoXIwSboBpnk99O/KFauAEILuNHv5DVFKZMBN/gUgw=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/maruel/rs v0.0.0-20150922171536-2c81c4312fe4/go.mod h1:kcRFpEzolcEklV6rD7W95mG49/sbdX/PlFmd7ni3RvA=
github.com/mattn/go-colorable v0.1.8 h1:c1ghPdyEDarC70ftn0y+A/Ee++9zz8ljHG1b13eJ0s8=
@ -11,19 +10,15 @@ github.com/mattn/go-colorable v0.1.8/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope
github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY=
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
github.com/nareix/joy4 v0.0.0-20200507095837-05a4ffbb5369/go.mod h1:aFJ1ZwLjvHN4yEzE5Bkz8rD8/d8Vlj3UIuvz2yfET7I=
github.com/shylinux/toolkits v0.1.9 h1:gfQnXSBBuCtUueNF5eL0kZAjJS8pzODrjxIL0WynqsQ=
github.com/shylinux/toolkits v0.1.9/go.mod h1:Y68Ot6xOmo1bun67YvqC3chDGeU2gDxtsUnvVDGJm4g=
github.com/shylinux/toolkits v0.2.0 h1:ZMJGFqqgZBXxu2jUw2Zqu8Vx8KhEgWcMBnlH3cR+MPQ=
github.com/shylinux/toolkits v0.2.0/go.mod h1:Y68Ot6xOmo1bun67YvqC3chDGeU2gDxtsUnvVDGJm4g=
github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e h1:MRM5ITcdelLK2j1vwZ3Je0FKVCfqOLp5zO6trqMLYs0=
github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e/go.mod h1:XV66xRDqSt+GTGFMVlhk3ULuV0y9ZmzeVGR4mloJI3M=
github.com/tuotoo/qrcode v0.0.0-20190222102259-ac9c44189bf2/go.mod h1:lPnW9HVS0vJdeYyQtOvIvlXgZPNhUAhwz+z5r8AJk0Y=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550 h1:ObdrDkeb4kJdCP557AjRjq69pTHfNouLtWZG7j9rPN8=
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d h1:+R4KGOnez64A81RvjARKc4UT5/tI9ujCIVX+P5KiHuI=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae h1:/WDfKMnPU+m5M4xB+6x4kaepxRw6jWvR5iDRdvjHgy8=

View File

@ -2,6 +2,7 @@ package git
import (
"os"
"strings"
ice "github.com/shylinux/icebergs"
"github.com/shylinux/icebergs/base/cli"
@ -24,14 +25,52 @@ func init() {
m.Option(ice.RENDER_OUTPUT, ice.RENDER_RESULT)
}},
"/repos/": {Name: "repos", Help: "repos", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
m.Option(ice.MSG_USERNAME, "shy")
m.Option(cli.CMD_ENV,
"GIT_HTTP_EXPORT_ALL", "true",
"GIT_PROJECT_ROOT", kit.Path("./"),
"PATH_INFO", "/"+strings.Join(arg, "/"),
"REMOTE_USER", m.Option(ice.MSG_USERNAME),
"REMOTE_ADDR", m.Option(ice.MSG_USERNAME),
"GIT_COMMITTER_NAME", m.Option(ice.MSG_USERNAME),
"GIT_COMMITTER_EMAIL", m.Option(ice.MSG_USERNAME),
"REQUEST_METHOD", m.Option(ice.MSG_METHOD),
"CONTENT_TYPE", m.R.Header.Get(web.ContentType),
"GIT_HTTP_EXPORT_ALL", "true",
"QUERY_STRING", m.R.URL.RawQuery,
"PATH", os.Getenv("PATH"),
"PATH", "/Users/shaoying/miss/contexts/usr/install/git-1.8.3.1"+":"+os.Getenv("PATH"),
)
m.Cmdy(cli.SYSTEM, "/usr/lib/git-core/git-http-backend")
switch strings.Join(arg, "/") {
case "info/refs":
msg := m.Cmd(cli.SYSTEM, "/Users/shaoying/miss/contexts/usr/install/git-1.8.3.1"+"/"+"git-http-backend")
m.Cmd("nfs.file", "append", "hi.log", msg.Append(cli.CMD_ERR))
x := msg.Result()
ls := strings.Split(x, "\n")
for i, v := range ls {
vs := strings.SplitN(v, ": ", 2)
if strings.TrimSpace(v) == "" {
m.Echo(strings.Join(ls[i+1:], "\n") + "\n")
break
}
m.W.Header().Set(vs[0], vs[1])
}
case "git-upload-pack":
m.Option("input", m.R.Body)
defer m.R.Body.Close()
msg := m.Cmd(cli.SYSTEM, "/Users/shaoying/miss/contexts/usr/install/git-1.8.3.1"+"/"+"git-upload-pack", "--advertise-refs", kit.Path("./"))
m.Cmd("nfs.file", "append", "hi.log", msg.Append(cli.CMD_ERR))
x := msg.Result()
ls := strings.SplitN(x, "\n", 2)
m.Debug(" %v %v", len(x), x[:len(x)])
m.Render(ice.RENDER_OUTPUT, ice.RENDER_VOID)
m.W.Write([]byte(ls[1]))
}
}},
},
})