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
cc59848b
Commit
cc59848b
authored
May 04, 2017
by
Nick Thomas
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'upstream/master' into ce-to-ee
parents
f5fd172d
407d8af4
Changes
21
Hide whitespace changes
Inline
Side-by-side
Showing
21 changed files
with
176 additions
and
97 deletions
+176
-97
app/assets/javascripts/environments/components/deploy_board_component.vue
...cripts/environments/components/deploy_board_component.vue
+33
-61
app/models/project.rb
app/models/project.rb
+15
-0
bin/elastic_repo_indexer
bin/elastic_repo_indexer
+10
-0
changelogs/unreleased-ee/2222-deploy-boards-polling.yml
changelogs/unreleased-ee/2222-deploy-boards-polling.yml
+4
-0
changelogs/unreleased/fix-import-export-missing-attributes.yml
...elogs/unreleased/fix-import-export-missing-attributes.yml
+4
-0
lib/elasticsearch/git.rb
lib/elasticsearch/git.rb
+0
-3
lib/elasticsearch/git/encoder_helper.rb
lib/elasticsearch/git/encoder_helper.rb
+0
-3
lib/elasticsearch/git/lite_blob.rb
lib/elasticsearch/git/lite_blob.rb
+0
-3
lib/elasticsearch/git/model.rb
lib/elasticsearch/git/model.rb
+0
-4
lib/elasticsearch/git/repository.rb
lib/elasticsearch/git/repository.rb
+0
-9
lib/gitlab/import_export/import_export.yml
lib/gitlab/import_export/import_export.yml
+30
-5
lib/gitlab/import_export/project_tree_restorer.rb
lib/gitlab/import_export/project_tree_restorer.rb
+2
-2
lib/gitlab/import_export/reader.rb
lib/gitlab/import_export/reader.rb
+4
-1
spec/features/issues/issue_sidebar_spec.rb
spec/features/issues/issue_sidebar_spec.rb
+2
-0
spec/lib/gitlab/import_export/project.json
spec/lib/gitlab/import_export/project.json
+1
-0
spec/lib/gitlab/import_export/project_tree_restorer_spec.rb
spec/lib/gitlab/import_export/project_tree_restorer_spec.rb
+4
-0
spec/lib/gitlab/import_export/project_tree_saver_spec.rb
spec/lib/gitlab/import_export/project_tree_saver_spec.rb
+12
-1
spec/lib/gitlab/import_export/reader_spec.rb
spec/lib/gitlab/import_export/reader_spec.rb
+1
-1
spec/lib/gitlab/import_export/safe_model_attributes.yml
spec/lib/gitlab/import_export/safe_model_attributes.yml
+31
-0
spec/models/project_spec.rb
spec/models/project_spec.rb
+19
-0
spec/support/import_export/import_export.yml
spec/support/import_export/import_export.yml
+4
-4
No files found.
app/assets/javascripts/environments/components/deploy_board_component.vue
View file @
cc59848b
...
...
@@ -19,11 +19,11 @@
* Please refer to this [comment](https://gitlab.com/gitlab-org/gitlab-ee/issues/1589#note_23630610)
* for more information
*/
import
statusCodes
from
'
~/lib/utils/http_status
'
;
import
'
~/flash
'
;
import
'
~/lib/utils/common_utils
'
;
import
Visibility
from
'
visibilityjs
'
;
import
deployBoardSvg
from
'
empty_states/icons/_deploy_board.svg
'
;
import
instanceComponent
from
'
./deploy_board_instance_component.vue
'
;
import
Poll
from
'
../../lib/utils/poll
'
;
import
'
../../flash
'
;
export
default
{
...
...
@@ -62,73 +62,45 @@ export default {
return
{
isLoading
:
false
,
hasError
:
false
,
backOffRequestCounter
:
0
,
deployBoardSvg
,
};
},
created
()
{
this
.
getDeployBoard
(
true
);
},
updated
()
{
// While board is not complete we need to request new data from the server.
// Let's make sure we are not making any request at the moment
// and that we only make this request if the latest response was not 204.
if
(
!
this
.
isLoading
&&
!
this
.
hasError
&&
this
.
deployBoardData
.
completion
&&
this
.
deployBoardData
.
completion
<
100
)
{
// let's wait 1s and make the request again
setTimeout
(()
=>
{
this
.
getDeployBoard
(
false
);
},
3000
);
const
poll
=
new
Poll
({
resource
:
this
.
service
,
method
:
'
getDeployBoard
'
,
data
:
this
.
endpoint
,
successCallback
:
this
.
successCallback
,
errorCallback
:
this
.
errorCallback
,
});
if
(
!
Visibility
.
hidden
())
{
this
.
isLoading
=
true
;
poll
.
makeRequest
();
}
Visibility
.
change
(()
=>
{
if
(
!
Visibility
.
hidden
())
{
poll
.
restart
();
}
else
{
poll
.
stop
();
}
});
},
methods
:
{
getDeployBoard
(
showLoading
)
{
this
.
isLoading
=
showLoading
;
const
maxNumberOfRequests
=
3
;
// If the response is 204, we make 3 more requests.
gl
.
utils
.
backOff
((
next
,
stop
)
=>
{
this
.
service
.
getDeployBoard
(
this
.
endpoint
)
.
then
((
resp
)
=>
{
if
(
resp
.
status
===
statusCodes
.
NO_CONTENT
)
{
this
.
backOffRequestCounter
=
this
.
backOffRequestCounter
+=
1
;
if
(
this
.
backOffRequestCounter
<
maxNumberOfRequests
)
{
next
();
}
else
{
stop
(
resp
);
}
}
else
{
stop
(
resp
);
}
})
.
catch
(
stop
);
})
.
then
((
resp
)
=>
{
if
(
resp
.
status
===
statusCodes
.
NO_CONTENT
)
{
this
.
hasError
=
true
;
return
resp
;
}
return
resp
.
json
();
})
.
then
((
response
)
=>
{
this
.
store
.
storeDeployBoard
(
this
.
environmentID
,
response
);
return
response
;
})
.
then
(()
=>
{
this
.
isLoading
=
false
;
})
.
catch
(()
=>
{
this
.
isLoading
=
false
;
new
Flash
(
'
An error occurred while fetching the deploy board.
'
,
'
alert
'
);
});
successCallback
(
response
)
{
const
data
=
response
.
json
();
this
.
store
.
storeDeployBoard
(
this
.
environmentID
,
data
);
this
.
isLoading
=
false
;
},
errorCallback
()
{
this
.
isLoading
=
false
;
// eslint-disable-next-line no-new
new
Flash
(
'
An error occurred while fetching the deploy board.
'
);
},
},
...
...
app/models/project.rb
View file @
cc59848b
...
...
@@ -1484,6 +1484,9 @@ class Project < ActiveRecord::Base
else
update_attribute
(
name
,
value
)
end
rescue
ActiveRecord
::
RecordNotSaved
=>
e
handle_update_attribute_error
(
e
,
value
)
end
def
change_repository_storage
(
new_repository_storage_key
)
...
...
@@ -1645,4 +1648,16 @@ class Project < ActiveRecord::Base
ContainerRepository
.
build_root_repository
(
self
).
has_tags?
end
def
handle_update_attribute_error
(
ex
,
value
)
if
ex
.
message
.
start_with?
(
'Failed to replace'
)
if
value
.
respond_to?
(
:each
)
invalid
=
value
.
detect
(
&
:invalid?
)
raise
ex
,
([
ex
.
message
]
+
invalid
.
errors
.
full_messages
).
join
(
' '
)
if
invalid
end
end
raise
ex
end
end
bin/elastic_repo_indexer
View file @
cc59848b
...
...
@@ -3,14 +3,24 @@
require
'rubygems'
require
'bundler/setup'
require
'json'
require
'active_model'
require
'active_support'
require
'active_support/core_ext'
require
'benchmark'
$:
<<
File
.
expand_path
(
'../lib'
,
File
.
dirname
(
__FILE__
))
require
'linguist'
require
'open3'
require
'rugged'
require
'gitlab/elastic/client'
require
'elasticsearch/model'
require
'elasticsearch/git'
require
'elasticsearch/git/encoder_helper'
require
'elasticsearch/git/lite_blob'
require
'elasticsearch/git/model'
require
'elasticsearch/git/repository'
Thread
.
abort_on_exception
=
true
...
...
changelogs/unreleased-ee/2222-deploy-boards-polling.yml
0 → 100644
View file @
cc59848b
---
title
:
Uses etag polling for deployboards
merge_request
:
1713
author
:
changelogs/unreleased/fix-import-export-missing-attributes.yml
0 → 100644
View file @
cc59848b
---
title
:
Add missing project attributes to Import/Export
merge_request
:
author
:
lib/elasticsearch/git.rb
View file @
cc59848b
require
"elasticsearch/git/model"
require
"elasticsearch/git/repository"
module
Elasticsearch
module
Git
end
...
...
lib/elasticsearch/git/encoder_helper.rb
View file @
cc59848b
require
'active_support/concern'
require
'charlock_holmes'
module
Elasticsearch
module
Git
module
EncoderHelper
...
...
lib/elasticsearch/git/lite_blob.rb
View file @
cc59848b
require
'linguist'
require
'elasticsearch/git/encoder_helper'
module
Elasticsearch
module
Git
class
LiteBlob
...
...
lib/elasticsearch/git/model.rb
View file @
cc59848b
require
'active_support/concern'
require
'active_model'
require
'elasticsearch/model'
module
Elasticsearch
module
Git
module
Model
...
...
lib/elasticsearch/git/repository.rb
View file @
cc59848b
require
'active_support/concern'
require
'active_model'
require
'elasticsearch'
require
'elasticsearch/git/model'
require
'elasticsearch/git/encoder_helper'
require
'elasticsearch/git/lite_blob'
require
'rugged'
require
'open3'
module
Elasticsearch
module
Git
module
Repository
...
...
lib/gitlab/import_export/import_export.yml
View file @
cc59848b
...
...
@@ -41,7 +41,6 @@ project_tree:
-
:statuses
-
triggers
:
-
:trigger_schedule
-
:deploy_keys
-
:services
-
:hooks
-
protected_branches
:
...
...
@@ -53,10 +52,6 @@ project_tree:
# Only include the following attributes for the models specified.
included_attributes
:
project
:
-
:description
-
:visibility_level
-
:archived
user
:
-
:id
-
:email
...
...
@@ -66,6 +61,34 @@ included_attributes:
# Do not include the following attributes for the models specified.
excluded_attributes
:
project
:
-
:name
-
:path
-
:namespace_id
-
:creator_id
-
:import_url
-
:import_status
-
:avatar
-
:import_type
-
:import_source
-
:import_error
-
:mirror
-
:runners_token
-
:repository_storage
-
:repository_read_only
-
:lfs_enabled
-
:import_jid
-
:created_at
-
:updated_at
-
:import_jid
-
:import_jid
-
:id
-
:star_count
-
:last_activity_at
-
:mirror_last_update_at
-
:mirror_last_successful_update_at
-
:mirror_user_id
-
:mirror_trigger_builds
snippets
:
-
:expired_at
merge_request_diff
:
...
...
@@ -94,3 +117,5 @@ methods:
-
:utf8_st_diffs
merge_requests
:
-
:diff_head_sha
project
:
-
:description_html
\ No newline at end of file
lib/gitlab/import_export/project_tree_restorer.rb
View file @
cc59848b
...
...
@@ -71,14 +71,14 @@ module Gitlab
def
restore_project
return
@project
unless
@tree_hash
@project
.
update
(
project_params
)
@project
.
update
_columns
(
project_params
)
@project
end
def
project_params
@tree_hash
.
reject
do
|
key
,
value
|
# return params that are not 1 to many or 1 to 1 relations
value
.
is_a?
(
Array
)
||
key
==
key
.
singularize
value
.
respond_to?
(
:each
)
&&
!
Project
.
column_names
.
include?
(
key
)
end
end
...
...
lib/gitlab/import_export/reader.rb
View file @
cc59848b
...
...
@@ -15,7 +15,10 @@ module Gitlab
# Outputs a hash in the format described here: http://api.rubyonrails.org/classes/ActiveModel/Serializers/JSON.html
# for outputting a project in JSON format, including its relations and sub relations.
def
project_tree
@attributes_finder
.
find_included
(
:project
).
merge
(
include:
build_hash
(
@tree
))
attributes
=
@attributes_finder
.
find
(
:project
)
project_attributes
=
attributes
.
is_a?
(
Hash
)
?
attributes
[
:project
]
:
{}
project_attributes
.
merge
(
include:
build_hash
(
@tree
))
rescue
=>
e
@shared
.
error
(
e
)
false
...
...
spec/features/issues/issue_sidebar_spec.rb
View file @
cc59848b
...
...
@@ -55,10 +55,12 @@ feature 'Issue Sidebar', feature: true do
# Resize the window
resize_screen_sm
# Make sure the sidebar is collapsed
find
(
sidebar_selector
)
expect
(
page
).
to
have_css
(
sidebar_selector
)
# Once is collapsed let's open the sidebard and reload
open_issue_sidebar
refresh
find
(
sidebar_selector
)
expect
(
page
).
to
have_css
(
sidebar_selector
)
# Restore the window size as it was including the sidebar
restore_window_size
...
...
spec/lib/gitlab/import_export/project.json
View file @
cc59848b
...
...
@@ -2,6 +2,7 @@
"description"
:
"Nisi et repellendus ut enim quo accusamus vel magnam."
,
"visibility_level"
:
10
,
"archived"
:
false
,
"description_html"
:
"description"
,
"labels"
:
[
{
"id"
:
2
,
...
...
spec/lib/gitlab/import_export/project_tree_restorer_spec.rb
View file @
cc59848b
...
...
@@ -30,6 +30,10 @@ describe Gitlab::ImportExport::ProjectTreeRestorer, services: true do
expect
(
project
.
project_feature
.
merge_requests_access_level
).
to
eq
(
ProjectFeature
::
ENABLED
)
end
it
'has the project html description'
do
expect
(
Project
.
find_by_path
(
'project'
).
description_html
).
to
eq
(
'description'
)
end
it
'has the same label associated to two issues'
do
expect
(
ProjectLabel
.
find_by_title
(
'test2'
).
issues
.
count
).
to
eq
(
2
)
end
...
...
spec/lib/gitlab/import_export/project_tree_saver_spec.rb
View file @
cc59848b
...
...
@@ -6,7 +6,7 @@ describe Gitlab::ImportExport::ProjectTreeSaver, services: true do
let
(
:project_tree_saver
)
{
described_class
.
new
(
project:
project
,
current_user:
user
,
shared:
shared
)
}
let
(
:export_path
)
{
"
#{
Dir
.
tmpdir
}
/project_tree_saver_spec"
}
let
(
:user
)
{
create
(
:user
)
}
let
(
:project
)
{
setup_project
}
let
!
(
:project
)
{
setup_project
}
before
do
project
.
team
<<
[
user
,
:master
]
...
...
@@ -189,6 +189,16 @@ describe Gitlab::ImportExport::ProjectTreeSaver, services: true do
end
end
end
context
'project attributes'
do
it
'contains the html description'
do
expect
(
saved_project_json
).
to
include
(
"description_html"
=>
'description'
)
end
it
'does not contain the runners token'
do
expect
(
saved_project_json
).
not_to
include
(
"runners_token"
=>
'token'
)
end
end
end
end
...
...
@@ -209,6 +219,7 @@ describe Gitlab::ImportExport::ProjectTreeSaver, services: true do
releases:
[
release
],
group:
group
)
project
.
update_column
(
:description_html
,
'description'
)
project_label
=
create
(
:label
,
project:
project
)
group_label
=
create
(
:group_label
,
group:
group
)
create
(
:label_link
,
label:
project_label
,
target:
issue
)
...
...
spec/lib/gitlab/import_export/reader_spec.rb
View file @
cc59848b
...
...
@@ -5,7 +5,7 @@ describe Gitlab::ImportExport::Reader, lib: true do
let
(
:test_config
)
{
'spec/support/import_export/import_export.yml'
}
let
(
:project_tree_hash
)
do
{
only:
[
:name
,
:path
],
except:
[
:id
,
:created_at
],
include:
[
:issues
,
:labels
,
{
merge_requests:
{
only:
[
:id
],
...
...
spec/lib/gitlab/import_export/safe_model_attributes.yml
View file @
cc59848b
...
...
@@ -333,6 +333,37 @@ Project:
-
snippets_enabled
-
visibility_level
-
archived
-
created_at
-
updated_at
-
last_activity_at
-
star_count
-
ci_id
-
shared_runners_enabled
-
build_coverage_regex
-
build_allow_git_fetchs
-
build_timeout
-
pending_delete
-
public_builds
-
last_repository_check_failed
-
last_repository_check_at
-
container_registry_enabled
-
only_allow_merge_if_pipeline_succeeds
-
has_external_issue_tracker
-
request_access_enabled
-
has_external_wiki
-
only_allow_merge_if_all_discussions_are_resolved
-
auto_cancel_pending_pipelines
-
printing_merge_request_link_enabled
-
build_allow_git_fetch
-
merge_requests_template
-
merge_requests_rebase_enabled
-
approvals_before_merge
-
reset_approvals_on_push
-
merge_requests_ff_only_enabled
-
issues_template
-
repository_size_limit
-
sync_time
-
service_desk_enabled
Author
:
-
name
ProjectFeature
:
...
...
spec/models/project_spec.rb
View file @
cc59848b
...
...
@@ -2321,4 +2321,23 @@ describe Project, models: true do
expect
(
project
.
pipeline_status
).
to
be_loaded
end
end
describe
'#append_or_update_attribute'
do
let
(
:project
)
{
create
(
:project
)
}
it
'shows full error updating an invalid MR'
do
error_message
=
'Failed to replace merge_requests because one or more of the new records could not be saved.'
\
' Validate fork Source project is not a fork of the target project'
expect
{
project
.
append_or_update_attribute
(
:merge_requests
,
[
create
(
:merge_request
)])
}.
to
raise_error
(
ActiveRecord
::
RecordNotSaved
,
error_message
)
end
it
'updates the project succesfully'
do
merge_request
=
create
(
:merge_request
,
target_project:
project
,
source_project:
project
)
expect
{
project
.
append_or_update_attribute
(
:merge_requests
,
[
merge_request
])
}.
not_to
raise_error
end
end
end
spec/support/import_export/import_export.yml
View file @
cc59848b
...
...
@@ -11,9 +11,6 @@ project_tree:
-
:user
included_attributes
:
project
:
-
:name
-
:path
merge_requests
:
-
:id
user
:
...
...
@@ -21,4 +18,7 @@ included_attributes:
excluded_attributes
:
merge_requests
:
-
:iid
\ No newline at end of file
-
:iid
project
:
-
:id
-
:created_at
\ No newline at end of file
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