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
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gitlab-ce
Commits
4cc169d3
Commit
4cc169d3
authored
Sep 21, 2012
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve commits compare. Added tags to autocomplete. Dont look for commits if from & to are empty
parent
49fe8fed
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
33 additions
and
16 deletions
+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
No files found.
app/controllers/commits_controller.rb
View file @
4cc169d3
...
@@ -52,6 +52,7 @@ class CommitsController < ApplicationController
...
@@ -52,6 +52,7 @@ class CommitsController < ApplicationController
@commits
=
result
[
:commits
]
@commits
=
result
[
:commits
]
@commit
=
result
[
:commit
]
@commit
=
result
[
:commit
]
@diffs
=
result
[
:diffs
]
@diffs
=
result
[
:diffs
]
@refs_are_same
=
result
[
:same
]
@line_notes
=
[]
@line_notes
=
[]
@commits
=
CommitDecorator
.
decorate
(
@commits
)
@commits
=
CommitDecorator
.
decorate
(
@commits
)
...
...
app/models/commit.rb
View file @
4cc169d3
...
@@ -82,20 +82,24 @@ class Commit
...
@@ -82,20 +82,24 @@ class Commit
end
end
def
compare
(
project
,
from
,
to
)
def
compare
(
project
,
from
,
to
)
first
=
project
.
commit
(
to
.
try
(
:strip
))
last
=
project
.
commit
(
from
.
try
(
:strip
))
result
=
{
result
=
{
commits:
[],
commits:
[],
diffs:
[],
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
if
first
&&
last
commits
=
[
first
,
last
].
sort_by
(
&
:created_at
)
commits
=
[
first
,
last
].
sort_by
(
&
:created_at
)
younger
=
commits
.
first
younger
=
commits
.
first
older
=
commits
.
last
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
[
: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
[
:diffs
]
=
project
.
repo
.
diff
(
younger
.
id
,
older
.
id
)
rescue
[]
result
[
:commit
]
=
Commit
.
new
(
older
)
result
[
:commit
]
=
Commit
.
new
(
older
)
...
...
app/roles/repository.rb
View file @
4cc169d3
...
@@ -79,6 +79,14 @@ module Repository
...
@@ -79,6 +79,14 @@ module Repository
@heads
||=
repo
.
heads
@heads
||=
repo
.
heads
end
end
def
branches_names
heads
.
map
(
&
:name
)
end
def
ref_names
[
branches_names
+
tags
].
flatten
end
def
tree
(
fcommit
,
path
=
nil
)
def
tree
(
fcommit
,
path
=
nil
)
fcommit
=
commit
if
fcommit
==
:head
fcommit
=
commit
if
fcommit
==
:head
tree
=
fcommit
.
tree
tree
=
fcommit
.
tree
...
...
app/views/commits/compare.html.haml
View file @
4cc169d3
=
render
"head"
=
render
"head"
%h3
%h3
.page_title
Compare View
Compare View
%hr
%hr
%div
%div
%p
%p
.slead
Fill input field with commit id like
Fill input field with commit id like
%code
'4eedf23'
%code
.label_branch
4eedf23
or branch/tag name like
or branch/tag name like
%code
master
%code
.label_branch
master
&
press compare button for commits list, code diff.
and
press compare button for commits list, code diff.
%br
%br
...
@@ -19,22 +19,24 @@
...
@@ -19,22 +19,24 @@
=
text_field_tag
:from
,
params
[
:from
],
placeholder:
"master"
,
class:
"xlarge"
=
text_field_tag
:from
,
params
[
:from
],
placeholder:
"master"
,
class:
"xlarge"
=
"..."
=
"..."
=
text_field_tag
:to
,
params
[
:to
],
placeholder:
"aa8b4ef"
,
class:
"xlarge"
=
text_field_tag
:to
,
params
[
:to
],
placeholder:
"aa8b4ef"
,
class:
"xlarge"
-
if
@refs_are_same
.alert
%span
Refs are the same
.actions
.actions
=
submit_tag
"Compare"
,
class:
"btn primary"
=
submit_tag
"Compare"
,
class:
"btn primary
wide commits-compare-btn
"
-
if
@commits
.
present?
-
unless
@commits
.
empty?
%div
.ui-box
%div
.ui-box
%h5
.small
Commits (
#{
@commits
.
count
}
)
%h5
.small
Commits (
#{
@commits
.
count
}
)
%ul
.unstyled
=
render
@commits
%ul
.unstyled
=
render
@commits
-
unless
@diffs
.
empty?
-
unless
@diffs
.
empty?
%h4
Diff
%h4
Diff
=
render
"commits/diffs"
,
diffs:
@diffs
=
render
"commits/diffs"
,
diffs:
@diffs
:javascript
:javascript
$
(
function
()
{
$
(
function
()
{
var
availableTags
=
#{
@project
.
heads
.
map
(
&
:name
)
.
to_json
}
;
var
availableTags
=
#{
@project
.
ref_names
.
to_json
}
;
$
(
"
#from
"
).
autocomplete
({
$
(
"
#from
"
).
autocomplete
({
source
:
availableTags
,
source
:
availableTags
,
...
@@ -45,5 +47,7 @@
...
@@ -45,5 +47,7 @@
source
:
availableTags
,
source
:
availableTags
,
minLength
:
1
minLength
:
1
});
});
disableButtonIfEmptyField
(
'
#to
'
,
'
.commits-compare-btn
'
);
});
});
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