Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
4cc169d3
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,发现更多精彩内容 >>
提交
4cc169d3
编写于
9月 21, 2012
作者:
D
Dmitriy Zaporozhets
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Improve commits compare. Added tags to autocomplete. Dont look for commits if from & to are empty
上级
49fe8fed
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
33 addition
and
16 deletion
+33
-16
app/controllers/commits_controller.rb
app/controllers/commits_controller.rb
+1
-0
app/models/commit.rb
app/models/commit.rb
+8
-4
app/roles/repository.rb
app/roles/repository.rb
+8
-0
app/views/commits/compare.html.haml
app/views/commits/compare.html.haml
+16
-12
未找到文件。
app/controllers/commits_controller.rb
浏览文件 @
4cc169d3
...
...
@@ -52,6 +52,7 @@ class CommitsController < ApplicationController
@commits
=
result
[
:commits
]
@commit
=
result
[
:commit
]
@diffs
=
result
[
:diffs
]
@refs_are_same
=
result
[
:same
]
@line_notes
=
[]
@commits
=
CommitDecorator
.
decorate
(
@commits
)
...
...
app/models/commit.rb
浏览文件 @
4cc169d3
...
...
@@ -82,20 +82,24 @@ class Commit
end
def
compare
(
project
,
from
,
to
)
first
=
project
.
commit
(
to
.
try
(
:strip
))
last
=
project
.
commit
(
from
.
try
(
:strip
))
result
=
{
commits:
[],
diffs:
[],
commit:
nil
commit:
nil
,
same:
false
}
return
result
unless
from
&&
to
first
=
project
.
commit
(
to
.
try
(
:strip
))
last
=
project
.
commit
(
from
.
try
(
:strip
))
if
first
&&
last
commits
=
[
first
,
last
].
sort_by
(
&
:created_at
)
younger
=
commits
.
first
older
=
commits
.
last
result
[
:same
]
=
(
younger
.
id
==
older
.
id
)
result
[
:commits
]
=
project
.
repo
.
commits_between
(
younger
.
id
,
older
.
id
).
map
{
|
c
|
Commit
.
new
(
c
)}
result
[
:diffs
]
=
project
.
repo
.
diff
(
younger
.
id
,
older
.
id
)
rescue
[]
result
[
:commit
]
=
Commit
.
new
(
older
)
...
...
app/roles/repository.rb
浏览文件 @
4cc169d3
...
...
@@ -79,6 +79,14 @@ module Repository
@heads
||=
repo
.
heads
end
def
branches_names
heads
.
map
(
&
:name
)
end
def
ref_names
[
branches_names
+
tags
].
flatten
end
def
tree
(
fcommit
,
path
=
nil
)
fcommit
=
commit
if
fcommit
==
:head
tree
=
fcommit
.
tree
...
...
app/views/commits/compare.html.haml
浏览文件 @
4cc169d3
=
render
"head"
%h3
%h3
.page_title
Compare View
%hr
%div
%p
%p
.slead
Fill input field with commit id like
%code
'4eedf23'
%code
.label_branch
4eedf23
or branch/tag name like
%code
master
&
press compare button for commits list, code diff.
%code
.label_branch
master
and
press compare button for commits list, code diff.
%br
...
...
@@ -19,22 +19,24 @@
=
text_field_tag
:from
,
params
[
:from
],
placeholder:
"master"
,
class:
"xlarge"
=
"..."
=
text_field_tag
:to
,
params
[
:to
],
placeholder:
"aa8b4ef"
,
class:
"xlarge"
-
if
@refs_are_same
.alert
%span
Refs are the same
.actions
=
submit_tag
"Compare"
,
class:
"btn primary"
=
submit_tag
"Compare"
,
class:
"btn primary
wide commits-compare-btn
"
-
unless
@commits
.
empty?
-
if
@commits
.
present?
%div
.ui-box
%h5
.small
Commits (
#{
@commits
.
count
}
)
%ul
.unstyled
=
render
@commits
-
unless
@diffs
.
empty?
-
unless
@diffs
.
empty?
%h4
Diff
=
render
"commits/diffs"
,
diffs:
@diffs
:javascript
$
(
function
()
{
var
availableTags
=
#{
@project
.
heads
.
map
(
&
:name
)
.
to_json
}
;
var
availableTags
=
#{
@project
.
ref_names
.
to_json
}
;
$
(
"
#from
"
).
autocomplete
({
source
:
availableTags
,
...
...
@@ -45,5 +47,7 @@
source
:
availableTags
,
minLength
:
1
});
disableButtonIfEmptyField
(
'
#to
'
,
'
.commits-compare-btn
'
);
});
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录