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
Tatuya Kamada
gitlab-ce
Commits
c8ba5c2d
Commit
c8ba5c2d
authored
Dec 25, 2012
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix routing issues when navigating over tree, commits etc
parent
49e73f8a
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
44 additions
and
5 deletions
+44
-5
app/helpers/commits_helper.rb
app/helpers/commits_helper.rb
+8
-0
app/models/project.rb
app/models/project.rb
+1
-1
app/views/commits/_text_file.html.haml
app/views/commits/_text_file.html.haml
+1
-1
config/routes.rb
config/routes.rb
+2
-2
lib/extracts_path.rb
lib/extracts_path.rb
+11
-1
spec/lib/extracts_path_spec.rb
spec/lib/extracts_path_spec.rb
+20
-0
spec/tasks/gitlab/backup_rake_spec.rb
spec/tasks/gitlab/backup_rake_spec.rb
+1
-0
No files found.
app/helpers/commits_helper.rb
View file @
c8ba5c2d
...
@@ -70,4 +70,12 @@ module CommitsHelper
...
@@ -70,4 +70,12 @@ module CommitsHelper
escape_javascript
(
render
'commits/commit'
,
commit:
commit
)
escape_javascript
(
render
'commits/commit'
,
commit:
commit
)
end
end
end
end
def
diff_line_content
(
line
)
if
line
.
blank?
" "
else
line
end
end
end
end
app/models/project.rb
View file @
c8ba5c2d
...
@@ -102,7 +102,7 @@ class Project < ActiveRecord::Base
...
@@ -102,7 +102,7 @@ class Project < ActiveRecord::Base
if
id
.
include?
(
"/"
)
if
id
.
include?
(
"/"
)
id
=
id
.
split
(
"/"
)
id
=
id
.
split
(
"/"
)
namespace_id
=
Namespace
.
find_by_path
(
id
.
first
).
id
namespace_id
=
Namespace
.
find_by_path
(
id
.
first
).
id
where
(
namespace_id:
namespace_id
).
find_by_path
(
id
.
last
)
where
(
namespace_id:
namespace_id
).
find_by_path
(
id
.
second
)
else
else
where
(
path:
id
,
namespace_id:
nil
).
last
where
(
path:
id
,
namespace_id:
nil
).
last
end
end
...
...
app/views/commits/_text_file.html.haml
View file @
c8ba5c2d
...
@@ -15,7 +15,7 @@
...
@@ -15,7 +15,7 @@
-
if
@comments_allowed
-
if
@comments_allowed
=
render
"notes/per_line_note_link"
,
line_code:
line_code
=
render
"notes/per_line_note_link"
,
line_code:
line_code
%td
.new_line
=
link_to
raw
(
type
==
"old"
?
" "
:
line_new
)
,
"#
#{
line_code
}
"
,
id:
line_code
%td
.new_line
=
link_to
raw
(
type
==
"old"
?
" "
:
line_new
)
,
"#
#{
line_code
}
"
,
id:
line_code
%td
.line_content
{
class:
"noteable_line #{type} #{line_code}"
,
"line_code"
=>
line_code
}=
raw
"
#{
line
}
"
%td
.line_content
{
class:
"noteable_line #{type} #{line_code}"
,
"line_code"
=>
line_code
}=
raw
diff_line_content
(
line
)
-
if
@comments_allowed
-
if
@comments_allowed
-
comments
=
@line_notes
.
select
{
|
n
|
n
.
line_code
==
line_code
}.
sort_by
(
&
:created_at
)
-
comments
=
@line_notes
.
select
{
|
n
|
n
.
line_code
==
line_code
}.
sort_by
(
&
:created_at
)
...
...
config/routes.rb
View file @
c8ba5c2d
...
@@ -112,7 +112,7 @@ Gitlab::Application.routes.draw do
...
@@ -112,7 +112,7 @@ Gitlab::Application.routes.draw do
#
#
# Project Area
# Project Area
#
#
resources
:projects
,
constraints:
{
id:
/[a-zA-Z.
\/0-9_\-
]+/
},
except:
[
:new
,
:create
,
:index
],
path:
"/"
do
resources
:projects
,
constraints:
{
id:
/[a-zA-Z.
0-9_\-\/
]+/
},
except:
[
:new
,
:create
,
:index
],
path:
"/"
do
member
do
member
do
get
"wall"
get
"wall"
get
"graph"
get
"graph"
...
@@ -190,12 +190,12 @@ Gitlab::Application.routes.draw do
...
@@ -190,12 +190,12 @@ Gitlab::Application.routes.draw do
end
end
end
end
resources
:tree
,
only:
[
:show
,
:edit
,
:update
],
constraints:
{
id:
/.+/
}
resources
:commit
,
only:
[
:show
],
constraints:
{
id:
/[[:alnum:]]{6,40}/
}
resources
:commit
,
only:
[
:show
],
constraints:
{
id:
/[[:alnum:]]{6,40}/
}
resources
:commits
,
only:
[
:show
],
constraints:
{
id:
/.+/
}
resources
:commits
,
only:
[
:show
],
constraints:
{
id:
/.+/
}
resources
:compare
,
only:
[
:index
,
:create
]
resources
:compare
,
only:
[
:index
,
:create
]
resources
:blame
,
only:
[
:show
],
constraints:
{
id:
/.+/
}
resources
:blame
,
only:
[
:show
],
constraints:
{
id:
/.+/
}
resources
:blob
,
only:
[
:show
],
constraints:
{
id:
/.+/
}
resources
:blob
,
only:
[
:show
],
constraints:
{
id:
/.+/
}
resources
:tree
,
only:
[
:show
,
:edit
,
:update
],
constraints:
{
id:
/.+/
}
match
"/compare/:from...:to"
=>
"compare#show"
,
as:
"compare"
,
match
"/compare/:from...:to"
=>
"compare#show"
,
as:
"compare"
,
:via
=>
[
:get
,
:post
],
constraints:
{
from:
/.+/
,
to:
/.+/
}
:via
=>
[
:get
,
:post
],
constraints:
{
from:
/.+/
,
to:
/.+/
}
...
...
lib/extracts_path.rb
View file @
c8ba5c2d
...
@@ -33,6 +33,9 @@ module ExtractsPath
...
@@ -33,6 +33,9 @@ module ExtractsPath
# extract_ref("v2.0.0/README.md")
# extract_ref("v2.0.0/README.md")
# # => ['v2.0.0', 'README.md']
# # => ['v2.0.0', 'README.md']
#
#
# extract_ref('/gitlab/vagrant/tree/master/app/models/project.rb')
# # => ['master', 'app/models/project.rb']
#
# extract_ref('issues/1234/app/models/project.rb')
# extract_ref('issues/1234/app/models/project.rb')
# # => ['issues/1234', 'app/models/project.rb']
# # => ['issues/1234', 'app/models/project.rb']
#
#
...
@@ -47,6 +50,13 @@ module ExtractsPath
...
@@ -47,6 +50,13 @@ module ExtractsPath
return
pair
unless
@project
return
pair
unless
@project
# Remove project, actions and all other staff from path
input
.
gsub!
(
"/
#{
@project
.
path_with_namespace
}
"
,
""
)
input
.
gsub!
(
/^\/(tree|commits|blame|blob)\//
,
""
)
# remove actions
input
.
gsub!
(
/\?.*$/
,
""
)
# remove stamps suffix
input
.
gsub!
(
/.atom$/
,
""
)
# remove rss feed
input
.
gsub!
(
/\/edit$/
,
""
)
# remove edit route part
if
input
.
match
(
/^([[:alnum:]]{40})(.+)/
)
if
input
.
match
(
/^([[:alnum:]]{40})(.+)/
)
# If the ref appears to be a SHA, we're done, just split the string
# If the ref appears to be a SHA, we're done, just split the string
pair
=
$~
.
captures
pair
=
$~
.
captures
...
@@ -98,7 +108,7 @@ module ExtractsPath
...
@@ -98,7 +108,7 @@ module ExtractsPath
request
.
format
=
:atom
request
.
format
=
:atom
end
end
@ref
,
@path
=
extract_ref
(
params
[
:id
]
)
@ref
,
@path
=
extract_ref
(
request
.
fullpath
)
@id
=
File
.
join
(
@ref
,
@path
)
@id
=
File
.
join
(
@ref
,
@path
)
...
...
spec/lib/extracts_path_spec.rb
View file @
c8ba5c2d
...
@@ -8,6 +8,7 @@ describe ExtractsPath do
...
@@ -8,6 +8,7 @@ describe ExtractsPath do
before
do
before
do
@project
=
project
@project
=
project
project
.
stub
(
:ref_names
).
and_return
([
'master'
,
'foo/bar/baz'
,
'v1.0.0'
,
'v2.0.0'
])
project
.
stub
(
:ref_names
).
and_return
([
'master'
,
'foo/bar/baz'
,
'v1.0.0'
,
'v2.0.0'
])
project
.
stub
(
path_with_namespace:
'gitlab/gitlab-ci'
)
end
end
describe
'#extract_ref'
do
describe
'#extract_ref'
do
...
@@ -53,5 +54,24 @@ describe ExtractsPath do
...
@@ -53,5 +54,24 @@ describe ExtractsPath do
extract_ref
(
'stable/CHANGELOG'
).
should
==
[
'stable'
,
'CHANGELOG'
]
extract_ref
(
'stable/CHANGELOG'
).
should
==
[
'stable'
,
'CHANGELOG'
]
end
end
end
end
context
"with a fullpath"
do
it
"extracts a valid branch"
do
extract_ref
(
'/gitlab/gitlab-ci/tree/foo/bar/baz/CHANGELOG'
).
should
==
[
'foo/bar/baz'
,
'CHANGELOG'
]
end
it
"extracts a valid tag"
do
extract_ref
(
'/gitlab/gitlab-ci/tree/v2.0.0/CHANGELOG'
).
should
==
[
'v2.0.0'
,
'CHANGELOG'
]
end
it
"extracts a valid commit SHA"
do
extract_ref
(
'/gitlab/gitlab-ci/tree/f4b14494ef6abf3d144c28e4af0c20143383e062/CHANGELOG'
).
should
==
[
'f4b14494ef6abf3d144c28e4af0c20143383e062'
,
'CHANGELOG'
]
end
it
"extracts a timestamp"
do
extract_ref
(
'/gitlab/gitlab-ci/tree/v2.0.0/CHANGELOG?_=12354435'
).
should
==
[
'v2.0.0'
,
'CHANGELOG'
]
end
end
end
end
end
end
spec/tasks/gitlab/backup_rake_spec.rb
View file @
c8ba5c2d
...
@@ -3,6 +3,7 @@ require 'rake'
...
@@ -3,6 +3,7 @@ require 'rake'
describe
'gitlab:app namespace rake task'
do
describe
'gitlab:app namespace rake task'
do
before
:all
do
before
:all
do
Rake
.
application
.
rake_require
"tasks/gitlab/task_helpers"
Rake
.
application
.
rake_require
"tasks/gitlab/backup"
Rake
.
application
.
rake_require
"tasks/gitlab/backup"
# empty task as env is already loaded
# empty task as env is already loaded
Rake
::
Task
.
define_task
:environment
Rake
::
Task
.
define_task
:environment
...
...
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