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
Boxiang Sun
gitlab-ce
Commits
2b04c2a6
Commit
2b04c2a6
authored
Nov 11, 2011
by
Nihad Abbasov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
create atom feed for commits
parent
3f70316c
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
37 additions
and
2 deletions
+37
-2
app/controllers/commits_controller.rb
app/controllers/commits_controller.rb
+3
-2
app/views/commits/index.atom.builder
app/views/commits/index.atom.builder
+23
-0
app/views/layouts/project.html.haml
app/views/layouts/project.html.haml
+2
-0
spec/requests/commits_spec.rb
spec/requests/commits_spec.rb
+9
-0
No files found.
app/controllers/commits_controller.rb
View file @
2b04c2a6
...
...
@@ -13,7 +13,7 @@ class CommitsController < ApplicationController
load_refs
# load @branch, @tag & @ref
@repo
=
project
.
repo
limit
,
offset
=
(
params
[
:limit
]
||
20
),
(
params
[
:offset
]
||
0
)
limit
,
offset
=
(
params
[
:limit
]
||
20
),
(
params
[
:offset
]
||
0
)
if
params
[
:path
]
@commits
=
@repo
.
log
(
@ref
,
params
[
:path
],
:max_count
=>
limit
,
:skip
=>
offset
)
...
...
@@ -24,6 +24,7 @@ class CommitsController < ApplicationController
respond_to
do
|
format
|
format
.
html
# index.html.erb
format
.
js
format
.
atom
{
render
:layout
=>
false
}
end
end
...
...
@@ -32,7 +33,7 @@ class CommitsController < ApplicationController
@notes
=
project
.
notes
.
where
(
:noteable_id
=>
@commit
.
id
,
:noteable_type
=>
"Commit"
).
order
(
"created_at DESC"
).
limit
(
20
)
@note
=
@project
.
notes
.
new
(
:noteable_id
=>
@commit
.
id
,
:noteable_type
=>
"Commit"
)
respond_to
do
|
format
|
respond_to
do
|
format
|
format
.
html
format
.
js
{
respond_with_notes
}
end
...
...
app/views/commits/index.atom.builder
0 → 100644
View file @
2b04c2a6
xml.instruct!
xml.feed "xmlns" => "http://www.w3.org/2005/Atom", "xmlns:media" => "http://search.yahoo.com/mrss/" do
xml.title "Recent commits to #{@project.name}:#{@ref}"
xml.link :href => project_commits_url(@project, :atom, :ref => @ref), :rel => "self", :type => "application/atom+xml"
xml.link :href => project_commits_url(@project), :rel => "alternate", :type => "text/html"
xml.id project_commits_url(@project)
xml.updated @commits.first.committed_date.strftime("%Y-%m-%dT%H:%M:%SZ") if @commits.any?
@commits.each do |commit|
xml.entry do
xml.id project_commit_url(@project, :id => commit.id)
xml.link :href => project_commit_url(@project, :id => commit.id)
xml.title truncate(commit.safe_message, :length => 80)
xml.updated commit.committed_date.strftime("%Y-%m-%dT%H:%M:%SZ")
xml.media :thumbnail, :width => "40", :height => "40", :url => gravatar_icon(commit.author_email)
xml.author do |author|
xml.name commit.author_name
xml.email commit.author_email
end
xml.summary commit.safe_message
end
end
end
app/views/layouts/project.html.haml
View file @
2b04c2a6
...
...
@@ -5,6 +5,8 @@
GitLab
#{
" - #{@project.name}"
if
@project
&&
!
@project
.
new_record?
}
=
stylesheet_link_tag
"application"
=
javascript_include_tag
"application"
-
if
current_page?
(
tree_project_path
(
@project
))
||
current_page?
(
project_commits_path
(
@project
))
=
auto_discovery_link_tag
(
:atom
,
project_commits_url
(
@project
,
:atom
,
:ref
=>
@ref
),
:title
=>
"Recent commits to
#{
@project
.
name
}
:
#{
@ref
}
"
)
=
csrf_meta_tags
=
javascript_tag
do
REQ_URI = "
#{
request
.
env
[
"REQUEST_URI"
]
}
";
...
...
spec/requests/commits_spec.rb
View file @
2b04c2a6
...
...
@@ -25,6 +25,15 @@ describe "Commits" do
page
.
should
have_content
(
commit
.
author
)
page
.
should
have_content
(
commit
.
message
)
end
it
"should render atom feed"
do
visit
project_commits_path
(
project
,
:atom
)
page
.
response_headers
[
'Content-Type'
].
should
have_content
(
"application/atom+xml"
)
page
.
body
.
should
have_selector
(
"title"
,
:text
=>
"Recent commits to
#{
project
.
name
}
"
)
page
.
body
.
should
have_selector
(
"author email"
,
:text
=>
commit
.
author_email
)
page
.
body
.
should
have_selector
(
"entry summary"
,
:text
=>
commit
.
message
)
end
end
describe
"GET /commits/:id"
do
...
...
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