mirror of
https://shylinux.com/x/ContextOS
synced 2025-04-26 17:24:05 +08:00
add trends
This commit is contained in:
parent
2191cc3ec4
commit
3ef7047f89
@ -851,14 +851,14 @@ var Index = &ctx.Context{Name: "cli", Help: "管理中心",
|
|||||||
})
|
})
|
||||||
m.Cmdp(0, []string{"go build"}, []string{"cli.system", "go", "get"}, list)
|
m.Cmdp(0, []string{"go build"}, []string{"cli.system", "go", "get"}, list)
|
||||||
|
|
||||||
case "stats":
|
|
||||||
// 代码统计
|
|
||||||
m.Cmdy("nfs.dir", kit.Select("src", arg, 1), "dir_deep", "dir_type", "file", "dir_sort", "line", "int_r", "dir_select", "group", "")
|
|
||||||
|
|
||||||
case "stat":
|
case "stat":
|
||||||
// 代码统计
|
// 代码统计
|
||||||
m.Cmdy("nfs.dir", "src", "dir_deep", "dir_type", "file", "dir_sort", "line", "int_r")
|
m.Cmdy("nfs.dir", "src", "dir_deep", "dir_type", "file", "dir_sort", "line", "int_r")
|
||||||
|
|
||||||
|
case "stats":
|
||||||
|
// 代码统计
|
||||||
|
m.Cmdy("nfs.dir", kit.Select("src", arg, 1), "dir_deep", "dir_type", "file", "dir_sort", "line", "int_r", "dir_select", "group", "")
|
||||||
|
|
||||||
case "trend":
|
case "trend":
|
||||||
// 提交记录
|
// 提交记录
|
||||||
if len(arg) == 1 {
|
if len(arg) == 1 {
|
||||||
@ -867,6 +867,14 @@ var Index = &ctx.Context{Name: "cli", Help: "管理中心",
|
|||||||
m.Cmdy("nfs.git", "sum", "-n", arg[1:])
|
m.Cmdy("nfs.git", "sum", "-n", arg[1:])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case "trends":
|
||||||
|
// 提交记录
|
||||||
|
if len(arg) == 1 {
|
||||||
|
m.Cmdy("nfs.git", "sum", "total")
|
||||||
|
} else {
|
||||||
|
m.Cmdy("nfs.git", "sum", "total", "--reverse", "--since", arg[1])
|
||||||
|
}
|
||||||
|
|
||||||
case "submit":
|
case "submit":
|
||||||
// 提交代码
|
// 提交代码
|
||||||
if len(arg) > 1 {
|
if len(arg) > 1 {
|
||||||
|
@ -757,6 +757,11 @@ var Index = &ctx.Context{Name: "nfs", Help: "存储中心",
|
|||||||
m.Cmd("cli.system", "git", "clone", arg[1], "cmd_dir", m.Conf("git", "local"))
|
m.Cmd("cli.system", "git", "clone", arg[1], "cmd_dir", m.Conf("git", "local"))
|
||||||
return
|
return
|
||||||
case "sum":
|
case "sum":
|
||||||
|
ts := false
|
||||||
|
if len(arg) > 1 && arg[1] == "total" {
|
||||||
|
ts, arg = true, arg[1:]
|
||||||
|
}
|
||||||
|
|
||||||
args := []string{}
|
args := []string{}
|
||||||
if m.Options("git_dir") {
|
if m.Options("git_dir") {
|
||||||
args = append(args, "-C", m.Option("git_dir"))
|
args = append(args, "-C", m.Option("git_dir"))
|
||||||
@ -767,37 +772,61 @@ var Index = &ctx.Context{Name: "nfs", Help: "存储中心",
|
|||||||
args = append(args, "--reverse")
|
args = append(args, "--reverse")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var total_day time.Duration
|
||||||
|
begin := ""
|
||||||
|
total := 0
|
||||||
|
total_add := 0
|
||||||
|
total_del := 0
|
||||||
if out, e := exec.Command("git", args...).CombinedOutput(); e == nil {
|
if out, e := exec.Command("git", args...).CombinedOutput(); e == nil {
|
||||||
for _, v := range strings.Split(string(out), "commit: ") {
|
for _, v := range strings.Split(string(out), "commit: ") {
|
||||||
if l := strings.Split(v, "\n"); len(l) > 3 {
|
if l := strings.Split(v, "\n"); len(l) > 3 {
|
||||||
fs := strings.Split(strings.TrimSpace(l[3]), ", ")
|
fs := strings.Split(strings.TrimSpace(l[3]), ", ")
|
||||||
hs := strings.Split(l[0], " ")
|
hs := strings.Split(l[0], " ")
|
||||||
m.Add("append", "date", hs[0])
|
m.Push("date", hs[0])
|
||||||
|
if total_day == 0 {
|
||||||
|
if t, e := time.Parse("2006-01-02", hs[0]); e == nil {
|
||||||
|
begin, total_day = hs[0], time.Now().Sub(t)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if adds := strings.Split(fs[1], " "); len(fs) > 2 {
|
if adds := strings.Split(fs[1], " "); len(fs) > 2 {
|
||||||
dels := strings.Split(fs[2], " ")
|
dels := strings.Split(fs[2], " ")
|
||||||
m.Add("append", "adds", adds[0])
|
total_del += kit.Int(dels[0])
|
||||||
m.Add("append", "dels", dels[0])
|
total_add += kit.Int(adds[0])
|
||||||
|
m.Push("adds", adds[0])
|
||||||
|
m.Push("dels", dels[0])
|
||||||
} else if adds[1] == "insertions(+)" {
|
} else if adds[1] == "insertions(+)" {
|
||||||
m.Add("append", "adds", adds[0])
|
total_add += kit.Int(adds[0])
|
||||||
m.Add("append", "dels", "0")
|
m.Push("adds", adds[0])
|
||||||
|
m.Push("dels", "0")
|
||||||
} else {
|
} else {
|
||||||
m.Add("append", "adds", "0")
|
m.Push("adds", "0")
|
||||||
m.Add("append", "dels", adds[0])
|
m.Push("dels", adds[0])
|
||||||
}
|
}
|
||||||
m.Add("append", "note", l[1])
|
total++
|
||||||
m.Add("append", "hour", strings.Split(hs[1], ":")[0])
|
m.Push("note", l[1])
|
||||||
m.Add("append", "time", hs[1])
|
m.Push("hour", strings.Split(hs[1], ":")[0])
|
||||||
|
m.Push("time", hs[1])
|
||||||
} else if len(l[0]) > 0 {
|
} else if len(l[0]) > 0 {
|
||||||
|
total++
|
||||||
hs := strings.Split(l[0], " ")
|
hs := strings.Split(l[0], " ")
|
||||||
m.Add("append", "date", hs[0])
|
m.Push("date", hs[0])
|
||||||
m.Add("append", "adds", 0)
|
m.Push("adds", 0)
|
||||||
m.Add("append", "dels", 0)
|
m.Push("dels", 0)
|
||||||
m.Add("append", "note", l[1])
|
m.Push("note", l[1])
|
||||||
m.Add("append", "hour", strings.Split(hs[1], ":")[0])
|
m.Push("hour", strings.Split(hs[1], ":")[0])
|
||||||
m.Add("append", "time", hs[1])
|
m.Push("time", hs[1])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if ts {
|
||||||
|
m.Set("append")
|
||||||
|
m.Append("from", begin)
|
||||||
|
m.Append("days", int(total_day.Hours())/24)
|
||||||
|
m.Append("commit", total)
|
||||||
|
m.Append("adds", total_add)
|
||||||
|
m.Append("dels", total_del)
|
||||||
|
m.Append("rest", total_add-total_del)
|
||||||
|
}
|
||||||
m.Table()
|
m.Table()
|
||||||
} else {
|
} else {
|
||||||
m.Log("warn", "%v", string(out))
|
m.Log("warn", "%v", string(out))
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
kit project "项目" private \
|
kit project "项目" private \
|
||||||
select "" values plugin values review values submit values trend values stats values stat values init action auto \
|
select "" values plugin values review values submit values trends values trend values stats values stat values init action auto \
|
||||||
text "" name see imports plugin_see action auto \
|
text "" name see imports plugin_see action auto \
|
||||||
button "执行" \
|
button "执行" \
|
||||||
button "返回" cb Last \
|
button "返回" cb Last \
|
||||||
|
Loading…
x
Reference in New Issue
Block a user