Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Phodal
Coca
提交
213e8395
C
Coca
项目概览
Phodal
/
Coca
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
C
Coca
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
未验证
提交
213e8395
编写于
12月 23, 2019
作者:
P
Phodal Huang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: add basic git summary
上级
8a88136c
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
15 addition
and
11 deletion
+15
-11
cmd/git.go
cmd/git.go
+12
-8
core/domain/gitt/gitt.go
core/domain/gitt/gitt.go
+3
-3
未找到文件。
cmd/git.go
浏览文件 @
213e8395
package
cmd
import
(
"encoding/json"
.
"github.com/phodal/coca/core/domain/gitt"
"fmt"
"github.com/olekukonko/tablewriter"
"github.com/phodal/coca/core/support"
"github.com/spf13/cobra"
"io/ioutil"
"log"
...
...
@@ -22,12 +24,14 @@ var (
gitCmdConfig
GitCmdConfig
)
var
gitCmd
*
cobra
.
Command
=
&
cobra
.
Command
{
var
gitCmd
=
&
cobra
.
Command
{
Use
:
"git"
,
Short
:
"git analysis"
,
Long
:
``
,
Run
:
func
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
message
:=
BuildMessageByInput
(
getCommitMessage
())
commitMessages
:=
BuildMessageByInput
(
getCommitMessage
())
cModel
,
_
:=
json
.
MarshalIndent
(
commitMessages
,
""
,
"
\t
"
)
support
.
WriteToCocaFile
(
"commits.json"
,
string
(
cModel
))
isFullMessage
:=
cmd
.
Flag
(
"full"
)
.
Value
.
String
()
==
"true"
size
:=
*&
gitCmdConfig
.
Size
...
...
@@ -35,7 +39,7 @@ var gitCmd *cobra.Command = &cobra.Command{
if
cmd
.
Flag
(
"basic"
)
.
Value
.
String
()
==
"true"
{
table
:=
tablewriter
.
NewWriter
(
os
.
Stdout
)
basicSummary
:=
BasicSummary
(
message
)
basicSummary
:=
BasicSummary
(
commitMessages
)
table
.
SetHeader
([]
string
{
"Statistic"
,
"Number"
})
table
.
Append
([]
string
{
"Commits"
,
strconv
.
Itoa
(
basicSummary
.
Commits
)})
table
.
Append
([]
string
{
"Entities"
,
strconv
.
Itoa
(
basicSummary
.
Entities
)})
...
...
@@ -47,7 +51,7 @@ var gitCmd *cobra.Command = &cobra.Command{
if
cmd
.
Flag
(
"team"
)
.
Value
.
String
()
==
"true"
{
table
:=
tablewriter
.
NewWriter
(
os
.
Stdout
)
teamSummary
:=
GetTeamSummary
(
message
)
teamSummary
:=
GetTeamSummary
(
commitMessages
)
table
.
SetHeader
([]
string
{
"EntityName"
,
"RevsCount"
,
"AuthorCount"
})
if
len
(
teamSummary
)
>
size
&&
isFullMessage
{
...
...
@@ -62,7 +66,7 @@ var gitCmd *cobra.Command = &cobra.Command{
if
cmd
.
Flag
(
"age"
)
.
Value
.
String
()
==
"true"
{
table
:=
tablewriter
.
NewWriter
(
os
.
Stdout
)
ages
:=
CalculateCodeAge
(
message
)
ages
:=
CalculateCodeAge
(
commitMessages
)
var
agesDisplay
[]
CodeAgeDisplay
for
_
,
info
:=
range
ages
{
const
secondsOfOneMonth
=
2600640
...
...
@@ -85,7 +89,7 @@ var gitCmd *cobra.Command = &cobra.Command{
if
cmd
.
Flag
(
"top"
)
.
Value
.
String
()
==
"true"
{
table
:=
tablewriter
.
NewWriter
(
os
.
Stdout
)
authors
:=
GetTopAuthors
(
message
)
authors
:=
GetTopAuthors
(
commitMessages
)
table
.
SetHeader
([]
string
{
"Author"
,
"CommitCount"
,
"LineCount"
})
if
len
(
authors
)
>
size
&&
isFullMessage
{
...
...
@@ -104,8 +108,8 @@ var gitCmd *cobra.Command = &cobra.Command{
return
}
GetRelatedFiles
(
message
,
config
)
//results := GetRelatedFiles(
message
, config)
GetRelatedFiles
(
commitMessages
,
config
)
//results := GetRelatedFiles(
commitMessages
, config)
//fmt.Println(results)
}
},
...
...
core/domain/gitt/gitt.go
浏览文件 @
213e8395
...
...
@@ -46,7 +46,7 @@ func BuildMessageByInput(inputStr string) []CommitMessage {
func
CalculateCodeAge
(
messages
[]
CommitMessage
)
[]
ProjectInfo
{
infos
:=
make
(
map
[
string
]
ProjectInfo
)
b
uildCommitMessageMap
(
messages
,
infos
)
B
uildCommitMessageMap
(
messages
,
infos
)
var
agesArray
[]
ProjectInfo
for
_
,
info
:=
range
infos
{
...
...
@@ -62,7 +62,7 @@ func CalculateCodeAge(messages []CommitMessage) []ProjectInfo {
func
GetTeamSummary
(
messages
[]
CommitMessage
)
[]
TeamSummary
{
infos
:=
make
(
map
[
string
]
ProjectInfo
)
infos
=
b
uildCommitMessageMap
(
messages
,
infos
)
infos
=
B
uildCommitMessageMap
(
messages
,
infos
)
var
sortInfos
[]
TeamSummary
for
_
,
info
:=
range
infos
{
...
...
@@ -76,7 +76,7 @@ func GetTeamSummary(messages []CommitMessage) []TeamSummary {
return
sortInfos
}
func
b
uildCommitMessageMap
(
messages
[]
CommitMessage
,
infos
map
[
string
]
ProjectInfo
)
map
[
string
]
ProjectInfo
{
func
B
uildCommitMessageMap
(
messages
[]
CommitMessage
,
infos
map
[
string
]
ProjectInfo
)
map
[
string
]
ProjectInfo
{
timeFormat
:=
"2006-01-02"
for
_
,
commitMessage
:=
range
messages
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录