Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
f0a6fbaa
G
gitlab-foss
项目概览
李少辉-开发者
/
gitlab-foss
通知
15
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
gitlab-foss
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
f0a6fbaa
编写于
11月 13, 2012
作者:
D
Dmitriy Zaporozhets
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Improve Commits stats code
上级
b28ab896
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
11 addition
and
12 deletion
+11
-12
app/views/repositories/stats.html.haml
app/views/repositories/stats.html.haml
+5
-3
lib/gitlab/git_stats.rb
lib/gitlab/git_stats.rb
+6
-9
未找到文件。
app/views/repositories/stats.html.haml
浏览文件 @
f0a6fbaa
...
...
@@ -2,12 +2,12 @@
.row
.span5
%h4
Stats
for
#{
@project
.
root_ref
}
:
Stats:
%p
%b
Total commits:
%span
=
@stats
.
commits_count
%p
%b
Total files:
%b
Total files
in
#{
@project
.
root_ref
}
:
%span
=
@stats
.
files_count
%p
%b
Authors:
...
...
@@ -30,10 +30,12 @@
:javascript
$
(
function
(){
var
labels
=
[
#{
@graph
.
labels
.
to_json
}
];
var
commits
=
[
#{
@graph
.
commits
.
join
(
', '
)
}
];
var
r
=
Raphael
(
'
activity-chart
'
);
r
.
text
(
160
,
10
,
"
Commit activity for last
#{
@graph
.
weeks
}
weeks
"
).
attr
({
font
:
"
13px sans-serif
"
});
r
.
barchart
(
10
,
10
,
400
,
160
,
[[
#{
@graph
.
commits
.
join
(
', '
)
}
]]
[
commits
],
{
colors
:[
"
#456
"
]}
).
label
(
labels
,
true
);
})
lib/gitlab/git_stats.rb
浏览文件 @
f0a6fbaa
...
...
@@ -15,7 +15,8 @@ module Gitlab
end
def
files_count
repo
.
git
.
sh
(
"git ls-tree -r --name-only
#{
ref
}
| wc -l"
).
first
.
to_i
args
=
[
ref
,
'-r'
,
'--name-only'
]
repo
.
git
.
run
(
nil
,
'ls-tree'
,
nil
,
{},
args
).
split
(
"
\n
"
).
count
end
def
authors_count
...
...
@@ -52,15 +53,11 @@ module Gitlab
def
build_graph
n
=
4
from
,
to
=
(
Date
.
today
-
n
.
weeks
),
Date
.
today
args
=
[
'--all'
,
"--since=
#{
from
.
to_s
(
:date
)
}
"
,
'--format=%ad'
]
rev_list
=
repo
.
git
.
run
(
nil
,
'rev-list'
,
nil
,
{},
args
).
split
(
"
\n
"
)
format
=
"--pretty=format:'%h|%at|%ai|%aE'"
commits_strings
=
repo
.
git
.
sh
(
"git rev-list --since
#{
from
.
to_s
(
:date
)
}
#{
format
}
#{
ref
}
| grep -v commit"
)[
0
].
split
(
"
\n
"
)
commits_dates
=
commits_strings
.
map
do
|
string
|
data
=
string
.
split
(
"|"
)
date
=
data
[
2
]
Time
.
parse
(
date
).
to_date
.
to_s
(
:date
)
end
commits_dates
=
rev_list
.
values_at
(
*
rev_list
.
each_index
.
select
{
|
i
|
i
.
odd?
})
commits_dates
=
commits_dates
.
map
{
|
date_str
|
Time
.
parse
(
date_str
).
to_date
.
to_s
(
:date
)
}
commits_per_day
=
from
.
upto
(
to
).
map
do
|
day
|
commits_dates
.
count
(
day
.
to_date
.
to_s
(
:date
))
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录