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
Léo-Paul Géneau
gitlab-ce
Commits
d60cc75d
Commit
d60cc75d
authored
Oct 18, 2018
by
Alessio Caiazza
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Show modified and added public paths in MR
parent
4a9efc60
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
68 additions
and
0 deletions
+68
-0
app/models/environment_status.rb
app/models/environment_status.rb
+29
-0
app/serializers/environment_status_entity.rb
app/serializers/environment_status_entity.rb
+2
-0
spec/models/environment_status_spec.rb
spec/models/environment_status_spec.rb
+28
-0
spec/serializers/environment_status_entity_spec.rb
spec/serializers/environment_status_entity_spec.rb
+9
-0
No files found.
app/models/environment_status.rb
View file @
d60cc75d
...
...
@@ -24,4 +24,33 @@ class EnvironmentStatus
def
deployed_at
deployment
&
.
created_at
end
def
changes
sha
=
merge_request
.
diff_head_sha
return
[]
if
project
.
route_map_for
(
sha
).
nil?
changed_files
.
map
{
|
file
|
build_change
(
file
,
sha
)
}.
compact
end
def
changed_files
merge_request
.
merge_request_diff
.
merge_request_diff_files
.
where
(
deleted_file:
false
)
end
private
PAGE_EXTENSIONS
=
/\A\.(s?html?|php|asp|cgi|pl)\z/i
.
freeze
def
build_change
(
file
,
sha
)
public_path
=
project
.
public_path_for_source_path
(
file
.
new_path
,
sha
)
return
if
public_path
.
nil?
ext
=
File
.
extname
(
public_path
)
return
if
ext
.
present?
&&
ext
!~
PAGE_EXTENSIONS
{
path:
public_path
,
external_url:
environment
.
external_url_for
(
file
.
new_path
,
sha
)
}
end
end
app/serializers/environment_status_entity.rb
View file @
d60cc75d
...
...
@@ -36,6 +36,8 @@ class EnvironmentStatusEntity < Grape::Entity
es
.
deployment
.
try
(
:formatted_deployment_time
)
end
expose
:changes
,
if:
->
(
*
)
{
Feature
.
enabled?
(
:ci_environments_status_changes
,
project
)
}
private
def
environment
...
...
spec/models/environment_status_spec.rb
View file @
d60cc75d
...
...
@@ -30,4 +30,32 @@ describe EnvironmentStatus do
it
{
is_expected
.
to
eq
(
deployment
)
}
end
# $ git diff --stat pages-deploy-target...pages-deploy
# .gitlab/route-map.yml | 5 +++++
# files/html/500.html | 13 -------------
# files/html/page.html | 3 +++
# files/js/application.js | 3 +++
# files/markdown/ruby-style-guide.md | 4 ++++
# pages-deploy.txt | 1 +
#
# $ cat .gitlab/route-map.yml
# - source: /files\/markdown\/(.+)\.md$/
# public: '\1.html'
#
# - source: /files\/(.+)/
# public: '\1'
describe
'#changes'
do
it
'contains only added and modified public pages'
do
expect
(
environment_status
.
changes
).
to
contain_exactly
(
{
path:
'ruby-style-guide.html'
,
external_url:
"
#{
environment
.
external_url
}
/ruby-style-guide.html"
},
{
path:
'html/page.html'
,
external_url:
"
#{
environment
.
external_url
}
/html/page.html"
}
)
end
end
end
spec/serializers/environment_status_entity_spec.rb
View file @
d60cc75d
...
...
@@ -25,11 +25,20 @@ describe EnvironmentStatusEntity do
it
{
is_expected
.
to
include
(
:external_url_formatted
)
}
it
{
is_expected
.
to
include
(
:deployed_at
)
}
it
{
is_expected
.
to
include
(
:deployed_at_formatted
)
}
it
{
is_expected
.
to
include
(
:changes
)
}
it
{
is_expected
.
not_to
include
(
:stop_url
)
}
it
{
is_expected
.
not_to
include
(
:metrics_url
)
}
it
{
is_expected
.
not_to
include
(
:metrics_monitoring_url
)
}
context
'when :ci_environments_status_changes feature flag is disabled'
do
before
do
stub_feature_flags
(
ci_environments_status_changes:
false
)
end
it
{
is_expected
.
not_to
include
(
:changes
)
}
end
context
'when the user is project maintainer'
do
before
do
project
.
add_maintainer
(
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