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
35e2315a
Commit
35e2315a
authored
Oct 12, 2016
by
Z.J. van de Weg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Minor style improvement
parent
4b40027b
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
28 additions
and
16 deletions
+28
-16
app/controllers/projects/merge_requests_controller.rb
app/controllers/projects/merge_requests_controller.rb
+6
-14
app/models/deployment.rb
app/models/deployment.rb
+4
-0
app/models/environment.rb
app/models/environment.rb
+7
-1
db/schema.rb
db/schema.rb
+11
-1
No files found.
app/controllers/projects/merge_requests_controller.rb
View file @
35e2315a
...
...
@@ -404,30 +404,22 @@ class Projects::MergeRequestsController < Projects::ApplicationController
end
def
ci_environments_status
environments
=
environments
=
begin
@merge_request
.
environments
.
map
do
|
environment
|
next
unless
can?
(
current_user
,
:read_environment
,
environment
)
deployment
=
environment
.
first_deployment_for
(
@merge_request
.
diff_head_commit
)
environment_data
=
{
name:
environment
.
name
,
{
id:
environment
.
id
,
name:
environment
.
name
,
url:
namespace_project_environment_path
(
@project
.
namespace
,
@project
,
environment
),
external_url:
environment
.
external_url
,
deployed_at:
deployment
?
deployment
.
created_at
:
nil
external_url_formatted:
environment
.
formatted_external_url
,
deployed_at:
deployment
.
try
(
:created_at
),
deployed_at_formatted:
deployment
.
try
(
:formatted_deployment_time
)
}
if
environment_data
[
:external_url
]
environment_data
[
:external_url_formatted
]
=
environment_data
[
:external_url
].
gsub
(
/\A.*?:\/\//
,
''
)
end
if
environment_data
[
:deployed_at
]
environment_data
[
:deployed_at_formatted
]
=
environment_data
[
:deployed_at
].
to_time
.
in_time_zone
.
to_s
(
:medium
)
end
environment_data
end
.
compact
end
...
...
app/models/deployment.rb
View file @
35e2315a
...
...
@@ -84,6 +84,10 @@ class Deployment < ActiveRecord::Base
take
end
def
formatted_deployment_time
created_at
.
to_time
.
in_time_zone
.
to_s
(
:medium
)
end
private
def
ref_path
...
...
app/models/environment.rb
View file @
35e2315a
...
...
@@ -53,11 +53,17 @@ class Environment < ActiveRecord::Base
return
nil
unless
ref
deployment_id
=
ref
.
split
(
'/'
).
last
.
to_i
deployment_id
=
ref
.
split
(
'/'
).
last
deployments
.
find
(
deployment_id
)
end
def
ref_path
"refs/environments/
#{
Shellwords
.
shellescape
(
name
)
}
"
end
def
formatted_external_url
return
nil
unless
external_url
external_url
.
gsub
(
/\A.*?:\/\//
,
''
)
end
end
db/schema.rb
View file @
35e2315a
...
...
@@ -446,6 +446,17 @@ ActiveRecord::Schema.define(version: 20161007133303) do
add_index
"identities"
,
[
"user_id"
],
name:
"index_identities_on_user_id"
,
using: :btree
create_table
"integrations"
,
force: :cascade
do
|
t
|
t
.
integer
"project_id"
t
.
string
"name"
t
.
string
"external_token"
t
.
datetime
"created_at"
,
null:
false
t
.
datetime
"updated_at"
,
null:
false
end
add_index
"integrations"
,
[
"external_token"
],
name:
"index_integrations_on_external_token"
,
unique:
true
,
using: :btree
add_index
"integrations"
,
[
"project_id"
],
name:
"index_integrations_on_project_id"
,
using: :btree
create_table
"issue_metrics"
,
force: :cascade
do
|
t
|
t
.
integer
"issue_id"
,
null:
false
t
.
datetime
"first_mentioned_in_commit_at"
...
...
@@ -613,7 +624,6 @@ ActiveRecord::Schema.define(version: 20161007133303) do
t
.
datetime
"updated_at"
,
null:
false
end
add_index
"merge_request_metrics"
,
[
"first_deployed_to_production_at"
],
name:
"index_merge_request_metrics_on_first_deployed_to_production_at"
,
using: :btree
add_index
"merge_request_metrics"
,
[
"merge_request_id"
],
name:
"index_merge_request_metrics"
,
using: :btree
create_table
"merge_requests"
,
force: :cascade
do
|
t
|
...
...
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