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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
ba318f3d
Commit
ba318f3d
authored
Jun 14, 2020
by
Lee Tickett
Committed by
Dylan Griffith
Jun 14, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Show build status in branch list
parent
3a082739
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
140 additions
and
3 deletions
+140
-3
app/controllers/projects/branches_controller.rb
app/controllers/projects/branches_controller.rb
+13
-1
app/views/projects/branches/_branch.html.haml
app/views/projects/branches/_branch.html.haml
+6
-0
app/views/projects/branches/_panel.html.haml
app/views/projects/branches/_panel.html.haml
+1
-1
app/views/projects/branches/index.html.haml
app/views/projects/branches/index.html.haml
+1
-1
changelogs/unreleased/show_build_status_in_branch_list.yml
changelogs/unreleased/show_build_status_in_branch_list.yml
+5
-0
spec/controllers/projects/branches_controller_spec.rb
spec/controllers/projects/branches_controller_spec.rb
+76
-0
spec/features/projects/branches_spec.rb
spec/features/projects/branches_spec.rb
+38
-0
No files found.
app/controllers/projects/branches_controller.rb
View file @
ba318f3d
...
...
@@ -25,8 +25,9 @@ class Projects::BranchesController < Projects::ApplicationController
@refs_pipelines
=
@project
.
ci_pipelines
.
latest_successful_for_refs
(
@branches
.
map
(
&
:name
))
@merged_branch_names
=
repository
.
merged_branch_names
(
@branches
.
map
(
&
:name
))
@branch_pipeline_statuses
=
branch_pipeline_statuses
# https://gitlab.com/gitlab-org/gitlab
-foss/issues/48097
# https://gitlab.com/gitlab-org/gitlab
/-/issues/22851
Gitlab
::
GitalyClient
.
allow_n_plus_1_calls
do
render
end
...
...
@@ -194,4 +195,15 @@ class Projects::BranchesController < Projects::ApplicationController
confidential_issue_project
end
def
branch_pipeline_statuses
latest_commits
=
@branches
.
map
do
|
branch
|
[
branch
.
name
,
repository
.
commit
(
branch
.
dereferenced_target
).
sha
]
end
.
to_h
latest_pipelines
=
project
.
ci_pipelines
.
latest_pipeline_per_commit
(
latest_commits
.
values
)
latest_commits
.
transform_values
do
|
commit_sha
|
latest_pipelines
[
commit_sha
]
&
.
detailed_status
(
current_user
)
end
.
compact
end
end
app/views/projects/branches/_branch.html.haml
View file @
ba318f3d
...
...
@@ -29,6 +29,12 @@
.js-branch-divergence-graph
.controls.d-none.d-md-block
<
-
if
commit_status
=
render
'ci/status/icon'
,
size:
24
,
status:
commit_status
,
option_css_classes:
'gl-display-inline-flex gl-vertical-align-middle gl-mr-5'
-
elsif
show_commit_status
.gl-display-inline-flex.gl-vertical-align-middle.gl-mr-5
%svg
.s24
-
if
merge_project
&&
create_mr_button?
(
@repository
.
root_ref
,
branch
.
name
)
=
link_to
create_mr_path
(
@repository
.
root_ref
,
branch
.
name
),
class:
'btn btn-default'
do
=
_
(
'Merge request'
)
...
...
app/views/projects/branches/_panel.html.haml
View file @
ba318f3d
...
...
@@ -12,7 +12,7 @@
=
panel_title
%ul
.content-list.all-branches.qa-all-branches
-
branches
.
first
(
overview_max_branches
).
each
do
|
branch
|
=
render
"projects/branches/branch"
,
branch:
branch
,
merged:
project
.
repository
.
merged_to_root_ref?
(
branch
)
=
render
"projects/branches/branch"
,
branch:
branch
,
merged:
project
.
repository
.
merged_to_root_ref?
(
branch
)
,
commit_status:
@branch_pipeline_statuses
[
branch
.
name
],
show_commit_status:
@branch_pipeline_statuses
.
any?
-
if
branches
.
size
>
overview_max_branches
.card-footer.text-center
=
link_to
show_more_text
,
project_branches_filtered_path
(
project
,
state:
state
),
id:
"state-
#{
state
}
"
,
data:
{
state:
state
}
app/views/projects/branches/index.html.haml
View file @
ba318f3d
...
...
@@ -59,7 +59,7 @@
-
elsif
@branches
.
any?
%ul
.content-list.all-branches
-
@branches
.
each
do
|
branch
|
=
render
"projects/branches/branch"
,
branch:
branch
,
merged:
@merged_branch_names
.
include?
(
branch
.
name
)
=
render
"projects/branches/branch"
,
branch:
branch
,
merged:
@merged_branch_names
.
include?
(
branch
.
name
)
,
commit_status:
@branch_pipeline_statuses
[
branch
.
name
],
show_commit_status:
@branch_pipeline_statuses
.
any?
=
paginate
@branches
,
theme:
'gitlab'
-
else
.nothing-here-block
...
...
changelogs/unreleased/show_build_status_in_branch_list.yml
0 → 100644
View file @
ba318f3d
---
title
:
Show build status on branch list
merge_request
:
30948
author
:
Lee Tickett
type
:
added
spec/controllers/projects/branches_controller_spec.rb
View file @
ba318f3d
...
...
@@ -487,6 +487,82 @@ RSpec.describe Projects::BranchesController do
end
end
context
'when a branch has multiple pipelines'
do
it
'chooses the latest to determine status'
do
sha
=
project
.
repository
.
create_file
(
developer
,
generate
(
:branch
),
'content'
,
message:
'message'
,
branch_name:
'master'
)
create
(
:ci_pipeline
,
project:
project
,
user:
developer
,
ref:
"master"
,
sha:
sha
,
status: :running
,
created_at:
6
.
months
.
ago
)
create
(
:ci_pipeline
,
project:
project
,
user:
developer
,
ref:
"master"
,
sha:
sha
,
status: :success
,
created_at:
2
.
months
.
ago
)
get
:index
,
format: :html
,
params:
{
namespace_id:
project
.
namespace
,
project_id:
project
,
state:
'all'
}
expect
(
controller
.
instance_variable_get
(
:@branch_pipeline_statuses
)[
"master"
].
group
).
to
eq
(
"success"
)
end
end
context
'when multiple branches exist'
do
it
'all relevant commit statuses are received'
do
master_sha
=
project
.
repository
.
create_file
(
developer
,
generate
(
:branch
),
'content'
,
message:
'message'
,
branch_name:
'master'
)
create
(
:ci_pipeline
,
project:
project
,
user:
developer
,
ref:
"master"
,
sha:
master_sha
,
status: :running
,
created_at:
6
.
months
.
ago
)
test_sha
=
project
.
repository
.
create_file
(
developer
,
generate
(
:branch
),
'content'
,
message:
'message'
,
branch_name:
'test'
)
create
(
:ci_pipeline
,
project:
project
,
user:
developer
,
ref:
"test"
,
sha:
test_sha
,
status: :success
,
created_at:
2
.
months
.
ago
)
get
:index
,
format: :html
,
params:
{
namespace_id:
project
.
namespace
,
project_id:
project
,
state:
'all'
}
expect
(
controller
.
instance_variable_get
(
:@branch_pipeline_statuses
)[
"master"
].
group
).
to
eq
(
"running"
)
expect
(
controller
.
instance_variable_get
(
:@branch_pipeline_statuses
)[
"test"
].
group
).
to
eq
(
"success"
)
end
end
context
'when a branch contains no pipelines'
do
it
'no commit statuses are received'
do
get
:index
,
format: :html
,
params:
{
namespace_id:
project
.
namespace
,
project_id:
project
,
state:
'all'
}
expect
(
controller
.
instance_variable_get
(
:@branch_pipeline_statuses
)).
to
be_blank
end
end
# We need :request_store because Gitaly only counts the queries whenever
# `RequestStore.active?` in GitalyClient.enforce_gitaly_request_limits
# And the main goal of this test is making sure TooManyInvocationsError
...
...
spec/features/projects/branches_spec.rb
View file @
ba318f3d
...
...
@@ -231,6 +231,44 @@ describe 'Branches' do
end
end
context
'with one or more pipeline'
,
:js
do
before
do
sha
=
create_file
(
branch_name:
"branch"
)
create
(
:ci_pipeline
,
project:
project
,
user:
user
,
ref:
"branch"
,
sha:
sha
,
status: :success
,
created_at:
5
.
months
.
ago
)
visit
project_branches_path
(
project
)
end
it
'shows pipeline status when available'
do
page
.
within
first
(
'.all-branches li'
)
do
expect
(
page
).
to
have_css
'a.ci-status-icon-success'
end
end
it
'displays a placeholder when not available'
do
page
.
all
(
'.all-branches li'
)
do
|
li
|
expect
(
li
).
to
have_css
'svg.s24'
end
end
end
context
'with no pipelines'
,
:js
do
before
do
visit
project_branches_path
(
project
)
end
it
'does not show placeholder or pipeline status'
do
page
.
all
(
'.all-branches'
)
do
|
branches
|
expect
(
branches
).
not_to
have_css
'svg.s24'
end
end
end
describe
'comparing branches'
do
before
do
sign_in
(
user
)
...
...
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