Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
heptapod
heptapod
Commits
f877d72fe1c8
Commit
f877d72f
authored
Sep 23, 2015
by
Dmitriy Zaporozhets
Browse files
Show CI status on all pages where commits list is rendered
Signed-off-by:
Dmitriy Zaporozhets
<
dmitriy.zaporozhets@gmail.com
>
parent
400e3eb46f63
Changes
5
Hide whitespace changes
Inline
Side-by-side
app/helpers/ci_status_helper.rb
0 → 100644
View file @
f877d72f
module
CiStatusHelper
def
ci_status_path
(
ci_commit
)
ci_project_ref_commits_path
(
ci_commit
.
project
,
ci_commit
.
ref
,
ci_commit
)
end
def
ci_status_icon
(
ci_commit
)
icon_name
=
case
ci_commit
.
status
when
'success'
'check'
when
'failed'
'close'
when
'running'
,
'pending'
'clock-o'
else
'circle'
end
icon
(
icon_name
)
end
def
ci_status_color
(
ci_commit
)
case
ci_commit
.
status
when
'success'
'green'
when
'failed'
'red'
when
'running'
,
'pending'
'yellow'
else
'gray'
end
end
end
app/helpers/commits_helper.rb
View file @
f877d72f
...
...
@@ -135,7 +135,7 @@
# size: size of the avatar image in px
def
commit_person_link
(
commit
,
options
=
{})
user
=
commit
.
send
(
options
[
:source
])
source_name
=
clean
(
commit
.
send
"
#{
options
[
:source
]
}
_name"
.
to_sym
)
source_email
=
clean
(
commit
.
send
"
#{
options
[
:source
]
}
_email"
.
to_sym
)
...
...
app/models/project.rb
View file @
f877d72f
...
...
@@ -735,4 +735,8 @@
errors
.
add
(
:base
,
'Failed create wiki'
)
false
end
def
ci_commit
(
sha
)
gitlab_ci_project
.
commits
.
find_by
(
sha:
sha
)
if
gitlab_ci?
end
end
app/views/projects/commits/_commit.html.haml
View file @
f877d72f
...
...
@@ -4,7 +4,11 @@
-
notes
=
commit
.
notes
-
note_count
=
notes
.
user
.
count
=
cache
[
project
.
id
,
commit
.
id
,
note_count
]
do
-
ci_commit
=
project
.
ci_commit
(
commit
.
sha
)
-
cache_key
=
[
project
.
id
,
commit
.
id
,
note_count
]
-
cache_key
.
push
(
ci_commit
.
status
)
if
ci_commit
=
cache
(
cache_key
)
do
%li
.commit.js-toggle-container
.commit-row-title
%strong
.str-truncated
...
...
@@ -13,6 +17,10 @@
%a
.text-expander.js-toggle-button
...
.pull-right
-
if
ci_commit
=
link_to
ci_status_path
(
ci_commit
),
class:
"c
#{
ci_status_color
(
ci_commit
)
}
"
do
=
ci_status_icon
(
ci_commit
)
=
link_to
commit
.
short_id
,
namespace_project_commit_path
(
project
.
namespace
,
project
,
commit
),
class:
"commit_short_id"
.notes_count
...
...
spec/models/project_spec.rb
View file @
f877d72f
...
...
@@ -401,4 +401,14 @@
it
{
should
eq
"http://localhost
#{
avatar_path
}
"
}
end
end
describe
:ci_commit
do
let
(
:project
)
{
create
:project
}
let
(
:ci_project
)
{
create
:ci_project
,
gl_project:
project
}
let
(
:commit
)
{
create
:ci_commit
,
project:
ci_project
}
before
{
project
.
create_gitlab_ci_service
(
active:
true
)
}
it
{
expect
(
project
.
ci_commit
(
commit
.
sha
)).
to
eq
(
commit
)
}
end
end
Write
Preview
Supports
Markdown
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