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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kazuhiko Shiozaki
gitlab-ce
Commits
136ab738
Commit
136ab738
authored
May 12, 2015
by
Robert Speicher
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update CommitRange#to_reference to use full SHAs
We only want them shortened by the filter, which calls to_s
parent
9d032cdd
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
18 deletions
+20
-18
app/models/commit_range.rb
app/models/commit_range.rb
+6
-3
spec/lib/gitlab/markdown/commit_range_reference_filter_spec.rb
...lib/gitlab/markdown/commit_range_reference_filter_spec.rb
+1
-2
spec/models/commit_range_spec.rb
spec/models/commit_range_spec.rb
+13
-13
No files found.
app/models/commit_range.rb
View file @
136ab738
...
@@ -61,11 +61,14 @@ class CommitRange
...
@@ -61,11 +61,14 @@ class CommitRange
end
end
def
to_reference
(
from_project
=
nil
)
def
to_reference
(
from_project
=
nil
)
# Not using to_s because we want the full SHAs
reference
=
sha_from
+
notation
+
sha_to
if
cross_project_reference?
(
from_project
)
if
cross_project_reference?
(
from_project
)
"
#{
project
.
to_reference
}
@
#{
to_s
}
"
reference
=
project
.
to_reference
+
'@'
+
reference
else
to_s
end
end
reference
end
end
# Returns a String for use in a link's title attribute
# Returns a String for use in a link's title attribute
...
...
spec/lib/gitlab/markdown/commit_range_reference_filter_spec.rb
View file @
136ab738
...
@@ -9,8 +9,7 @@ module Gitlab::Markdown
...
@@ -9,8 +9,7 @@ module Gitlab::Markdown
let
(
:commit2
)
{
project
.
commit
(
"HEAD~2"
)
}
let
(
:commit2
)
{
project
.
commit
(
"HEAD~2"
)
}
it
'requires project context'
do
it
'requires project context'
do
expect
{
described_class
.
call
(
'Commit Range 1c002d..d200c1'
,
{})
}.
expect
{
described_class
.
call
(
''
)
}.
to
raise_error
(
ArgumentError
,
/:project/
)
to
raise_error
(
ArgumentError
,
/:project/
)
end
end
%w(pre code a style)
.
each
do
|
elem
|
%w(pre code a style)
.
each
do
|
elem
|
...
...
spec/models/commit_range_spec.rb
View file @
136ab738
require
'spec_helper'
require
'spec_helper'
describe
CommitRange
do
describe
CommitRange
do
describe
'modules'
do
subject
{
described_class
}
it
{
is_expected
.
to
include_module
(
Referable
)
}
end
let
(
:sha_from
)
{
'f3f85602'
}
let
(
:sha_from
)
{
'f3f85602'
}
let
(
:sha_to
)
{
'e86e1013'
}
let
(
:sha_to
)
{
'e86e1013'
}
...
@@ -11,10 +17,14 @@ describe CommitRange do
...
@@ -11,10 +17,14 @@ describe CommitRange do
expect
{
described_class
.
new
(
"Foo"
)
}.
to
raise_error
expect
{
described_class
.
new
(
"Foo"
)
}.
to
raise_error
end
end
describe
'modules'
do
describe
'#to_s'
do
subject
{
described_class
}
it
'is correct for three-dot syntax'
do
expect
(
range
.
to_s
).
to
eq
"
#{
sha_from
[
0
..
7
]
}
...
#{
sha_to
[
0
..
7
]
}
"
end
it
{
is_expected
.
to
include_module
(
Referable
)
}
it
'is correct for two-dot syntax'
do
expect
(
range2
.
to_s
).
to
eq
"
#{
sha_from
[
0
..
7
]
}
..
#{
sha_to
[
0
..
7
]
}
"
end
end
end
describe
'#to_reference'
do
describe
'#to_reference'
do
...
@@ -34,16 +44,6 @@ describe CommitRange do
...
@@ -34,16 +44,6 @@ describe CommitRange do
end
end
end
end
describe
'#to_s'
do
it
'is correct for three-dot syntax'
do
expect
(
range
.
to_s
).
to
eq
"
#{
sha_from
[
0
..
7
]
}
...
#{
sha_to
[
0
..
7
]
}
"
end
it
'is correct for two-dot syntax'
do
expect
(
range2
.
to_s
).
to
eq
"
#{
sha_from
[
0
..
7
]
}
..
#{
sha_to
[
0
..
7
]
}
"
end
end
describe
'#reference_title'
do
describe
'#reference_title'
do
it
'returns the correct String for three-dot ranges'
do
it
'returns the correct String for three-dot ranges'
do
expect
(
range
.
reference_title
).
to
eq
"Commits
#{
sha_from
}
through
#{
sha_to
}
"
expect
(
range
.
reference_title
).
to
eq
"Commits
#{
sha_from
}
through
#{
sha_to
}
"
...
...
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