forked from x/icebergs
opt git
This commit is contained in:
parent
6852ba21be
commit
108001e500
@ -174,6 +174,9 @@ func init() {
|
||||
if r.Method != http.MethodGet {
|
||||
return false
|
||||
}
|
||||
if strings.HasSuffix(r.URL.Path, "/") {
|
||||
return false
|
||||
}
|
||||
if !strings.HasPrefix(r.Header.Get(web.UserAgent), "Mozilla") {
|
||||
return false
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package wiki
|
||||
|
||||
import (
|
||||
"net/url"
|
||||
"path"
|
||||
"strings"
|
||||
|
||||
@ -14,7 +15,8 @@ func _refer_show(m *ice.Message, text string, arg ...string) {
|
||||
list := [][]string{}
|
||||
for _, v := range kit.Split(strings.TrimSpace(text), ice.NL, ice.NL) {
|
||||
if ls := kit.Split(v, " ", " "); len(ls) == 1 {
|
||||
list = append(list, []string{path.Base(ls[0]), ls[0]})
|
||||
name, _ := url.QueryUnescape(path.Base(ls[0]))
|
||||
list = append(list, []string{kit.Select(ls[0], name), ls[0]})
|
||||
} else {
|
||||
list = append(list, ls)
|
||||
}
|
||||
|
21
exec.go
21
exec.go
@ -3,6 +3,7 @@ package ice
|
||||
import (
|
||||
"errors"
|
||||
"io"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
kit "shylinux.com/x/toolkits"
|
||||
@ -59,6 +60,26 @@ func (m *Message) Sleep(d string, arg ...Any) *Message {
|
||||
func (m *Message) Sleep300ms(arg ...Any) *Message { return m.Sleep("300ms", arg...) }
|
||||
func (m *Message) Sleep30ms(arg ...Any) *Message { return m.Sleep("30ms", arg...) }
|
||||
func (m *Message) Sleep3s(arg ...Any) *Message { return m.Sleep("3s", arg...) }
|
||||
func (m *Message) TableGo(cb Any) *Message {
|
||||
wg, lock := sync.WaitGroup{}, &task.Lock{}
|
||||
defer wg.Wait()
|
||||
m.Tables(func(value Maps) {
|
||||
wg.Add(1)
|
||||
task.Put(kit.FileLine(cb, 3), func(*task.Task) error {
|
||||
defer wg.Done()
|
||||
switch cb := cb.(type) {
|
||||
case func(Maps, *task.Lock):
|
||||
cb(value, lock)
|
||||
case func(Maps):
|
||||
cb(value)
|
||||
default:
|
||||
m.ErrorNotImplement(cb)
|
||||
}
|
||||
return nil
|
||||
})
|
||||
})
|
||||
return m
|
||||
}
|
||||
func (m *Message) Go(cb Any) *Message {
|
||||
task.Put(kit.FileLine(cb, 3), func(task *task.Task) error {
|
||||
m.TryCatch(m, true, func(m *Message) {
|
||||
|
@ -13,6 +13,7 @@ import (
|
||||
"shylinux.com/x/icebergs/base/web"
|
||||
"shylinux.com/x/icebergs/core/code"
|
||||
kit "shylinux.com/x/toolkits"
|
||||
"shylinux.com/x/toolkits/task"
|
||||
)
|
||||
|
||||
func _status_tag(m *ice.Message, tags string) string {
|
||||
@ -123,10 +124,17 @@ func _status_stat(m *ice.Message, files, adds, dels int) (int, int, int) {
|
||||
return files, adds, dels
|
||||
}
|
||||
func _status_list(m *ice.Message) (files, adds, dels int, last time.Time) {
|
||||
m.Cmd(REPOS, ice.OptionFields("name,path"), func(value ice.Maps) {
|
||||
m.Option(cli.CMD_DIR, value[nfs.PATH])
|
||||
diff := _git_cmds(m, STATUS, "-sb")
|
||||
tags := _git_cmds(m, "describe", "--tags")
|
||||
m.Cmd(REPOS, ice.OptionFields("name,path")).TableGo(func(value ice.Maps, lock *task.Lock) {
|
||||
msg := m.Spawn(kit.Dict(cli.CMD_DIR, value[nfs.PATH]))
|
||||
diff := _git_cmds(msg, STATUS, "-sb")
|
||||
tags := _git_cmds(msg, "describe", "--tags")
|
||||
_files, _adds, _dels := _status_stat(msg, 0, 0, 0)
|
||||
now, _ := time.Parse("2006-01-02 15:04:05 -0700", strings.TrimSpace(_git_cmds(msg, "log", `--pretty=%cd`, "--date=iso", "-n1")))
|
||||
|
||||
defer lock.Lock()()
|
||||
if files, adds, dels = files+_files, adds+_adds, dels+_dels; now.After(last) {
|
||||
last = now
|
||||
}
|
||||
|
||||
for _, v := range strings.Split(strings.TrimSpace(diff), ice.NL) {
|
||||
if v == "" {
|
||||
@ -134,7 +142,7 @@ func _status_list(m *ice.Message) (files, adds, dels int, last time.Time) {
|
||||
}
|
||||
vs := strings.SplitN(strings.TrimSpace(v), ice.SP, 2)
|
||||
switch kit.Ext(vs[1]) {
|
||||
case "swp", "swo", "bin", "var":
|
||||
case "swp", "swo", ice.BIN, ice.VAR:
|
||||
continue
|
||||
}
|
||||
|
||||
@ -165,12 +173,6 @@ func _status_list(m *ice.Message) (files, adds, dels int, last time.Time) {
|
||||
}
|
||||
m.PushButton(list)
|
||||
}
|
||||
|
||||
files, adds, dels = _status_stat(m, files, adds, dels)
|
||||
now, _ := time.Parse("2006-01-02 15:04:05 -0700", strings.TrimSpace(_git_cmds(m, "log", `--pretty=%cd`, "--date=iso", "-n1")))
|
||||
if now.After(last) {
|
||||
last = now
|
||||
}
|
||||
})
|
||||
return
|
||||
}
|
||||
@ -320,7 +322,7 @@ func init() {
|
||||
if len(arg) == 0 {
|
||||
m.Action(PULL, MAKE, PUSH, TAGS, PIE, code.PUBLISH)
|
||||
files, adds, dels, last := _status_list(m)
|
||||
m.Status("files", files, "adds", adds, "dels", dels, "last", last.Format(ice.MOD_TIME))
|
||||
m.StatusTime("files", files, "adds", adds, "dels", dels, "last", last.Format(ice.MOD_TIME))
|
||||
web.Toast3s(m, kit.Format("files: %d, adds: %d, dels: %d", files, adds, dels), ice.CONTEXTS)
|
||||
return
|
||||
}
|
||||
|
@ -3,7 +3,6 @@ package git
|
||||
import (
|
||||
"path"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
ice "shylinux.com/x/icebergs"
|
||||
@ -51,34 +50,27 @@ func init() {
|
||||
}
|
||||
|
||||
// 提交统计
|
||||
wg, lock := &sync.WaitGroup{}, &task.Lock{}
|
||||
days, commit, adds, dels, rest := 0, 0, 0, 0, 0
|
||||
m.Cmd(REPOS, ice.OptionFields("name,path"), func(value ice.Maps) {
|
||||
m.Cmd(REPOS, ice.OptionFields("name,path")).TableGo(func(value ice.Maps, lock *task.Lock) {
|
||||
if m.Config(kit.Keys("skip", value[REPOS])) == ice.TRUE {
|
||||
return
|
||||
}
|
||||
msg := m.Cmd("_sum", value[nfs.PATH], mdb.TOTAL, "10000")
|
||||
|
||||
wg.Add(1)
|
||||
m.Go(func() {
|
||||
defer wg.Done()
|
||||
msg := m.Cmd("_sum", value[nfs.PATH], mdb.TOTAL, "10000")
|
||||
|
||||
defer lock.Lock()()
|
||||
msg.Tables(func(value ice.Maps) {
|
||||
if kit.Int(value["days"]) > days {
|
||||
days = kit.Int(value["days"])
|
||||
}
|
||||
commit += kit.Int(value["commit"])
|
||||
adds += kit.Int(value["adds"])
|
||||
dels += kit.Int(value["dels"])
|
||||
rest += kit.Int(value["rest"])
|
||||
})
|
||||
|
||||
m.Push(REPOS, value[REPOS])
|
||||
m.Copy(msg)
|
||||
defer lock.Lock()()
|
||||
msg.Tables(func(value ice.Maps) {
|
||||
if kit.Int(value["days"]) > days {
|
||||
days = kit.Int(value["days"])
|
||||
}
|
||||
commit += kit.Int(value["commit"])
|
||||
adds += kit.Int(value["adds"])
|
||||
dels += kit.Int(value["dels"])
|
||||
rest += kit.Int(value["rest"])
|
||||
})
|
||||
|
||||
m.Push(REPOS, value[REPOS])
|
||||
m.Copy(msg)
|
||||
})
|
||||
wg.Wait()
|
||||
|
||||
m.Push(REPOS, mdb.TOTAL)
|
||||
m.Push("tags", "v3.0.0")
|
||||
|
@ -23,14 +23,12 @@ func _wx_sign(m *ice.Message, nonce, stamp string) string {
|
||||
kit.Format("timestamp=%s", stamp),
|
||||
kit.Format("noncestr=%s", nonce),
|
||||
)), "&")
|
||||
m.Debug("what %v", text)
|
||||
return kit.Format(sha1.Sum([]byte(text)))
|
||||
}
|
||||
func _wx_config(m *ice.Message, nonce string) {
|
||||
m.Option(APPID, m.Config(APPID))
|
||||
m.Option(ssh.SCRIPT, m.Config(ssh.SCRIPT))
|
||||
m.Option("signature", _wx_sign(m, m.Option("noncestr", nonce), m.Option("timestamp", kit.Format(time.Now().Unix()))))
|
||||
m.Option("debug", "true")
|
||||
}
|
||||
func _wx_check(m *ice.Message) {
|
||||
check := kit.Sort([]string{m.Config(TOKEN), m.Option("timestamp"), m.Option("nonce")})
|
||||
|
Loading…
x
Reference in New Issue
Block a user