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
a8ea8d98
Commit
a8ea8d98
authored
Sep 20, 2012
by
Robert Speicher
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update RefExtractor to handle atom feeds
parent
398ba6f1
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
12 additions
and
15 deletions
+12
-15
app/controllers/tree_controller.rb
app/controllers/tree_controller.rb
+0
-3
lib/ref_extractor.rb
lib/ref_extractor.rb
+7
-1
spec/routing/project_routing_spec.rb
spec/routing/project_routing_spec.rb
+5
-11
No files found.
app/controllers/tree_controller.rb
View file @
a8ea8d98
# Controller for viewing a repository's file structure
# Controller for viewing a repository's file structure
class
TreeController
<
ApplicationController
class
TreeController
<
ApplicationController
# Thrown when given an invalid path
class
InvalidPathError
<
StandardError
;
end
include
RefExtractor
include
RefExtractor
layout
"project"
layout
"project"
...
...
lib/ref_extractor.rb
View file @
a8ea8d98
# Module providing an extract_ref method for controllers working with Git
# Module providing an extract_ref method for controllers working with Git
# tree-ish + path params
# tree-ish + path params
module
RefExtractor
module
RefExtractor
#
Thrown
when given an invalid path
#
Raised
when given an invalid path
class
InvalidPathError
<
StandardError
;
end
class
InvalidPathError
<
StandardError
;
end
# Given a string containing both a Git ref - such as a branch or tag - and a
# Given a string containing both a Git ref - such as a branch or tag - and a
...
@@ -81,6 +81,12 @@ module RefExtractor
...
@@ -81,6 +81,12 @@ module RefExtractor
# Automatically renders `not_found!` if a valid tree could not be resolved
# Automatically renders `not_found!` if a valid tree could not be resolved
# (e.g., when a user inserts an invalid path or ref).
# (e.g., when a user inserts an invalid path or ref).
def
assign_ref_vars
def
assign_ref_vars
# Handle formats embedded in the id
if
params
[
:id
].
ends_with?
(
'.atom'
)
params
[
:id
].
gsub!
(
/\.atom$/
,
''
)
request
.
format
=
:atom
end
@ref
,
@path
=
extract_ref
(
params
[
:id
])
@ref
,
@path
=
extract_ref
(
params
[
:id
])
@id
=
File
.
join
(
@ref
,
@path
)
@id
=
File
.
join
(
@ref
,
@path
)
...
...
spec/routing/project_routing_spec.rb
View file @
a8ea8d98
...
@@ -293,11 +293,7 @@ end
...
@@ -293,11 +293,7 @@ end
# patch_project_commit GET /:project_id/commits/:id/patch(.:format) commits#patch
# patch_project_commit GET /:project_id/commits/:id/patch(.:format) commits#patch
# project_commits GET /:project_id/commits(.:format) commits#index
# project_commits GET /:project_id/commits(.:format) commits#index
# POST /:project_id/commits(.:format) commits#create
# POST /:project_id/commits(.:format) commits#create
# new_project_commit GET /:project_id/commits/new(.:format) commits#new
# edit_project_commit GET /:project_id/commits/:id/edit(.:format) commits#edit
# project_commit GET /:project_id/commits/:id(.:format) commits#show
# project_commit GET /:project_id/commits/:id(.:format) commits#show
# PUT /:project_id/commits/:id(.:format) commits#update
# DELETE /:project_id/commits/:id(.:format) commits#destroy
describe
CommitsController
,
"routing"
do
describe
CommitsController
,
"routing"
do
it
"to #compare"
do
it
"to #compare"
do
get
(
"/gitlabhq/commits/compare"
).
should
route_to
(
'commits#compare'
,
project_id:
'gitlabhq'
)
get
(
"/gitlabhq/commits/compare"
).
should
route_to
(
'commits#compare'
,
project_id:
'gitlabhq'
)
...
@@ -307,6 +303,10 @@ describe CommitsController, "routing" do
...
@@ -307,6 +303,10 @@ describe CommitsController, "routing" do
get
(
"/gitlabhq/commits/1/patch"
).
should
route_to
(
'commits#patch'
,
project_id:
'gitlabhq'
,
id:
'1'
)
get
(
"/gitlabhq/commits/1/patch"
).
should
route_to
(
'commits#patch'
,
project_id:
'gitlabhq'
,
id:
'1'
)
end
end
it
"does something with atom feeds"
do
get
(
"/gitlabhq/commits/master.atom"
).
should
route_to
(
'commits#show'
,
project_id:
'gitlabhq'
,
id:
'master.atom'
)
end
it_behaves_like
"RESTful project resources"
do
it_behaves_like
"RESTful project resources"
do
let
(
:actions
)
{
[
:index
,
:show
]
}
let
(
:actions
)
{
[
:index
,
:show
]
}
let
(
:controller
)
{
'commits'
}
let
(
:controller
)
{
'commits'
}
...
@@ -425,6 +425,7 @@ end
...
@@ -425,6 +425,7 @@ end
# /:project_id/commits/*path
# /:project_id/commits/*path
# /gitlabhq/commits/master/app/contexts/base_context.rb
# /gitlabhq/commits/master/app/contexts/base_context.rb
# /gitlabhq/commits/test/branch/name/app/contexts/base_context.rb
# /gitlabhq/commits/test/branch/name/app/contexts/base_context.rb
# /gitlabhq/commits/master.atom
#
#
# /:project_id/raw/*path
# /:project_id/raw/*path
# /gitlabhq/raw/master/app/contexts/base_context.rb
# /gitlabhq/raw/master/app/contexts/base_context.rb
...
@@ -436,13 +437,6 @@ end
...
@@ -436,13 +437,6 @@ end
describe
"pending routing"
do
describe
"pending routing"
do
before
{
pending
}
before
{
pending
}
describe
"/:project_id/commit/:id"
do
it
"routes to a specific commit"
do
get
(
"/gitlabhq/commit/f4b1449"
).
should
route_to
(
'commit#show'
,
project_id:
'gitlabhq'
,
id:
'f4b1449'
)
get
(
"/gitlabhq/commit/f4b14494ef6abf3d144c28e4af0c20143383e062"
).
should
route_to
(
'commit#show'
,
project_id:
'gitlabhq'
,
id:
'f4b14494ef6abf3d144c28e4af0c20143383e062'
)
end
end
describe
"/:project_id/raw/:id"
do
describe
"/:project_id/raw/:id"
do
it
"routes to a ref with a path"
do
it
"routes to a ref with a path"
do
get
(
"/gitlabhq/raw/master/app/models/project.rb"
).
should
route_to
(
'raw#show'
,
project_id:
'gitlabhq'
,
id:
'master/app/models/project.rb'
)
get
(
"/gitlabhq/raw/master/app/models/project.rb"
).
should
route_to
(
'raw#show'
,
project_id:
'gitlabhq'
,
id:
'master/app/models/project.rb'
)
...
...
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