mirror of
https://shylinux.com/x/icebergs
synced 2025-04-26 01:24:05 +08:00
opt git
This commit is contained in:
parent
bc009120e8
commit
5aa39a40cb
6
go.sum
6
go.sum
@ -1,7 +1,12 @@
|
|||||||
|
github.com/AaronO/go-git-http v0.0.0-20161214145340-1d9485b3a98f h1:x/RDwGRneK2/891S2o7KhZt3MhHMSCssoeDOfvolTMk=
|
||||||
github.com/AaronO/go-git-http v0.0.0-20161214145340-1d9485b3a98f/go.mod h1:+6Yuq73F9068Na+mSBNXCvyuxvgw4f/g5ii40e3U8Sc=
|
github.com/AaronO/go-git-http v0.0.0-20161214145340-1d9485b3a98f/go.mod h1:+6Yuq73F9068Na+mSBNXCvyuxvgw4f/g5ii40e3U8Sc=
|
||||||
|
github.com/Baozisoftware/qrcode-terminal-go v0.0.0-20170407111555-c0650d8dff0f h1:2dk3eOnYllh+wUOuDhOoC2vUVoJF/5z478ryJ+wzEII=
|
||||||
github.com/Baozisoftware/qrcode-terminal-go v0.0.0-20170407111555-c0650d8dff0f/go.mod h1:4a58ifQTEe2uwwsaqbh3i2un5/CBPg+At/qHpt18Tmk=
|
github.com/Baozisoftware/qrcode-terminal-go v0.0.0-20170407111555-c0650d8dff0f/go.mod h1:4a58ifQTEe2uwwsaqbh3i2un5/CBPg+At/qHpt18Tmk=
|
||||||
|
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/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
|
||||||
|
github.com/mattn/go-colorable v0.1.8 h1:c1ghPdyEDarC70ftn0y+A/Ee++9zz8ljHG1b13eJ0s8=
|
||||||
github.com/mattn/go-colorable v0.1.8/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
|
github.com/mattn/go-colorable v0.1.8/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
|
||||||
|
github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY=
|
||||||
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
|
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
|
||||||
github.com/shylinux/toolkits v0.2.3 h1:UdE5dUKtc+iVeco9sFrlj98BxVJADYoLNeywTnLrSMc=
|
github.com/shylinux/toolkits v0.2.3 h1:UdE5dUKtc+iVeco9sFrlj98BxVJADYoLNeywTnLrSMc=
|
||||||
github.com/shylinux/toolkits v0.2.3/go.mod h1:oMwi/N00I2cXenmcAkqikEncTzB4u5JhTQ9mO5xj7sY=
|
github.com/shylinux/toolkits v0.2.3/go.mod h1:oMwi/N00I2cXenmcAkqikEncTzB4u5JhTQ9mO5xj7sY=
|
||||||
@ -11,6 +16,7 @@ golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2/go.mod h1:T9bdIzuCu7OtxOm
|
|||||||
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
||||||
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/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/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68 h1:nxC68pudNYkKU6jWhgrqdreuFiOQWj1Fs7T3VrH4Pjw=
|
||||||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||||
|
@ -6,8 +6,8 @@ refer `
|
|||||||
`
|
`
|
||||||
|
|
||||||
chapter "源码"
|
chapter "源码"
|
||||||
field git web.code.git.git
|
field "安装" web.code.git.git
|
||||||
field git web.code.inner args `usr/install/git-1.8.3.1/ shell.c 145`
|
field "源码" web.code.inner args `usr/install/git-1.8.3.1/ shell.c 145`
|
||||||
|
|
||||||
section "构建"
|
section "构建"
|
||||||
spark shell `
|
spark shell `
|
||||||
@ -33,6 +33,7 @@ field "代码库" web.code.git.repos
|
|||||||
field "统计量" web.code.git.total
|
field "统计量" web.code.git.total
|
||||||
field "趋势图" web.code.git.trend args `icebergs`
|
field "趋势图" web.code.git.trend args `icebergs`
|
||||||
field "架构图" web.code.git.spide args `icebergs`
|
field "架构图" web.code.git.spide args `icebergs`
|
||||||
|
field "配置键" web.code.git.config
|
||||||
field "状态机" web.code.git.status
|
field "状态机" web.code.git.status
|
||||||
field "服务器" web.code.git.server
|
field "服务器" web.code.git.server
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@ func init() {
|
|||||||
)},
|
)},
|
||||||
},
|
},
|
||||||
Commands: map[string]*ice.Command{
|
Commands: map[string]*ice.Command{
|
||||||
REPOS: {Name: "repos name path auto create", Help: "代码库", Action: map[string]*ice.Action{
|
REPOS: {Name: "repos name path auto create proxy", Help: "代码库", Action: map[string]*ice.Action{
|
||||||
mdb.CREATE: {Name: "create repos branch name path", Help: "添加", Hand: func(m *ice.Message, arg ...string) {
|
mdb.CREATE: {Name: "create repos branch name path", Help: "添加", Hand: func(m *ice.Message, arg ...string) {
|
||||||
m.Option(kit.MDB_NAME, kit.Select(strings.TrimSuffix(path.Base(m.Option(kit.SSH_REPOS)), ".git"), m.Option(kit.MDB_NAME)))
|
m.Option(kit.MDB_NAME, kit.Select(strings.TrimSuffix(path.Base(m.Option(kit.SSH_REPOS)), ".git"), m.Option(kit.MDB_NAME)))
|
||||||
m.Option(kit.MDB_PATH, kit.Select(path.Join(kit.SSH_USR, m.Option(kit.MDB_NAME)), m.Option(kit.MDB_PATH)))
|
m.Option(kit.MDB_PATH, kit.Select(path.Join(kit.SSH_USR, m.Option(kit.MDB_NAME)), m.Option(kit.MDB_PATH)))
|
||||||
@ -73,9 +73,12 @@ func init() {
|
|||||||
|
|
||||||
_repos_insert(m, m.Option(kit.MDB_NAME), m.Option(kit.MDB_PATH))
|
_repos_insert(m, m.Option(kit.MDB_NAME), m.Option(kit.MDB_PATH))
|
||||||
}},
|
}},
|
||||||
|
"proxy": {Name: "proxy from to", Help: "代理", Hand: func(m *ice.Message, arg ...string) {
|
||||||
|
m.Cmd(cli.SYSTEM, GIT, "config", "--global", fmt.Sprintf(`url.%s.insteadOf`, m.Option("to")), m.Option("from"))
|
||||||
|
}},
|
||||||
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||||
if len(arg) == 0 { // 仓库列表
|
if len(arg) == 0 { // 仓库列表
|
||||||
m.Option(mdb.FIELDS, "time,name,branch,commit")
|
m.Option(mdb.FIELDS, "time,name,branch,commit,remote")
|
||||||
m.Cmdy(mdb.SELECT, m.Prefix(REPOS), "", mdb.HASH)
|
m.Cmdy(mdb.SELECT, m.Prefix(REPOS), "", mdb.HASH)
|
||||||
m.Sort(kit.MDB_NAME)
|
m.Sort(kit.MDB_NAME)
|
||||||
return
|
return
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
package git
|
package git
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"os"
|
||||||
"path"
|
"path"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/AaronO/go-git-http"
|
"github.com/AaronO/go-git-http"
|
||||||
"github.com/AaronO/go-git-http/auth"
|
"github.com/AaronO/go-git-http/auth"
|
||||||
@ -22,29 +24,40 @@ func init() {
|
|||||||
SERVER: {Name: SERVER, Help: "服务器", Value: kit.Data(kit.MDB_PATH, "usr/local")},
|
SERVER: {Name: SERVER, Help: "服务器", Value: kit.Data(kit.MDB_PATH, "usr/local")},
|
||||||
},
|
},
|
||||||
Commands: map[string]*ice.Command{
|
Commands: map[string]*ice.Command{
|
||||||
web.WEB_LOGIN: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
|
||||||
m.Render(ice.RENDER_VOID)
|
|
||||||
}},
|
|
||||||
|
|
||||||
SERVER: {Name: "server path auto create", Help: "server", Action: map[string]*ice.Action{
|
SERVER: {Name: "server path auto create", Help: "server", Action: map[string]*ice.Action{
|
||||||
mdb.CREATE: {Name: "create name", Help: "添加", Hand: func(m *ice.Message, arg ...string) {
|
mdb.CREATE: {Name: "create name", Help: "添加", Hand: func(m *ice.Message, arg ...string) {
|
||||||
m.Option(cli.CMD_DIR, path.Join(m.Conf(SERVER, kit.META_PATH), REPOS))
|
m.Option(cli.CMD_DIR, path.Join(m.Conf(SERVER, kit.META_PATH), REPOS))
|
||||||
m.Cmd(cli.SYSTEM, GIT, INIT, "--bare", m.Option(kit.MDB_NAME))
|
m.Cmd(cli.SYSTEM, GIT, INIT, "--bare", m.Option(kit.MDB_NAME))
|
||||||
}},
|
}},
|
||||||
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||||
m.Option(nfs.DIR_ROOT, path.Join(m.Conf(SERVER, kit.META_PATH), REPOS))
|
if len(arg) == 0 {
|
||||||
m.Cmdy(nfs.DIR, "./")
|
m.Option(nfs.DIR_ROOT, path.Join(m.Conf(SERVER, kit.META_PATH), REPOS))
|
||||||
m.EchoScript("git remote add origin https://shylinux.com/code/git/repos/volcanos")
|
m.Cmdy(nfs.DIR, "./")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
m.Cmdy("_sum", path.Join("usr/local/repos", arg[0]))
|
||||||
}},
|
}},
|
||||||
|
|
||||||
|
web.WEB_LOGIN: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||||
|
m.Render(ice.RENDER_VOID)
|
||||||
|
}},
|
||||||
"/repos/": {Name: "/github.com/", Help: "/github.com/", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
"/repos/": {Name: "/github.com/", Help: "/github.com/", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||||
auth.Authenticator(func(info auth.AuthInfo) (bool, error) {
|
auth.Authenticator(func(info auth.AuthInfo) (bool, error) {
|
||||||
if !aaa.UserLogin(m, info.Username, info.Password) {
|
if !aaa.UserLogin(m, info.Username, info.Password) {
|
||||||
return false, nil
|
return false, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if info.Push && aaa.UserRole(m, info.Username) == aaa.VOID {
|
if info.Push {
|
||||||
return false, nil
|
if aaa.UserRole(m, info.Username) == aaa.VOID {
|
||||||
|
return false, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
m.Option(cli.CMD_DIR, path.Join(m.Conf(SERVER, kit.META_PATH), REPOS))
|
||||||
|
p := strings.Trim(path.Join(arg...), "info/refs")
|
||||||
|
if _, e := os.Stat(path.Join(m.Option(cli.CMD_DIR), p)); os.IsNotExist(e) {
|
||||||
|
m.Cmd(cli.SYSTEM, GIT, INIT, "--bare", p)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true, nil
|
return true, nil
|
||||||
|
@ -20,7 +20,7 @@ const STATUS = "status"
|
|||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
Index.Merge(&ice.Context{Commands: map[string]*ice.Command{
|
Index.Merge(&ice.Context{Commands: map[string]*ice.Command{
|
||||||
STATUS: {Name: "status name auto pull compile create commit", Help: "代码状态", Action: map[string]*ice.Action{
|
STATUS: {Name: "status name auto", Help: "代码状态", Action: map[string]*ice.Action{
|
||||||
PULL: {Name: "pull", Help: "下载", Hand: func(m *ice.Message, arg ...string) {
|
PULL: {Name: "pull", Help: "下载", Hand: func(m *ice.Message, arg ...string) {
|
||||||
m.Cmdy(cli.PROGRESS, mdb.CREATE, func(update func(name string, count, total int)) {
|
m.Cmdy(cli.PROGRESS, mdb.CREATE, func(update func(name string, count, total int)) {
|
||||||
count, total := 0, len(m.Confm(REPOS, kit.MDB_HASH))
|
count, total := 0, len(m.Confm(REPOS, kit.MDB_HASH))
|
||||||
@ -77,9 +77,11 @@ func init() {
|
|||||||
m.Richs(REPOS, nil, kit.Select(kit.MDB_FOREACH, arg, 0), func(key string, value map[string]interface{}) {
|
m.Richs(REPOS, nil, kit.Select(kit.MDB_FOREACH, arg, 0), func(key string, value map[string]interface{}) {
|
||||||
value = kit.GetMeta(value)
|
value = kit.GetMeta(value)
|
||||||
if m.Option(cli.CMD_DIR, value[kit.MDB_PATH]); len(arg) > 0 {
|
if m.Option(cli.CMD_DIR, value[kit.MDB_PATH]); len(arg) > 0 {
|
||||||
|
m.Option("_action", kit.Format([]string{"commit"}))
|
||||||
m.Echo(m.Cmdx(cli.SYSTEM, GIT, DIFF))
|
m.Echo(m.Cmdx(cli.SYSTEM, GIT, DIFF))
|
||||||
return // 更改详情
|
return // 更改详情
|
||||||
}
|
}
|
||||||
|
m.Option("_action", kit.Format([]string{"pull", "compile", "create"}))
|
||||||
|
|
||||||
// 更改列表
|
// 更改列表
|
||||||
for _, v := range strings.Split(strings.TrimSpace(m.Cmdx(cli.SYSTEM, GIT, STATUS, "-sb")), "\n") {
|
for _, v := range strings.Split(strings.TrimSpace(m.Cmdx(cli.SYSTEM, GIT, STATUS, "-sb")), "\n") {
|
||||||
|
@ -69,6 +69,9 @@ func init() {
|
|||||||
if s, e := os.Stat(arg[0] + "/.git"); e == nil && s.IsDir() {
|
if s, e := os.Stat(arg[0] + "/.git"); e == nil && s.IsDir() {
|
||||||
m.Option(cli.CMD_DIR, arg[0])
|
m.Option(cli.CMD_DIR, arg[0])
|
||||||
arg = arg[1:]
|
arg = arg[1:]
|
||||||
|
} else if s, e := os.Stat(arg[0] + "/refs"); e == nil && s.IsDir() {
|
||||||
|
m.Option(cli.CMD_DIR, arg[0])
|
||||||
|
arg = arg[1:]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user