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
477d975a
Commit
477d975a
authored
Oct 30, 2016
by
Jeff Stubler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add blame view age map
parent
a1695253
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
158 additions
and
3 deletions
+158
-3
app/assets/stylesheets/framework/files.scss
app/assets/stylesheets/framework/files.scss
+50
-0
app/assets/stylesheets/framework/variables.scss
app/assets/stylesheets/framework/variables.scss
+7
-0
app/helpers/blame_helper.rb
app/helpers/blame_helper.rb
+21
-0
app/views/projects/blame/_age_map_legend.html.haml
app/views/projects/blame/_age_map_legend.html.haml
+12
-0
app/views/projects/blame/show.html.haml
app/views/projects/blame/show.html.haml
+5
-3
changelogs/unreleased/23998-blame-age-map.yml
changelogs/unreleased/23998-blame-age-map.yml
+4
-0
spec/helpers/blame_helper_spec.rb
spec/helpers/blame_helper_spec.rb
+59
-0
No files found.
app/assets/stylesheets/framework/files.scss
View file @
477d975a
...
...
@@ -59,6 +59,43 @@
}
}
.file-blame-legend
{
background-color
:
$gray-light
;
text-align
:
right
;
padding
:
8px
$gl-padding
;
@media
(
max-width
:
$screen-xs-max
)
{
text-align
:
left
;
}
.left-label
{
padding-right
:
5px
;
}
.right-label
{
padding-left
:
5px
;
}
.legend-box
{
display
:
inline-block
;
width
:
10px
;
height
:
10px
;
padding
:
0
2px
;
}
@for
$i
from
0
through
5
{
.legend-box-
#{
$i
}
{
background-color
:
mix
(
$blame-cyan
,
$blame-blue
,
$i
/
5
.0
*
100%
);
}
}
@for
$i
from
1
through
4
{
.legend-box-
#{
$i
+
5
}
{
background-color
:
mix
(
$blame-gray
,
$blame-cyan
,
$i
/
4
.0
*
100%
);
}
}
}
.file-content
{
background
:
$white-light
;
...
...
@@ -118,6 +155,19 @@
padding
:
5px
10px
;
min-width
:
400px
;
background
:
$gray-light
;
border-left
:
3px
solid
;
}
@for
$i
from
0
through
5
{
td
.blame-commit-age-
#{
$i
}
{
border-left-color
:
mix
(
$blame-cyan
,
$blame-blue
,
$i
/
5
.0
*
100%
);
}
}
@for
$i
from
1
through
4
{
td
.blame-commit-age-
#{
$i
+
5
}
{
border-left-color
:
mix
(
$blame-gray
,
$blame-cyan
,
$i
/
4
.0
*
100%
);
}
}
td
.line-numbers
{
...
...
app/assets/stylesheets/framework/variables.scss
View file @
477d975a
...
...
@@ -364,6 +364,13 @@ $avatar_radius: 50%;
$avatar-border
:
rgba
(
0
,
0
,
0
,
.1
);
$gl-avatar-size
:
40px
;
/*
* Blame
*/
$blame-gray
:
#ededed
;
$blame-cyan
:
#acd5f2
;
$blame-blue
:
#254e77
;
/*
* Builds
*/
...
...
app/helpers/blame_helper.rb
0 → 100644
View file @
477d975a
module
BlameHelper
def
age_map_duration
(
blame_groups
,
project
)
now
=
Time
.
zone
.
now
start_date
=
blame_groups
.
map
{
|
blame_group
|
blame_group
[
:commit
].
committed_date
}
.
append
(
project
.
created_at
).
min
{
now:
now
,
started_days_ago:
(
now
-
start_date
).
to_i
/
1
.
day
}
end
def
age_map_class
(
commit_date
,
duration
)
commit_date_days_ago
=
(
duration
[
:now
]
-
commit_date
).
to_i
/
1
.
day
# Numbers 0 to 10 come from this calculation, but only commits on the oldest
# day get number 10 (all other numbers can be multiple days), so the range
# is normalized to 0-9
age_group
=
[(
10
*
commit_date_days_ago
)
/
duration
[
:started_days_ago
],
9
].
min
"blame-commit-age-
#{
age_group
}
"
end
end
app/views/projects/blame/_age_map_legend.html.haml
0 → 100644
View file @
477d975a
%span
.left-label
Newer
%span
.legend-box.legend-box-0
%span
.legend-box.legend-box-1
%span
.legend-box.legend-box-2
%span
.legend-box.legend-box-3
%span
.legend-box.legend-box-4
%span
.legend-box.legend-box-5
%span
.legend-box.legend-box-6
%span
.legend-box.legend-box-7
%span
.legend-box.legend-box-8
%span
.legend-box.legend-box-9
%span
.right-label
Older
app/views/projects/blame/show.html.haml
View file @
477d975a
-
@no_container
=
true
-
project_duration
=
age_map_duration
(
@blame_groups
,
@project
)
-
page_title
"Annotate"
,
@blob
.
path
,
@ref
=
render
"projects/commits/head"
...
...
@@ -8,15 +9,16 @@
.file-holder
=
render
"projects/blob/header"
,
blob:
@blob
,
blame:
true
.file-blame-legend
=
render
'age_map_legend'
.table-responsive.file-content.blame.code.js-syntax-highlight
%table
-
current_line
=
1
-
@blame_groups
.
each
do
|
blame_group
|
%tr
%td
.blame-commit
-
commit
=
blame_group
[
:commit
]
%td
.blame-commit
{
class:
age_map_class
(
commit
.
committed_date
,
project_duration
)
}
.commit
-
commit
=
blame_group
[
:commit
]
=
author_avatar
(
commit
,
size:
36
)
.commit-row-title
%strong
...
...
changelogs/unreleased/23998-blame-age-map.yml
0 → 100644
View file @
477d975a
---
title
:
Add blame view age mapping
merge_request
:
7198
author
:
Jeff Stubler
spec/helpers/blame_helper_spec.rb
0 → 100644
View file @
477d975a
require
'spec_helper'
describe
BlameHelper
do
describe
'#get_age_map_start_date'
do
let
(
:dates
)
do
[
Time
.
zone
.
local
(
2014
,
3
,
17
,
0
,
0
,
0
),
Time
.
zone
.
local
(
2011
,
11
,
2
,
0
,
0
,
0
),
Time
.
zone
.
local
(
2015
,
7
,
9
,
0
,
0
,
0
),
Time
.
zone
.
local
(
2013
,
2
,
24
,
0
,
0
,
0
),
Time
.
zone
.
local
(
2010
,
9
,
22
,
0
,
0
,
0
)]
end
let
(
:blame_groups
)
do
[
{
commit:
double
(
committed_date:
dates
[
0
])
},
{
commit:
double
(
committed_date:
dates
[
1
])
},
{
commit:
double
(
committed_date:
dates
[
2
])
}
]
end
it
'returns the earliest date from a blame group'
do
project
=
double
(
created_at:
dates
[
3
])
duration
=
helper
.
age_map_duration
(
blame_groups
,
project
)
expect
(
duration
[
:started_days_ago
]).
to
eq
((
duration
[
:now
]
-
dates
[
1
]).
to_i
/
1
.
day
)
end
it
'returns the earliest date from a project'
do
project
=
double
(
created_at:
dates
[
4
])
duration
=
helper
.
age_map_duration
(
blame_groups
,
project
)
expect
(
duration
[
:started_days_ago
]).
to
eq
((
duration
[
:now
]
-
dates
[
4
]).
to_i
/
1
.
day
)
end
end
describe
'#age_map_class'
do
let
(
:dates
)
do
[
Time
.
zone
.
local
(
2014
,
3
,
17
,
0
,
0
,
0
)]
end
let
(
:blame_groups
)
do
[
{
commit:
double
(
committed_date:
dates
[
0
])
}
]
end
let
(
:duration
)
do
project
=
double
(
created_at:
dates
[
0
])
helper
.
age_map_duration
(
blame_groups
,
project
)
end
it
'returns blame-commit-age-9 when oldest'
do
expect
(
helper
.
age_map_class
(
dates
[
0
],
duration
)).
to
eq
'blame-commit-age-9'
end
it
'returns blame-commit-age-0 class when newest'
do
expect
(
helper
.
age_map_class
(
duration
[
:now
],
duration
)).
to
eq
'blame-commit-age-0'
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