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
9cd8f7b0
Commit
9cd8f7b0
authored
May 17, 2012
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
New Feature: Git Blame for file
parent
2e54ac17
Changes
9
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
135 additions
and
15 deletions
+135
-15
app/assets/stylesheets/gitlab_bootstrap.scss
app/assets/stylesheets/gitlab_bootstrap.scss
+7
-0
app/assets/stylesheets/tree.scss
app/assets/stylesheets/tree.scss
+29
-0
app/controllers/refs_controller.rb
app/controllers/refs_controller.rb
+5
-1
app/views/refs/_head.html.haml
app/views/refs/_head.html.haml
+10
-0
app/views/refs/_tree_file.html.haml
app/views/refs/_tree_file.html.haml
+4
-4
app/views/refs/blame.html.haml
app/views/refs/blame.html.haml
+46
-0
app/views/refs/tree.html.haml
app/views/refs/tree.html.haml
+1
-10
config/routes.rb
config/routes.rb
+8
-0
spec/requests/file_blame_spec.rb
spec/requests/file_blame_spec.rb
+25
-0
No files found.
app/assets/stylesheets/gitlab_bootstrap.scss
View file @
9cd8f7b0
...
...
@@ -268,6 +268,13 @@ img.avatar {
-webkit-border-radius
:
4px
;
-moz-border-radius
:
4px
;
border-radius
:
4px
;
&
.s16
{
width
:
16px
;
}
&
.s24
{
width
:
24px
;
}
}
img
.lil_av
{
...
...
app/assets/stylesheets/tree.scss
View file @
9cd8f7b0
...
...
@@ -53,6 +53,11 @@
padding
:
9px
10px
;
height
:
18px
;
.options
{
float
:right
;
margin-top
:
-5px
;
}
.file_name
{
color
:
$style_color
;
font-size
:
14px
;
...
...
@@ -220,3 +225,27 @@
margin
:
0
;
}
}
.blame_file
{
.view_file_content
{
tr
{
border-bottom
:
1px
solid
#eee
;
}
td
{
padding
:
5px
;
}
.author
,
.commit
{
background
:
#f5f5f5
;
vertical-align
:top
;
}
.lines
{
pre
{
padding
:
0
;
margin
:
0
;
background
:none
;
border
:none
;
}
}
}
}
app/controllers/refs_controller.rb
View file @
9cd8f7b0
...
...
@@ -8,7 +8,7 @@ class RefsController < ApplicationController
before_filter
:require_non_empty_project
before_filter
:ref
before_filter
:define_tree_vars
,
:only
=>
[
:tree
,
:blob
]
before_filter
:define_tree_vars
,
:only
=>
[
:tree
,
:blob
,
:blame
]
before_filter
:render_full_content
layout
"project"
...
...
@@ -62,6 +62,10 @@ class RefsController < ApplicationController
return
render_404
end
def
blame
@blame
=
Grit
::
Blob
.
blame
(
@repo
,
@commit
.
id
,
params
[
:path
])
end
protected
def
define_tree_vars
...
...
app/views/refs/_head.html.haml
0 → 100644
View file @
9cd8f7b0
%ul
.nav.nav-tabs
%li
=
form_tag
switch_project_refs_path
(
@project
),
:method
=>
:get
,
:class
=>
"project-refs-form"
,
:remote
=>
true
do
=
select_tag
"ref"
,
grouped_options_refs
,
:onchange
=>
"$(this.form).trigger('submit');"
,
:class
=>
"project-refs-select"
=
hidden_field_tag
:destination
,
"tree"
=
hidden_field_tag
:path
,
params
[
:path
]
%li
{
:class
=>
"#{'active' if (controller.controller_name == "
refs
") }"
}
=
link_to
tree_project_ref_path
(
@project
,
@ref
)
do
Code
app/views/refs/_tree_file.html.haml
View file @
9cd8f7b0
:css
.view_file
.view_file_header
%i
.icon-file
%span
.file_name
=
name
%small
#{
file
.
mode
}
%span
.right
=
link_to
"raw"
,
blob_project_ref_path
(
@project
,
@ref
,
:path
=>
params
[
:path
]),
:class
=>
"right"
,
:target
=>
"_blank"
=
link_to
"history"
,
project_commits_path
(
@project
,
:path
=>
params
[
:path
],
:ref
=>
@ref
),
:class
=>
"right"
,
:style
=>
"margin-right:10px;"
%span
.options
=
link_to
"raw"
,
blob_project_ref_path
(
@project
,
@ref
,
:path
=>
params
[
:path
]),
:class
=>
"btn very_small"
,
:target
=>
"_blank"
=
link_to
"history"
,
project_commits_path
(
@project
,
:path
=>
params
[
:path
],
:ref
=>
@ref
),
:class
=>
"btn very_small"
=
link_to
"blame"
,
blame_file_project_ref_path
(
@project
,
@ref
,
:path
=>
params
[
:path
]),
:class
=>
"btn very_small"
-
if
file
.
text?
-
if
name
=~
/\.(md|markdown)$/i
#tree-readme-holder
...
...
app/views/refs/blame.html.haml
0 → 100644
View file @
9cd8f7b0
=
render
"head"
#tree-holder
%ul
.breadcrumb
%li
%span
.arrow
=
link_to
tree_project_ref_path
(
@project
,
@ref
,
:path
=>
nil
)
do
=
@project
.
name
-
@tree
.
breadcrumbs
(
6
)
do
|
link
|
\/
%li
=
link
.clear
.view_file.blame_file
.view_file_header
%i
.icon-file
%span
.file_name
=
@tree
.
name
%small
blame
%span
.options
=
link_to
"raw"
,
blob_project_ref_path
(
@project
,
@ref
,
:path
=>
params
[
:path
]),
:class
=>
"btn very_small"
,
:target
=>
"_blank"
=
link_to
"history"
,
project_commits_path
(
@project
,
:path
=>
params
[
:path
],
:ref
=>
@ref
),
:class
=>
"btn very_small"
=
link_to
"source"
,
tree_file_project_ref_path
(
@project
,
@ref
,
:path
=>
params
[
:path
]),
:class
=>
"btn very_small"
.view_file_content
%table
-
@blame
.
each
do
|
commit
,
lines
|
-
commit
=
Commit
.
new
(
commit
)
%tr
%td
.author
=
image_tag
gravatar_icon
(
commit
.
author_email
,
16
)
=
commit
.
author_name
%td
.commit
=
link_to
project_commit_path
(
@project
,
:id
=>
commit
.
id
)
do
%code
=
commit
.
id
.
to_s
[
0
..
10
]
%span
.row_title
=
truncate
(
commit
.
safe_message
,
:length
=>
30
)
rescue
"--broken encoding"
%td
.lines
=
preserve
do
%pre
-
lines
.
each
do
|
line
|
=
line
:javascript
$
(
function
(){
$
(
'
.project-refs-select
'
).
chosen
();
});
app/views/refs/tree.html.haml
View file @
9cd8f7b0
%ul
.nav.nav-tabs
%li
=
form_tag
switch_project_refs_path
(
@project
),
:method
=>
:get
,
:class
=>
"project-refs-form"
,
:remote
=>
true
do
=
select_tag
"ref"
,
grouped_options_refs
,
:onchange
=>
"$(this.form).trigger('submit');"
,
:class
=>
"project-refs-select"
=
hidden_field_tag
:destination
,
"tree"
=
hidden_field_tag
:path
,
params
[
:path
]
%li
{
:class
=>
"#{'active' if (controller.controller_name == "
refs
") }"
}
=
link_to
tree_project_ref_path
(
@project
,
@ref
)
do
Code
=
render
"head"
#tree-holder
=
render
:partial
=>
"tree"
,
:locals
=>
{
:repo
=>
@repo
,
:commit
=>
@commit
,
:tree
=>
@tree
}
:javascript
...
...
config/routes.rb
View file @
9cd8f7b0
...
...
@@ -94,6 +94,14 @@ Gitlab::Application.routes.draw do
:id
=>
/[a-zA-Z.0-9\/_\-]+/
,
:path
=>
/.*/
}
# blame
get
"blame/:path"
=>
"refs#blame"
,
:as
=>
:blame_file
,
:constraints
=>
{
:id
=>
/[a-zA-Z.0-9\/_\-]+/
,
:path
=>
/.*/
}
end
end
...
...
spec/requests/file_blame_spec.rb
0 → 100644
View file @
9cd8f7b0
require
'spec_helper'
describe
"Blame file"
do
before
{
login_as
:user
}
describe
"GET /:projectname/:commit/blob/Gemfile"
do
before
do
@project
=
Factory
:project
@project
.
add_access
(
@user
,
:read
)
visit
tree_project_ref_path
(
@project
,
@project
.
root_ref
,
:path
=>
"Gemfile"
)
click_link
"blame"
end
it
"should be correct path"
do
current_path
.
should
==
blame_file_project_ref_path
(
@project
,
@project
.
root_ref
,
:path
=>
"Gemfile"
)
end
it
"should contain file view"
do
page
.
should
have_content
(
"rubygems.org"
)
page
.
should
have_content
(
"Dmitriy Zaporozhets"
)
page
.
should
have_content
(
"bc3735004cb Moving to rails 3.2"
)
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