BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
2823c058
Commit
2823c058
authored
Apr 16, 2015
by
Robert Speicher
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
project_from_ref returns nil when reference can't be accessed
Prior it would return the project from the current context, which wasn't the intended behavior.
parent
3a0b4340
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
16 additions
and
11 deletions
+16
-11
commit_range_reference_filter.rb
lib/gitlab/markdown/commit_range_reference_filter.rb
+1
-1
commit_reference_filter.rb
lib/gitlab/markdown/commit_reference_filter.rb
+7
-1
cross_project_reference.rb
lib/gitlab/markdown/cross_project_reference.rb
+3
-4
issue_reference_filter.rb
lib/gitlab/markdown/issue_reference_filter.rb
+1
-1
merge_request_reference_filter.rb
lib/gitlab/markdown/merge_request_reference_filter.rb
+1
-1
snippet_reference_filter.rb
lib/gitlab/markdown/snippet_reference_filter.rb
+1
-1
cross_project_reference_spec.rb
spec/lib/gitlab/markdown/cross_project_reference_spec.rb
+2
-2
No files found.
lib/gitlab/markdown/commit_range_reference_filter.rb
View file @
2823c058
...
...
@@ -91,7 +91,7 @@ module Gitlab
end
def
valid_range?
(
project
,
from_id
,
to_id
)
project
.
valid_repo?
&&
commit
(
from_id
)
&&
commit
(
to_id
)
project
&&
project
.
valid_repo?
&&
commit
(
from_id
)
&&
commit
(
to_id
)
end
def
url_for_commit_range
(
project
,
from_id
,
to_id
)
...
...
lib/gitlab/markdown/commit_reference_filter.rb
View file @
2823c058
...
...
@@ -47,7 +47,7 @@ module Gitlab
self
.
class
.
references_in
(
text
)
do
|
match
,
commit_ref
,
project_ref
|
project
=
self
.
project_from_ref
(
project_ref
)
if
project
.
valid_repo?
&&
commit
=
project
.
repository
.
commit
(
commit_ref
)
if
commit
=
commit_from_ref
(
project
,
commit_ref
)
url
=
url_for_commit
(
project
,
commit
)
title
=
escape_once
(
commit
.
link_title
)
...
...
@@ -64,6 +64,12 @@ module Gitlab
end
end
def
commit_from_ref
(
project
,
commit_ref
)
if
project
&&
project
.
valid_repo?
project
.
repository
.
commit
(
commit_ref
)
end
end
def
url_for_commit
(
project
,
commit
)
h
=
Rails
.
application
.
routes
.
url_helpers
h
.
namespace_project_commit_url
(
project
.
namespace
,
project
,
commit
,
...
...
lib/gitlab/markdown/cross_project_reference.rb
View file @
2823c058
...
...
@@ -10,18 +10,17 @@ module Gitlab
#
# Defaults to value of `context[:project]` if:
# * No reference is given OR
# * Reference given doesn't exist OR
# * Reference given can't be read by the current user
# * Reference given doesn't exist
#
# ref - String reference.
#
# Returns a Project
# Returns a Project
, or nil if the reference can't be accessed
def
project_from_ref
(
ref
)
if
ref
&&
other
=
Project
.
find_with_namespace
(
ref
)
if
user_can_reference_project?
(
other
)
other
else
context
[
:project
]
nil
end
else
context
[
:project
]
...
...
lib/gitlab/markdown/issue_reference_filter.rb
View file @
2823c058
...
...
@@ -47,7 +47,7 @@ module Gitlab
self
.
class
.
references_in
(
text
)
do
|
match
,
issue
,
project_ref
|
project
=
self
.
project_from_ref
(
project_ref
)
if
project
.
issue_exists?
(
issue
)
if
project
&&
project
.
issue_exists?
(
issue
)
url
=
url_for_issue
(
issue
,
project
,
only_path:
context
[
:only_path
])
title
=
escape_once
(
"Issue:
#{
title_for_issue
(
issue
,
project
)
}
"
)
...
...
lib/gitlab/markdown/merge_request_reference_filter.rb
View file @
2823c058
...
...
@@ -47,7 +47,7 @@ module Gitlab
self
.
class
.
references_in
(
text
)
do
|
match
,
id
,
project_ref
|
project
=
self
.
project_from_ref
(
project_ref
)
if
merge_request
=
project
.
merge_requests
.
find_by
(
iid:
id
)
if
project
&&
merge_request
=
project
.
merge_requests
.
find_by
(
iid:
id
)
title
=
escape_once
(
"Merge Request:
#{
merge_request
.
title
}
"
)
klass
=
reference_class
(
:merge_request
)
...
...
lib/gitlab/markdown/snippet_reference_filter.rb
View file @
2823c058
...
...
@@ -47,7 +47,7 @@ module Gitlab
self
.
class
.
references_in
(
text
)
do
|
match
,
id
,
project_ref
|
project
=
self
.
project_from_ref
(
project_ref
)
if
snippet
=
project
.
snippets
.
find_by
(
id:
id
)
if
project
&&
snippet
=
project
.
snippets
.
find_by
(
id:
id
)
title
=
escape_once
(
"Snippet:
#{
snippet
.
title
}
"
)
klass
=
reference_class
(
:snippet
)
...
...
spec/lib/gitlab/markdown/cross_project_reference_spec.rb
View file @
2823c058
...
...
@@ -37,11 +37,11 @@ module Gitlab::Markdown
end
context
'and the user does not have permission to read it'
do
it
'returns
the project from context
'
do
it
'returns
nil
'
do
expect
(
self
).
to
receive
(
:user_can_reference_project?
).
with
(
project2
).
and_return
(
false
)
expect
(
project_from_ref
(
'cross/reference'
)).
to
eq
context
[
:project
]
expect
(
project_from_ref
(
'cross/reference'
)).
to
be_nil
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