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
9f05e97a
Commit
9f05e97a
authored
Mar 13, 2019
by
Nick Thomas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Run rubocop -a
parent
5ed9c5f7
Changes
46
Show whitespace changes
Inline
Side-by-side
Showing
46 changed files
with
326 additions
and
428 deletions
+326
-428
app/models/merge_request_diff.rb
app/models/merge_request_diff.rb
+4
-6
app/models/merge_request_diff_file.rb
app/models/merge_request_diff_file.rb
+1
-1
app/models/project.rb
app/models/project.rb
+3
-5
app/models/project_services/jira_service.rb
app/models/project_services/jira_service.rb
+4
-6
app/models/repository.rb
app/models/repository.rb
+6
-8
app/models/user_interacted_project.rb
app/models/user_interacted_project.rb
+8
-10
app/serializers/detailed_status_entity.rb
app/serializers/detailed_status_entity.rb
+7
-9
app/services/projects/lfs_pointers/lfs_download_link_list_service.rb
...s/projects/lfs_pointers/lfs_download_link_list_service.rb
+7
-9
app/services/projects/lfs_pointers/lfs_download_service.rb
app/services/projects/lfs_pointers/lfs_download_service.rb
+9
-11
app/workers/concerns/waitable_worker.rb
app/workers/concerns/waitable_worker.rb
+3
-5
app/workers/create_gpg_signature_worker.rb
app/workers/create_gpg_signature_worker.rb
+3
-5
app/workers/emails_on_push_worker.rb
app/workers/emails_on_push_worker.rb
+16
-18
app/workers/object_storage/migrate_uploads_worker.rb
app/workers/object_storage/migrate_uploads_worker.rb
+3
-5
app/workers/pipeline_schedule_worker.rb
app/workers/pipeline_schedule_worker.rb
+9
-10
app/workers/remove_expired_members_worker.rb
app/workers/remove_expired_members_worker.rb
+3
-5
config/initializers/trusted_proxies.rb
config/initializers/trusted_proxies.rb
+2
-4
db/migrate/20170530130129_project_foreign_keys_with_cascading_deletes.rb
...0530130129_project_foreign_keys_with_cascading_deletes.rb
+4
-5
lib/api/project_milestones.rb
lib/api/project_milestones.rb
+7
-9
lib/api/repositories.rb
lib/api/repositories.rb
+7
-11
lib/gitlab/background_migration/archive_legacy_traces.rb
lib/gitlab/background_migration/archive_legacy_traces.rb
+4
-5
lib/gitlab/background_migration/normalize_ldap_extern_uids_range.rb
.../background_migration/normalize_ldap_extern_uids_range.rb
+5
-7
lib/gitlab/background_migration/populate_untracked_uploads.rb
...gitlab/background_migration/populate_untracked_uploads.rb
+6
-8
lib/gitlab/bitbucket_import/importer.rb
lib/gitlab/bitbucket_import/importer.rb
+67
-75
lib/gitlab/bitbucket_server_import/importer.rb
lib/gitlab/bitbucket_server_import/importer.rb
+17
-23
lib/gitlab/ci/build/artifacts/metadata.rb
lib/gitlab/ci/build/artifacts/metadata.rb
+1
-1
lib/gitlab/database/multi_threaded_migration.rb
lib/gitlab/database/multi_threaded_migration.rb
+4
-6
lib/gitlab/database/sha_attribute.rb
lib/gitlab/database/sha_attribute.rb
+1
-1
lib/gitlab/gitaly_client.rb
lib/gitlab/gitaly_client.rb
+5
-7
lib/gitlab/gitaly_client/blobs_stitcher.rb
lib/gitlab/gitaly_client/blobs_stitcher.rb
+9
-11
lib/gitlab/legacy_github_import/importer.rb
lib/gitlab/legacy_github_import/importer.rb
+24
-32
lib/gitlab/metrics/influx_db.rb
lib/gitlab/metrics/influx_db.rb
+2
-4
lib/tasks/gitlab/artifacts/migrate.rake
lib/tasks/gitlab/artifacts/migrate.rake
+6
-7
lib/tasks/gitlab/lfs/migrate.rake
lib/tasks/gitlab/lfs/migrate.rake
+5
-6
lib/tasks/gitlab/traces.rake
lib/tasks/gitlab/traces.rake
+5
-6
lib/tasks/lint.rake
lib/tasks/lint.rake
+3
-5
lib/tasks/migrate/migrate_iids.rake
lib/tasks/migrate/migrate_iids.rake
+18
-24
qa/qa/page/project/web_ide/edit.rb
qa/qa/page/project/web_ide/edit.rb
+3
-5
scripts/gitaly_test.rb
scripts/gitaly_test.rb
+7
-9
scripts/merge-simplecov
scripts/merge-simplecov
+3
-5
spec/lib/gitlab/background_migration/deserialize_merge_request_diffs_and_commits_spec.rb
...ation/deserialize_merge_request_diffs_and_commits_spec.rb
+2
-4
spec/lib/gitlab/git/repository_cleaner_spec.rb
spec/lib/gitlab/git/repository_cleaner_spec.rb
+5
-7
spec/rack_servers/puma_spec.rb
spec/rack_servers/puma_spec.rb
+3
-5
spec/services/projects/destroy_service_spec.rb
spec/services/projects/destroy_service_spec.rb
+2
-4
spec/support/helpers/graphql_helpers.rb
spec/support/helpers/graphql_helpers.rb
+4
-6
spec/support/helpers/stub_object_storage.rb
spec/support/helpers/stub_object_storage.rb
+5
-7
spec/support/helpers/test_env.rb
spec/support/helpers/test_env.rb
+4
-6
No files found.
app/models/merge_request_diff.rb
View file @
9f05e97a
...
...
@@ -286,7 +286,6 @@ class MergeRequestDiff < ActiveRecord::Base
return
yield
(
@external_diff_file
)
if
@external_diff_file
external_diff
.
open
do
|
file
|
begin
@external_diff_file
=
file
yield
(
@external_diff_file
)
...
...
@@ -294,7 +293,6 @@ class MergeRequestDiff < ActiveRecord::Base
@external_diff_file
=
nil
end
end
end
private
...
...
app/models/merge_request_diff_file.rb
View file @
9f05e97a
...
...
@@ -23,6 +23,6 @@ class MergeRequestDiffFile < ActiveRecord::Base
super
end
binary?
?
content
.
unpack
(
'm0'
).
first
:
content
binary?
?
content
.
unpack
1
(
'm0'
)
:
content
end
end
app/models/project.rb
View file @
9f05e97a
...
...
@@ -1209,13 +1209,11 @@ class Project < ActiveRecord::Base
def
repo_exists?
strong_memoize
(
:repo_exists
)
do
begin
repository
.
exists?
rescue
false
end
end
end
def
root_ref?
(
branch
)
repository
.
root_ref
==
branch
...
...
app/models/project_services/jira_service.rb
View file @
9f05e97a
...
...
@@ -205,14 +205,12 @@ class JiraService < IssueTrackerService
# if any transition fails it will log the error message and stop the transition sequence
def
transition_issue
(
issue
)
jira_issue_transition_id
.
scan
(
Gitlab
::
Regex
.
jira_transition_id_regex
).
each
do
|
transition_id
|
begin
issue
.
transitions
.
build
.
save!
(
transition:
{
id:
transition_id
})
rescue
=>
error
log_error
(
"Issue transition failed"
,
error:
error
.
message
,
client_url:
client_url
)
return
false
end
end
end
def
add_issue_solved_comment
(
issue
,
commit_id
,
commit_url
)
link_title
=
"Solved by commit
#{
commit_id
}
."
...
...
app/models/repository.rb
View file @
9f05e97a
...
...
@@ -265,7 +265,6 @@ class Repository
# to avoid unnecessary syncing.
def
keep_around
(
*
shas
)
shas
.
each
do
|
sha
|
begin
next
unless
sha
.
present?
&&
commit_by
(
oid:
sha
)
next
if
kept_around?
(
sha
)
...
...
@@ -276,7 +275,6 @@ class Repository
Rails
.
logger
.
error
"Unable to create keep-around reference for repository
#{
disk_path
}
:
#{
ex
}
"
end
end
end
def
kept_around?
(
sha
)
ref_exists?
(
keep_around_ref_name
(
sha
))
...
...
app/models/user_interacted_project.rb
View file @
9f05e97a
...
...
@@ -26,7 +26,6 @@ class UserInteractedProject < ActiveRecord::Base
cached_exists?
(
attributes
)
do
transaction
(
requires_new:
true
)
do
begin
where
(
attributes
).
select
(
1
).
first
||
create!
(
attributes
)
true
# not caching the whole record here for now
rescue
ActiveRecord
::
RecordNotUnique
...
...
@@ -38,7 +37,6 @@ class UserInteractedProject < ActiveRecord::Base
end
end
end
end
# Check if we can safely call .track (table exists)
def
available?
...
...
app/serializers/detailed_status_entity.rb
View file @
9f05e97a
...
...
@@ -9,7 +9,6 @@ class DetailedStatusEntity < Grape::Entity
expose
:details_path
expose
:illustration
do
|
status
|
begin
illustration
=
{
image:
ActionController
::
Base
.
helpers
.
image_path
(
status
.
illustration
[
:image
])
}
...
...
@@ -19,7 +18,6 @@ class DetailedStatusEntity < Grape::Entity
rescue
NotImplementedError
# ignored
end
end
expose
:favicon
do
|
status
|
Gitlab
::
Favicon
.
status_overlay
(
status
.
favicon
)
...
...
app/services/projects/lfs_pointers/lfs_download_link_list_service.rb
View file @
9f05e97a
...
...
@@ -42,7 +42,6 @@ module Projects
def
parse_response_links
(
objects_response
)
objects_response
.
each_with_object
([])
do
|
entry
,
link_list
|
begin
link
=
entry
.
dig
(
'actions'
,
DOWNLOAD_ACTION
,
'href'
)
raise
DownloadLinkNotFound
unless
link
...
...
@@ -54,7 +53,6 @@ module Projects
log_error
(
"Link for Lfs Object with oid
#{
entry
[
'oid'
]
}
not found or invalid."
)
end
end
end
def
request_body
(
oids
)
{
...
...
app/services/projects/lfs_pointers/lfs_download_service.rb
View file @
9f05e97a
...
...
@@ -75,7 +75,6 @@ module Projects
create_tmp_storage_dir
File
.
open
(
tmp_filename
,
'wb'
)
do
|
file
|
begin
yield
file
rescue
StandardError
=>
e
# If the lfs file is successfully downloaded it will be removed
...
...
@@ -87,7 +86,6 @@ module Projects
raise
e
end
end
end
def
tmp_filename
File
.
join
(
tmp_storage_dir
,
lfs_oid
)
...
...
app/workers/concerns/waitable_worker.rb
View file @
9f05e97a
...
...
@@ -25,12 +25,10 @@ module WaitableWorker
failed
=
[]
args_list
.
each
do
|
args
|
begin
new
.
perform
(
*
args
)
rescue
failed
<<
args
end
end
bulk_perform_async
(
failed
)
if
failed
.
present?
end
...
...
app/workers/create_gpg_signature_worker.rb
View file @
9f05e97a
...
...
@@ -20,12 +20,10 @@ class CreateGpgSignatureWorker
# This calculates and caches the signature in the database
commits
.
each
do
|
commit
|
begin
Gitlab
::
Gpg
::
Commit
.
new
(
commit
).
signature
rescue
=>
e
Rails
.
logger
.
error
(
"Failed to create signature for commit
#{
commit
.
id
}
. Error:
#{
e
.
message
}
"
)
end
end
end
# rubocop: enable CodeReuse/ActiveRecord
end
app/workers/emails_on_push_worker.rb
View file @
9f05e97a
...
...
@@ -52,7 +52,6 @@ class EmailsOnPushWorker
end
valid_recipients
(
recipients
).
each
do
|
recipient
|
begin
send_email
(
recipient
,
project_id
,
...
...
@@ -70,7 +69,6 @@ class EmailsOnPushWorker
rescue
Net
::
SMTPFatalError
,
Net
::
SMTPSyntaxError
=>
e
logger
.
info
(
"Failed to send e-mail for project '
#{
project
.
full_name
}
' to
#{
recipient
}
:
#{
e
}
"
)
end
end
ensure
@email
=
nil
compare
=
nil
...
...
app/workers/object_storage/migrate_uploads_worker.rb
View file @
9f05e97a
...
...
@@ -126,12 +126,10 @@ module ObjectStorage
def
process_uploader
(
uploader
)
MigrationResult
.
new
(
uploader
.
upload
).
tap
do
|
result
|
begin
uploader
.
migrate!
(
@to_store
)
rescue
=>
e
result
.
error
=
e
end
end
end
end
end
app/workers/pipeline_schedule_worker.rb
View file @
9f05e97a
...
...
@@ -8,7 +8,7 @@ class PipelineScheduleWorker
def
perform
Ci
::
PipelineSchedule
.
active
.
where
(
"next_run_at < ?"
,
Time
.
now
)
.
preload
(
:owner
,
:project
).
find_each
do
|
schedule
|
begin
Ci
::
CreatePipelineService
.
new
(
schedule
.
project
,
schedule
.
owner
,
ref:
schedule
.
ref
)
...
...
@@ -19,7 +19,6 @@ class PipelineScheduleWorker
schedule
.
schedule_next_run!
end
end
end
# rubocop: enable CodeReuse/ActiveRecord
private
...
...
app/workers/remove_expired_members_worker.rb
View file @
9f05e97a
...
...
@@ -6,11 +6,9 @@ class RemoveExpiredMembersWorker
def
perform
Member
.
expired
.
find_each
do
|
member
|
begin
Members
::
DestroyService
.
new
.
execute
(
member
,
skip_authorization:
true
)
rescue
=>
ex
logger
.
error
(
"Expired Member ID=
#{
member
.
id
}
cannot be removed -
#{
ex
}
"
)
end
end
end
end
config/initializers/trusted_proxies.rb
View file @
9f05e97a
...
...
@@ -14,10 +14,8 @@ module Rack
end
gitlab_trusted_proxies
=
Array
(
Gitlab
.
config
.
gitlab
.
trusted_proxies
).
map
do
|
proxy
|
begin
IPAddr
.
new
(
proxy
)
rescue
IPAddr
::
InvalidAddressError
end
rescue
IPAddr
::
InvalidAddressError
end
.
compact
Rails
.
application
.
config
.
action_dispatch
.
trusted_proxies
=
(
...
...
db/migrate/20170530130129_project_foreign_keys_with_cascading_deletes.rb
View file @
9f05e97a
...
...
@@ -126,12 +126,11 @@ class ProjectForeignKeysWithCascadingDeletes < ActiveRecord::Migration[4.2]
queues
.
each
do
|
queue
|
# Stealing is racy so it's possible a pop might be called on an
# already-empty queue.
begin
remove_orphans
(
*
queue
.
pop
(
true
))
stolen
=
true
rescue
ThreadError
end
end
break
unless
stolen
end
...
...
lib/api/project_milestones.rb
View file @
9f05e97a
...
...
@@ -103,7 +103,6 @@ module API
detail
'This feature was introduced in GitLab 11.9'
end
post
':id/milestones/:milestone_id/promote'
do
begin
authorize!
:admin_milestone
,
user_project
authorize!
:admin_milestone
,
user_project
.
group
...
...
@@ -116,5 +115,4 @@ module API
end
end
end
end
end
lib/api/repositories.rb
View file @
9f05e97a
...
...
@@ -89,12 +89,10 @@ module API
optional
:format
,
type:
String
,
desc:
'The archive format'
end
get
':id/repository/archive'
,
requirements:
{
format:
Gitlab
::
PathRegex
.
archive_formats_regex
}
do
begin
send_git_archive
user_project
.
repository
,
ref:
params
[
:sha
],
format:
params
[
:format
],
append_sha:
true
rescue
not_found!
(
'File'
)
end
end
desc
'Compare two branches, tags, or commits'
do
success
Entities
::
Compare
...
...
@@ -118,13 +116,11 @@ module API
optional
:sort
,
type:
String
,
values:
%w[asc desc]
,
default:
'asc'
,
desc:
'Sort by asc (ascending) or desc (descending)'
end
get
':id/repository/contributors'
do
begin
contributors
=
::
Kaminari
.
paginate_array
(
user_project
.
repository
.
contributors
(
order_by:
params
[
:order_by
],
sort:
params
[
:sort
]))
present
paginate
(
contributors
),
with:
Entities
::
Contributor
rescue
not_found!
end
end
desc
'Get the common ancestor between commits'
do
success
Entities
::
Commit
...
...
lib/gitlab/background_migration/archive_legacy_traces.rb
View file @
9f05e97a
...
...
@@ -11,7 +11,7 @@ module Gitlab
# So we chose a way to use ::Ci::Build directly and we don't change the `archive!` method until 11.1
::
Ci
::
Build
.
finished
.
without_archived_trace
.
where
(
id:
start_id
..
stop_id
).
find_each
do
|
build
|
begin
build
.
trace
.
archive!
rescue
=>
e
Rails
.
logger
.
error
"Failed to archive live trace. id:
#{
build
.
id
}
message:
#{
e
.
message
}
"
...
...
@@ -19,5 +19,4 @@ module Gitlab
end
end
end
end
end
lib/gitlab/background_migration/normalize_ldap_extern_uids_range.rb
View file @
9f05e97a
...
...
@@ -302,7 +302,6 @@ module Gitlab
ldap_identities
=
Identity
.
where
(
"provider like 'ldap%'"
).
where
(
id:
start_id
..
end_id
)
ldap_identities
.
each
do
|
identity
|
begin
identity
.
extern_uid
=
Gitlab
::
Auth
::
LDAP
::
DN
.
new
(
identity
.
extern_uid
).
to_normalized_s
unless
identity
.
save
Rails
.
logger
.
info
"Unable to normalize
\"
#{
identity
.
extern_uid
}
\"
. Skipping."
...
...
@@ -311,7 +310,6 @@ module Gitlab
Rails
.
logger
.
info
"Unable to normalize
\"
#{
identity
.
extern_uid
}
\"
due to
\"
#{
e
.
message
}
\"
. Skipping."
end
end
end
def
migrate?
Identity
.
table_exists?
...
...
lib/gitlab/background_migration/populate_untracked_uploads.rb
View file @
9f05e97a
...
...
@@ -34,7 +34,6 @@ module Gitlab
def
filter_error_files
(
files
)
files
.
partition
do
|
file
|
begin
file
.
to_h
true
rescue
=>
e
...
...
@@ -47,7 +46,6 @@ module Gitlab
false
end
end
end
def
filter_existing_uploads
(
files
)
paths
=
files
.
map
(
&
:upload_path
)
...
...
lib/gitlab/bitbucket_import/importer.rb
View file @
9f05e97a
...
...
@@ -79,7 +79,6 @@ module Gitlab
create_labels
client
.
issues
(
repo
).
each
do
|
issue
|
begin
description
=
''
description
+=
@formatter
.
author_line
(
issue
.
author
)
unless
find_user_id
(
issue
.
author
)
description
+=
issue
.
description
...
...
@@ -105,7 +104,6 @@ module Gitlab
errors
<<
{
type: :issue
,
iid:
issue
.
iid
,
errors:
e
.
message
}
end
end
end
# rubocop: enable CodeReuse/ActiveRecord
def
import_issue_comments
(
issue
,
gitlab_issue
)
...
...
@@ -150,7 +148,6 @@ module Gitlab
pull_requests
=
client
.
pull_requests
(
repo
)
pull_requests
.
each
do
|
pull_request
|
begin
description
=
''
description
+=
@formatter
.
author_line
(
pull_request
.
author
)
unless
find_user_id
(
pull_request
.
author
)
description
+=
pull_request
.
description
...
...
@@ -182,7 +179,6 @@ module Gitlab
errors
<<
{
type: :pull_request
,
iid:
pull_request
.
iid
,
errors:
e
.
message
,
trace:
e
.
backtrace
.
join
(
"
\n
"
),
raw_response:
pull_request
.
raw
}
end
end
end
def
import_pull_request_comments
(
pull_request
,
merge_request
)
comments
=
client
.
pull_request_comments
(
repo
,
pull_request
.
iid
)
...
...
@@ -211,7 +207,6 @@ module Gitlab
end
inline_comments
.
each
do
|
comment
|
begin
attributes
=
pull_request_comment_attributes
(
comment
)
attributes
[
:discussion_id
]
=
discussion_map
[
comment
.
parent_id
]
if
comment
.
has_parent?
...
...
@@ -229,7 +224,6 @@ module Gitlab
errors
<<
{
type: :pull_request
,
iid:
comment
.
iid
,
errors:
e
.
message
}
end
end
end
def
build_position
(
merge_request
,
pr_comment
)
params
=
{
...
...
@@ -245,13 +239,11 @@ module Gitlab
def
import_standalone_pr_comments
(
pr_comments
,
merge_request
)
pr_comments
.
each
do
|
comment
|
begin
merge_request
.
notes
.
create!
(
pull_request_comment_attributes
(
comment
))
rescue
StandardError
=>
e
errors
<<
{
type: :pull_request
,
iid:
comment
.
iid
,
errors:
e
.
message
}
end
end
end
def
pull_request_comment_attributes
(
comment
)
{
...
...
lib/gitlab/bitbucket_server_import/importer.rb
View file @
9f05e97a
...
...
@@ -162,7 +162,6 @@ module Gitlab
restore_branches
(
batch
)
if
recover_missing_commits
batch
.
each
do
|
pull_request
|
begin
import_bitbucket_pull_request
(
pull_request
)
rescue
StandardError
=>
e
backtrace
=
Gitlab
::
Profiler
.
clean_backtrace
(
e
.
backtrace
)
...
...
@@ -172,11 +171,9 @@ module Gitlab
end
end
end
end
def
delete_temp_branches
@temp_branches
.
each
do
|
branch
|
begin
client
.
delete_branch
(
project_key
,
repository_slug
,
branch
.
name
,
branch
.
sha
)
project
.
repository
.
delete_branch
(
branch
.
name
)
rescue
BitbucketServer
::
Connection
::
ConnectionError
=>
e
...
...
@@ -184,7 +181,6 @@ module Gitlab
@errors
<<
{
type: :delete_temp_branches
,
branch_name:
branch
.
name
,
errors:
e
.
message
}
end
end
end
def
import_bitbucket_pull_request
(
pull_request
)
log_info
(
stage:
'import_bitbucket_pull_requests'
,
message:
'starting'
,
iid:
pull_request
.
iid
)
...
...
@@ -323,7 +319,6 @@ module Gitlab
def
import_standalone_pr_comments
(
pr_comments
,
merge_request
)
pr_comments
.
each
do
|
comment
|
begin
merge_request
.
notes
.
create!
(
pull_request_comment_attributes
(
comment
))
comment
.
comments
.
each
do
|
replies
|
...
...
@@ -334,7 +329,6 @@ module Gitlab
errors
<<
{
type: :pull_request
,
comment_id:
comment
.
id
,
errors:
e
.
message
}
end
end
end
def
pull_request_comment_attributes
(
comment
)
author
=
find_user_id
(
comment
.
author_email
)
...
...
lib/gitlab/ci/build/artifacts/metadata.rb
View file @
9f05e97a
...
...
@@ -98,7 +98,7 @@ module Gitlab
def
read_uint32
(
gz
)
binary
=
gz
.
read
(
4
)
binary
.
unpack
(
'L>'
)[
0
]
if
binary
binary
.
unpack
1
(
'L>'
)
if
binary
end
def
read_string
(
gz
)
...
...
lib/gitlab/database/multi_threaded_migration.rb
View file @
9f05e97a
...
...
@@ -35,7 +35,6 @@ module Gitlab
threads
=
Array
.
new
(
thread_count
)
do
Thread
.
new
do
pool
.
with_connection
do
|
connection
|
begin
Thread
.
current
[
MULTI_THREAD_AR_CONNECTION
]
=
connection
yield
ensure
...
...
@@ -43,7 +42,6 @@ module Gitlab
end
end
end
end
threads
.
each
(
&
:join
)
if
join
...
...
lib/gitlab/database/sha_attribute.rb
View file @
9f05e97a
...
...
@@ -22,7 +22,7 @@ module Gitlab
# Casts binary data to a SHA1 in hexadecimal.
def
deserialize
(
value
)
value
=
super
(
value
)
value
?
value
.
unpack
(
PACK_FORMAT
)[
0
]
:
nil
value
?
value
.
unpack
1
(
PACK_FORMAT
)
:
nil
end
# Casts a SHA1 in hexadecimal to the proper binary format.
...
...
lib/gitlab/gitaly_client.rb
View file @
9f05e97a
...
...
@@ -75,13 +75,11 @@ module Gitlab
@certs
=
stub_cert_paths
.
flat_map
do
|
cert_file
|
File
.
read
(
cert_file
).
scan
(
PEM_REGEX
).
map
do
|
cert
|
begin
OpenSSL
::
X509
::
Certificate
.
new
(
cert
).
to_pem
rescue
OpenSSL
::
OpenSSLError
=>
e
Rails
.
logger
.
error
"Could not load certificate
#{
cert_file
}
#{
e
}
"
Gitlab
::
Sentry
.
track_exception
(
e
,
extra:
{
cert_file:
cert_file
})
nil
end
end
.
compact
end
.
uniq
.
join
(
"
\n
"
)
end
...
...
lib/gitlab/gitaly_client/blobs_stitcher.rb
View file @
9f05e97a
...
...
@@ -13,7 +13,6 @@ module Gitlab
current_blob_data
=
nil
@rpc_response
.
each
do
|
msg
|
begin
if
msg
.
oid
.
blank?
&&
msg
.
data
.
blank?
next
elsif
msg
.
oid
.
present?
...
...
@@ -25,7 +24,6 @@ module Gitlab
current_blob_data
[
:data
]
<<
msg
.
data
end
end
end
yield
new_blob
(
current_blob_data
)
if
current_blob_data
end
...
...
lib/gitlab/legacy_github_import/importer.rb
View file @
9f05e97a
...
...
@@ -89,14 +89,12 @@ module Gitlab
def
import_labels
fetch_resources
(
:labels
,
repo
,
per_page:
100
)
do
|
labels
|
labels
.
each
do
|
raw
|
begin
gh_label
=
LabelFormatter
.
new
(
project
,
raw
)
gh_label
.
create!
rescue
=>
e
errors
<<
{
type: :label
,
url:
Gitlab
::
UrlSanitizer
.
sanitize
(
gh_label
.
url
),
errors:
e
.
message
}
end
end
end
cache_labels!
end
...
...
@@ -104,7 +102,6 @@ module Gitlab
def
import_milestones
fetch_resources
(
:milestones
,
repo
,
state: :all
,
per_page:
100
)
do
|
milestones
|
milestones
.
each
do
|
raw
|
begin
gh_milestone
=
MilestoneFormatter
.
new
(
project
,
raw
)
gh_milestone
.
create!
rescue
=>
e
...
...
@@ -112,7 +109,6 @@ module Gitlab
end
end
end
end
# rubocop: disable CodeReuse/ActiveRecord
def
import_issues
...
...
@@ -223,7 +219,6 @@ module Gitlab
def
create_comments
(
comments
)
ActiveRecord
::
Base
.
no_touching
do
comments
.
each
do
|
raw
|
begin
comment
=
CommentFormatter
.
new
(
project
,
raw
,
client
)
# GH does not return info about comment's parent, so we guess it by checking its URL!
...
...
@@ -243,7 +238,6 @@ module Gitlab
end
end
end
end
# rubocop: enable CodeReuse/ActiveRecord
def
discard_inserted_comments
(
comments
,
last_note
)
...
...
@@ -281,7 +275,6 @@ module Gitlab
def
import_releases
fetch_resources
(
:releases
,
repo
,
per_page:
100
)
do
|
releases
|
releases
.
each
do
|
raw
|
begin
gh_release
=
ReleaseFormatter
.
new
(
project
,
raw
)
gh_release
.
create!
if
gh_release
.
valid?
rescue
=>
e
...
...
@@ -289,7 +282,6 @@ module Gitlab
end
end
end
end
def
cache_labels!
project
.
labels
.
select
(
:id
,
:title
).
find_each
do
|
label
|
...
...
lib/gitlab/metrics/influx_db.rb
View file @
9f05e97a
...
...
@@ -52,12 +52,10 @@ module Gitlab
pool
&
.
with
do
|
connection
|
prepared
.
each_slice
(
settings
[
:packet_size
])
do
|
slice
|
begin
connection
.
write_points
(
slice
)
rescue
StandardError
end
end
end
rescue
Errno
::
EADDRNOTAVAIL
,
SocketError
=>
ex
Gitlab
::
EnvironmentLogger
.
error
(
'Cannot resolve InfluxDB address. GitLab Performance Monitoring will not work.'
)
Gitlab
::
EnvironmentLogger
.
error
(
ex
)
...
...
lib/tasks/gitlab/artifacts/migrate.rake
View file @
9f05e97a
...
...
@@ -11,7 +11,7 @@ namespace :gitlab do
Ci
::
Build
.
joins
(
:project
)
.
with_artifacts_stored_locally
.
find_each
(
batch_size:
10
)
do
|
build
|
begin
build
.
artifacts_file
.
migrate!
(
ObjectStorage
::
Store
::
REMOTE
)
build
.
artifacts_metadata
.
migrate!
(
ObjectStorage
::
Store
::
REMOTE
)
...
...
@@ -21,5 +21,4 @@ namespace :gitlab do
end
end
end
end
end
lib/tasks/gitlab/lfs/migrate.rake
View file @
9f05e97a
...
...
@@ -9,7 +9,7 @@ namespace :gitlab do
LfsObject
.
with_files_stored_locally
.
find_each
(
batch_size:
10
)
do
|
lfs_object
|
begin
lfs_object
.
file
.
migrate!
(
LfsObjectUploader
::
Store
::
REMOTE
)
logger
.
info
(
"Transferred LFS object
#{
lfs_object
.
oid
}
of size
#{
lfs_object
.
size
.
to_i
.
bytes
}
to object storage"
)
...
...
@@ -18,5 +18,4 @@ namespace :gitlab do
end
end
end
end
end
lib/tasks/gitlab/traces.rake
View file @
9f05e97a
...
...
@@ -26,7 +26,7 @@ namespace :gitlab do
Ci
::
Build
.
joins
(
:project
)
.
with_archived_trace_stored_locally
.
find_each
(
batch_size:
10
)
do
|
build
|
begin
build
.
job_artifacts_trace
.
file
.
migrate!
(
ObjectStorage
::
Store
::
REMOTE
)
logger
.
info
(
"Transferred job trace of
#{
build
.
id
}
to object storage"
)
...
...
@@ -35,5 +35,4 @@ namespace :gitlab do
end
end
end
end
end
lib/tasks/lint.rake
View file @
9f05e97a
...
...
@@ -19,12 +19,10 @@ unless Rails.env.production?
desc
"GitLab | lint | Lint HAML files"
task
:haml
do
begin
Rake
::
Task
[
'haml_lint'
].
invoke
rescue
RuntimeError
# The haml_lint tasks raise a RuntimeError
exit
(
1
)
end
end
desc
"GitLab | lint | Run several lint checks"
task
:all
do
...
...
lib/tasks/migrate/migrate_iids.rake
View file @
9f05e97a
...
...
@@ -2,7 +2,6 @@ desc "GitLab | Build internal ids for issues and merge requests"
task
migrate_iids: :environment
do
puts
'Issues'
.
color
(
:yellow
)
Issue
.
where
(
iid:
nil
).
find_each
(
batch_size:
100
)
do
|
issue
|
begin
issue
.
set_iid
if
issue
.
update_attribute
(
:iid
,
issue
.
iid
)
...
...
@@ -13,12 +12,10 @@ task migrate_iids: :environment do
rescue
print
'F'
end
end
puts
'done'
puts
'Merge Requests'
.
color
(
:yellow
)
MergeRequest
.
where
(
iid:
nil
).
find_each
(
batch_size:
100
)
do
|
mr
|
begin
mr
.
set_iid
if
mr
.
update_attribute
(
:iid
,
mr
.
iid
)
...
...
@@ -29,12 +26,10 @@ task migrate_iids: :environment do
rescue
print
'F'
end
end
puts
'done'
puts
'Milestones'
.
color
(
:yellow
)
Milestone
.
where
(
iid:
nil
).
find_each
(
batch_size:
100
)
do
|
m
|
begin
m
.
set_iid
if
m
.
update_attribute
(
:iid
,
m
.
iid
)
...
...
@@ -45,7 +40,6 @@ task migrate_iids: :environment do
rescue
print
'F'
end
end
puts
'done'
end
qa/qa/page/project/web_ide/edit.rb
View file @
9f05e97a
...
...
@@ -43,12 +43,10 @@ module QA
def
create_new_file_from_template
(
file_name
,
template
)
click_element
:new_file
within_element
(
:template_list
)
do
begin
click_on
file_name
rescue
Capybara
::
ElementNotFound
raise
ElementNotFound
,
%Q(Couldn't find file template named "
#{
file_name
}
". Please confirm that it is a valid option.)
end
end
wait
(
reload:
false
)
do
within_element
(
:file_templates_bar
)
do
...
...
scripts/gitaly_test.rb
View file @
9f05e97a
...
...
@@ -79,7 +79,6 @@ module GitalyTest
socket
=
read_socket_path
Integer
(
timeout
/
delay
).
times
do
begin
UNIXSocket
.
new
(
socket
)
puts
' OK'
...
...
@@ -88,7 +87,6 @@ module GitalyTest
print
'.'
sleep
delay
end
end
puts
' FAILED'
...
...
scripts/merge-simplecov
View file @
9f05e97a
...
...
@@ -12,13 +12,11 @@ module SimpleCov
def
resultset_hashes
resultset_files
.
map
do
|
path
|
begin
JSON
.
parse
(
File
.
read
(
path
))
rescue
{}
end
end
end
def
resultset
resultset_hashes
.
reduce
({},
:merge
)
...
...
spec/lib/gitlab/background_migration/deserialize_merge_request_diffs_and_commits_spec.rb
View file @
9f05e97a
...
...
@@ -172,11 +172,9 @@ describe Gitlab::BackgroundMigration::DeserializeMergeRequestDiffsAndCommits, :m
let
(
:exception
)
{
ActiveRecord
::
RecordNotFound
}
let
(
:perform_ignoring_exceptions
)
do
begin
subject
.
perform
(
start_id
,
stop_id
)
rescue
described_class
::
Error
end
end
before
do
allow_any_instance_of
(
described_class
::
MergeRequestDiff
::
ActiveRecord_Relation
)
...
...
spec/lib/gitlab/git/repository_cleaner_spec.rb
View file @
9f05e97a
...
...
@@ -37,7 +37,6 @@ describe Gitlab::Git::RepositoryCleaner do
let
(
:object_map
)
{
Gitlab
::
HttpIO
.
new
(
url
,
object_map_data
.
size
)
}
around
do
|
example
|
begin
tempfile
.
write
(
object_map_data
)
tempfile
.
close
...
...
@@ -45,7 +44,6 @@ describe Gitlab::Git::RepositoryCleaner do
ensure
tempfile
.
unlink
end
end
it
'removes internal references'
do
stub_remote_url_200
(
url
,
tempfile
.
path
)
...
...
spec/rack_servers/puma_spec.rb
View file @
9f05e97a
...
...
@@ -44,12 +44,10 @@ describe 'Puma' do
end
after
(
:all
)
do
begin
WebMock
.
disable_net_connect!
(
allow_localhost:
true
)
Process
.
kill
(
'TERM'
,
@puma_master_pid
)
rescue
Errno
::
ESRCH
end
end
def
wait_puma_boot!
(
master_pid
,
ready_file
)
# We have seen the boot timeout after 2 minutes in CI so let's set it to 5 minutes.
...
...
spec/services/projects/destroy_service_spec.rb
View file @
9f05e97a
...
...
@@ -128,11 +128,9 @@ describe Projects::DestroyService do
it
'keeps project team intact upon an error'
do
perform_enqueued_jobs
do
begin
destroy_project
(
project
,
user
,
{})
rescue
::
Redis
::
CannotConnectError
end
end
expect
(
project
.
team
.
members
.
count
).
to
eq
2
end
...
...
spec/support/helpers/graphql_helpers.rb
View file @
9f05e97a
...
...
@@ -18,13 +18,11 @@ module GraphqlHelpers
# Runs a block inside a BatchLoader::Executor wrapper
def
batch
(
max_queries:
nil
,
&
blk
)
wrapper
=
proc
do
begin
BatchLoader
::
Executor
.
ensure_current
yield
ensure
BatchLoader
::
Executor
.
clear_current
end
end
if
max_queries
result
=
nil
...
...
spec/support/helpers/stub_object_storage.rb
View file @
9f05e97a
...
...
@@ -23,7 +23,6 @@ module StubObjectStorage
Fog
.
mock!
::
Fog
::
Storage
.
new
(
connection_params
).
tap
do
|
connection
|
begin
connection
.
directories
.
create
(
key:
remote_directory
)
# Cleanup remaining files
...
...
@@ -33,7 +32,6 @@ module StubObjectStorage
rescue
Excon
::
Error
::
Conflict
end
end
end
def
stub_artifacts_object_storage
(
**
params
)
stub_object_storage_uploader
(
config:
Gitlab
.
config
.
artifacts
.
object_store
,
...
...
spec/support/helpers/test_env.rb
View file @
9f05e97a
...
...
@@ -202,13 +202,11 @@ module TestEnv
socket
=
Gitlab
::
GitalyClient
.
address
(
'default'
).
sub
(
'unix:'
,
''
)
Integer
(
sleep_time
/
sleep_interval
).
times
do
begin
Socket
.
unix
(
socket
)
return
rescue
sleep
sleep_interval
end
end
raise
"could not connect to gitaly at
#{
socket
.
inspect
}
after
#{
sleep_time
}
seconds"
end
...
...
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