Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
422e4398
Commit
422e4398
authored
Feb 06, 2012
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Compare view for commits
parent
6c416aaa
Changes
13
Show whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
135 additions
and
61 deletions
+135
-61
app/assets/stylesheets/commits.css.scss
app/assets/stylesheets/commits.css.scss
+7
-0
app/controllers/commits_controller.rb
app/controllers/commits_controller.rb
+21
-2
app/views/commits/_commit.html.haml
app/views/commits/_commit.html.haml
+13
-0
app/views/commits/_commits.html.haml
app/views/commits/_commits.html.haml
+1
-14
app/views/commits/_diffs.html.haml
app/views/commits/_diffs.html.haml
+3
-2
app/views/commits/_head.html.haml
app/views/commits/_head.html.haml
+22
-0
app/views/commits/compare.html.haml
app/views/commits/compare.html.haml
+49
-0
app/views/commits/index.html.haml
app/views/commits/index.html.haml
+1
-7
app/views/commits/show.html.haml
app/views/commits/show.html.haml
+1
-1
app/views/merge_requests/_commits.html.haml
app/views/merge_requests/_commits.html.haml
+1
-10
app/views/merge_requests/_diffs.html.haml
app/views/merge_requests/_diffs.html.haml
+1
-24
config/routes.rb
config/routes.rb
+5
-1
spec/requests/commits_spec.rb
spec/requests/commits_spec.rb
+10
-0
No files found.
app/assets/stylesheets/commits.css.scss
View file @
422e4398
...
...
@@ -134,3 +134,10 @@ ul.bordered-list li:last-child { border:none }
margin
:
2px
;
}
}
.project-refs-form.commit-refs-form
.chzn-container
{
position
:
relative
;
top
:
0
;
left
:
0
;
margin-right
:
10px
;
}
app/controllers/commits_controller.rb
View file @
422e4398
...
...
@@ -9,6 +9,7 @@ class CommitsController < ApplicationController
before_filter
:authorize_read_project!
before_filter
:require_non_empty_project
before_filter
:load_refs
,
:only
=>
:index
# load @branch, @tag & @ref
before_filter
:render_full_content
def
index
@repo
=
project
.
repo
...
...
@@ -29,11 +30,29 @@ class CommitsController < ApplicationController
@line_notes
=
project
.
commit_line_notes
(
@commit
)
render_full_content
respond_to
do
|
format
|
format
.
html
format
.
js
{
respond_with_notes
}
end
end
def
compare
first
=
project
.
commit
(
params
[
:to
])
last
=
project
.
commit
(
params
[
:from
])
@diffs
=
[]
@commits
=
[]
@line_notes
=
[]
if
first
&&
last
commits
=
[
first
,
last
].
sort_by
(
&
:created_at
)
younger
=
commits
.
first
older
=
commits
.
last
@commits
=
project
.
repo
.
commits_between
(
younger
.
id
,
older
.
id
).
map
{
|
c
|
Commit
.
new
(
c
)}
@diffs
=
project
.
repo
.
diff
(
younger
.
id
,
older
.
id
)
rescue
[]
@commit
=
older
end
end
end
app/views/commits/_commit.html.haml
0 → 100644
View file @
422e4398
%li
.entry
=
link_to
project_commit_path
(
@project
,
:id
=>
commit
.
id
)
do
%div
%strong
=
truncate
commit
.
id
.
to_s
,
:length
=>
10
–
=
image_tag
gravatar_icon
(
commit
.
author_email
),
:class
=>
""
,
:width
=>
16
=
truncate
(
commit
.
safe_message
,
:length
=>
50
)
%span
.right.cgray
=
time_ago_in_words
(
commit
.
committed_date
)
ago
app/views/commits/_commits.html.haml
View file @
422e4398
...
...
@@ -3,17 +3,4 @@
.day-commits-table
%h5
.underlined
=
day
.
stamp
(
"28 Aug, 2010"
)
%br
%ul
.unstyled
-
commits
.
each
do
|
commit
|
%li
.entry
=
link_to
project_commit_path
(
@project
,
:id
=>
commit
.
id
)
do
%div
%strong
=
truncate
commit
.
id
.
to_s
,
:length
=>
10
–
=
image_tag
gravatar_icon
(
commit
.
author_email
),
:class
=>
""
,
:width
=>
16
=
truncate
(
commit
.
safe_message
,
:length
=>
50
)
%span
.right.cgray
=
time_ago_in_words
(
commit
.
committed_date
)
ago
%ul
.unstyled
=
render
commits
app/views/commits/_diff.html.haml
→
app/views/commits/_diff
s
.html.haml
View file @
422e4398
.file_stats
=
render
"commits/diff_head"
,
:diffs
=>
@commit
.
diffs
=
render
"commits/diff_head"
,
:diffs
=>
diffs
-
@commit
.
diffs
.
each_with_index
do
|
diff
,
i
|
-
diffs
.
each_with_index
do
|
diff
,
i
|
-
next
if
diff
.
diff
.
empty?
-
file
=
(
@commit
.
tree
/
diff
.
b_path
)
-
next
unless
file
...
...
@@ -22,3 +22,4 @@
-
else
%p
%center
No preview for this file type
app/views/commits/_head.html.haml
0 → 100644
View file @
422e4398
%ul
.tabs
%li
=
form_tag
switch_project_refs_path
(
@project
),
:method
=>
:get
,
:class
=>
"project-refs-form commit-refs-form"
do
=
select_tag
"ref"
,
grouped_options_refs
,
:onchange
=>
"$(this.form).trigger('submit');"
,
:class
=>
"project-refs-select"
=
hidden_field_tag
:destination
,
"commits"
%li
{
:class
=>
"#{'active' if current_page?(project_commits_path(@project)) }"
}
=
link_to
project_commits_path
(
@project
)
do
%span
Commits
%li
{
:class
=>
"#{'active' if current_page?(compare_project_commits_path(@project)) }"
}
=
link_to
compare_project_commits_path
(
@project
)
do
%span
Compare
:javascript
$
(
function
(){
$
(
'
.project-refs-select
'
).
chosen
();
});
app/views/commits/compare.html.haml
0 → 100644
View file @
422e4398
=
render
"head"
%h3
Compare View
%hr
%div
%p
Fill input field with commit id like
%code
'4eedf23'
or branch/tag name like
%code
master
&
press compare button for commits list, code diff.
%br
=
form_tag
compare_project_commits_path
(
@project
),
:method
=>
:get
do
.clearfix
=
text_field_tag
:from
,
params
[
:from
],
:placeholder
=>
"master"
,
:class
=>
"xlarge"
=
"..."
=
text_field_tag
:to
,
params
[
:to
],
:placeholder
=>
"aa8b4ef"
,
:class
=>
"xlarge"
.actions
=
submit_tag
"Compare"
,
:class
=>
"btn primary"
-
unless
@commits
.
empty?
%h4
Commits
%ul
.unstyled
=
render
@commits
-
unless
@diffs
.
empty?
%h4
Diff
=
render
"commits/diffs"
,
:diffs
=>
@diffs
:javascript
$
(
function
()
{
var
availableTags
=
#{
@project
.
heads
.
map
(
&
:name
).
to_json
}
;
$
(
"
#from
"
).
autocomplete
({
source
:
availableTags
,
minLength
:
1
});
$
(
"
#to
"
).
autocomplete
({
source
:
availableTags
,
minLength
:
1
});
});
app/views/commits/index.html.haml
View file @
422e4398
=
render
"head"
%h3
Commits
-
if
current_user
.
private_token
%span
.rss-icon
=
link_to
project_commits_path
(
@project
,
:atom
,
{
:private_token
=>
current_user
.
private_token
,
:ref
=>
@ref
})
do
=
image_tag
"Rss-UI.PNG"
,
:width
=>
22
,
:title
=>
"feed"
=
form_tag
switch_project_refs_path
(
@project
),
:method
=>
:get
,
:class
=>
"project-refs-form right"
do
=
select_tag
"ref"
,
grouped_options_refs
,
:onchange
=>
"$(this.form).trigger('submit');"
,
:class
=>
"project-refs-select"
=
hidden_field_tag
:destination
,
"commits"
%hr
-
if
params
[
:path
]
...
...
@@ -31,7 +29,3 @@
CommitsList
.
init
(
"
#{
@ref
}
"
,
20
);
});
:javascript
$
(
function
(){
$
(
'
.project-refs-select
'
).
chosen
();
});
app/views/commits/show.html.haml
View file @
422e4398
...
...
@@ -19,7 +19,7 @@
.clear
%br
=
render
"commits/diff
"
=
render
"commits/diff
s"
,
:diffs
=>
@commit
.
diffs
=
render
"notes/notes"
=
render
"notes/per_line_form"
...
...
app/views/merge_requests/_commits.html.haml
View file @
422e4398
-
if
@commits
.
size
>
0
.merge-request-commits
-
@commits
.
each
do
|
commit
|
.entry
=
link_to
project_commit_path
(
@project
,
:id
=>
commit
.
id
)
do
%strong
=
truncate
(
commit
.
id
.
to_s
,
:length
=>
10
)
=
image_tag
gravatar_icon
(
commit
.
author_email
),
:class
=>
""
,
:width
=>
16
%span
=
truncate
(
commit
.
safe_message
,
:length
=>
40
)
%span
.right
=
time_ago_in_words
(
commit
.
committed_date
)
ago
%ul
.unstyled
=
render
@commits
-
if
@commits
.
empty?
%p
.cgray
Nothing to merge
app/views/merge_requests/_diffs.html.haml
View file @
422e4398
.file_stats
=
render
"commits/diff_head"
,
:diffs
=>
@diffs
-
@diffs
.
each_with_index
do
|
diff
,
i
|
-
next
if
diff
.
diff
.
empty?
-
file
=
(
@commit
.
tree
/
diff
.
b_path
)
-
next
unless
file
.diff_file
.diff_file_header
-
if
diff
.
deleted_file
%strong
{
:id
=>
"#{diff.b_path}"
}=
diff
.
a_path
-
else
=
link_to
tree_file_project_ref_path
(
@project
,
@commit
.
id
,
diff
.
b_path
)
do
%strong
{
:id
=>
"#{diff.b_path}"
}=
diff
.
b_path
%br
/
.diff_file_content
-
if
file
.
text?
=
render
:partial
=>
"commits/text_file"
,
:locals
=>
{
:diff
=>
diff
,
:index
=>
i
}
-
elsif
file
.
image?
.diff_file_content_image
%img
{
:src
=>
"data:#{file.mime_type};base64,#{Base64.encode64(file.data)}"
}
-
else
%p
%center
No preview for this file type
=
render
"commits/diffs"
,
:diffs
=>
@diffs
-
if
@diffs
.
empty?
%p
.cgray
Nothing to merge
config/routes.rb
View file @
422e4398
...
...
@@ -96,7 +96,11 @@ Gitlab::Application.routes.draw do
get
:test
end
end
resources
:commits
resources
:commits
do
collection
do
get
:compare
end
end
resources
:team_members
resources
:issues
do
collection
do
...
...
spec/requests/commits_spec.rb
View file @
422e4398
...
...
@@ -55,4 +55,14 @@ describe "Commits" do
current_path
.
should
==
project_commit_path
(
project
,
commit
.
id
)
end
end
describe
"GET /commits/compare"
do
before
do
visit
compare_project_commits_path
(
project
)
end
it
"should have valid path"
do
current_path
.
should
==
compare_project_commits_path
(
project
)
end
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment