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
2be85d6b
Commit
2be85d6b
authored
Jul 30, 2020
by
Doug Stull
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Resolve Style/NumericPredicate for lib items
- enforce standards...
parent
935b0bc3
Changes
52
Hide whitespace changes
Inline
Side-by-side
Showing
52 changed files
with
63 additions
and
115 deletions
+63
-115
.rubocop_todo.yml
.rubocop_todo.yml
+0
-52
ee/lib/ee/gitlab/auth/ldap/person.rb
ee/lib/ee/gitlab/auth/ldap/person.rb
+1
-1
ee/lib/ee/gitlab/background_migration/prune_orphaned_geo_events.rb
.../gitlab/background_migration/prune_orphaned_geo_events.rb
+2
-2
ee/lib/ee/gitlab/checks/push_rules/file_size_check.rb
ee/lib/ee/gitlab/checks/push_rules/file_size_check.rb
+1
-1
ee/lib/ee/gitlab/geo_git_access.rb
ee/lib/ee/gitlab/geo_git_access.rb
+1
-1
ee/lib/gitlab/geo/fdw.rb
ee/lib/gitlab/geo/fdw.rb
+3
-3
ee/lib/gitlab/geo/log_cursor/lease.rb
ee/lib/gitlab/geo/log_cursor/lease.rb
+1
-1
ee/lib/tasks/gitlab/elastic.rake
ee/lib/tasks/gitlab/elastic.rake
+1
-1
lib/api/entities/feature.rb
lib/api/entities/feature.rb
+1
-1
lib/api/helpers/pagination_strategies.rb
lib/api/helpers/pagination_strategies.rb
+1
-1
lib/backup/files.rb
lib/backup/files.rb
+1
-1
lib/banzai/filter/gollum_tags_filter.rb
lib/banzai/filter/gollum_tags_filter.rb
+1
-1
lib/bitbucket_server/paginator.rb
lib/bitbucket_server/paginator.rb
+1
-1
lib/declarative_policy/runner.rb
lib/declarative_policy/runner.rb
+1
-1
lib/gitlab/auth/ldap/adapter.rb
lib/gitlab/auth/ldap/adapter.rb
+1
-1
lib/gitlab/bare_repository_import/importer.rb
lib/gitlab/bare_repository_import/importer.rb
+1
-1
lib/gitlab/ci/config/external/context.rb
lib/gitlab/ci/config/external/context.rb
+1
-1
lib/gitlab/ci/reports/accessibility_reports_comparer.rb
lib/gitlab/ci/reports/accessibility_reports_comparer.rb
+1
-1
lib/gitlab/cycle_analytics/summary/value.rb
lib/gitlab/cycle_analytics/summary/value.rb
+1
-1
lib/gitlab/cycle_analytics/summary_helper.rb
lib/gitlab/cycle_analytics/summary_helper.rb
+1
-1
lib/gitlab/danger/teammate.rb
lib/gitlab/danger/teammate.rb
+1
-1
lib/gitlab/database.rb
lib/gitlab/database.rb
+1
-1
lib/gitlab/database/connection_timer.rb
lib/gitlab/database/connection_timer.rb
+1
-1
lib/gitlab/database/migration_helpers.rb
lib/gitlab/database/migration_helpers.rb
+1
-1
lib/gitlab/exclusive_lease.rb
lib/gitlab/exclusive_lease.rb
+1
-1
lib/gitlab/exclusive_lease_helpers/sleeping_lock.rb
lib/gitlab/exclusive_lease_helpers/sleeping_lock.rb
+1
-1
lib/gitlab/experimentation.rb
lib/gitlab/experimentation.rb
+1
-1
lib/gitlab/file_hook.rb
lib/gitlab/file_hook.rb
+1
-1
lib/gitlab/git/commit.rb
lib/gitlab/git/commit.rb
+2
-2
lib/gitlab/git/repository.rb
lib/gitlab/git/repository.rb
+1
-1
lib/gitlab/git/rugged_impl/blob.rb
lib/gitlab/git/rugged_impl/blob.rb
+1
-1
lib/gitlab/gitaly_client.rb
lib/gitlab/gitaly_client.rb
+1
-1
lib/gitlab/github_import/user_finder.rb
lib/gitlab/github_import/user_finder.rb
+1
-1
lib/gitlab/hashed_storage/migrator.rb
lib/gitlab/hashed_storage/migrator.rb
+1
-1
lib/gitlab/import_export/command_line_util.rb
lib/gitlab/import_export/command_line_util.rb
+2
-2
lib/gitlab/multi_collection_paginator.rb
lib/gitlab/multi_collection_paginator.rb
+1
-1
lib/gitlab/polling_interval.rb
lib/gitlab/polling_interval.rb
+1
-1
lib/gitlab/project_search_results.rb
lib/gitlab/project_search_results.rb
+1
-1
lib/gitlab/seeder.rb
lib/gitlab/seeder.rb
+1
-1
lib/gitlab/sidekiq_cluster.rb
lib/gitlab/sidekiq_cluster.rb
+1
-1
lib/gitlab/sidekiq_daemon/memory_killer.rb
lib/gitlab/sidekiq_daemon/memory_killer.rb
+1
-1
lib/gitlab/sidekiq_middleware/memory_killer.rb
lib/gitlab/sidekiq_middleware/memory_killer.rb
+1
-1
lib/gitlab/sidekiq_status.rb
lib/gitlab/sidekiq_status.rb
+1
-1
lib/gitlab/slash_commands/presenters/issue_show.rb
lib/gitlab/slash_commands/presenters/issue_show.rb
+4
-4
lib/gitlab/task_helpers.rb
lib/gitlab/task_helpers.rb
+1
-1
lib/gitlab/untrusted_regexp.rb
lib/gitlab/untrusted_regexp.rb
+2
-2
lib/gitlab/usage_data/topology.rb
lib/gitlab/usage_data/topology.rb
+1
-1
lib/gitlab/utils.rb
lib/gitlab/utils.rb
+1
-1
lib/system_check/sidekiq_check.rb
lib/system_check/sidekiq_check.rb
+1
-1
lib/tasks/gitlab/gitaly.rake
lib/tasks/gitlab/gitaly.rake
+1
-1
lib/tasks/gitlab/snippets.rake
lib/tasks/gitlab/snippets.rake
+4
-4
lib/tasks/gitlab/workhorse.rake
lib/tasks/gitlab/workhorse.rake
+1
-1
No files found.
.rubocop_todo.yml
View file @
2be85d6b
...
@@ -980,59 +980,7 @@ Style/NumericPredicate:
...
@@ -980,59 +980,7 @@ Style/NumericPredicate:
-
'
ee/app/workers/geo/registry_sync_worker.rb'
-
'
ee/app/workers/geo/registry_sync_worker.rb'
-
'
ee/app/workers/geo/repository_shard_sync_worker.rb'
-
'
ee/app/workers/geo/repository_shard_sync_worker.rb'
-
'
ee/app/workers/geo/repository_verification/primary/shard_worker.rb'
-
'
ee/app/workers/geo/repository_verification/primary/shard_worker.rb'
-
'
ee/lib/api/helpers/packages/conan/api_helpers.rb'
-
'
ee/lib/ee/gitlab/auth/ldap/person.rb'
-
'
ee/lib/ee/gitlab/background_migration/prune_orphaned_geo_events.rb'
-
'
ee/lib/ee/gitlab/checks/push_rules/file_size_check.rb'
-
'
ee/lib/ee/gitlab/geo_git_access.rb'
-
'
ee/lib/gitlab/geo/fdw.rb'
-
'
ee/lib/gitlab/geo/log_cursor/lease.rb'
-
'
ee/lib/tasks/gitlab/elastic.rake'
-
'
lib/api/entities/feature.rb'
-
'
lib/api/helpers/pagination_strategies.rb'
-
'
lib/backup/files.rb'
-
'
lib/banzai/filter/gollum_tags_filter.rb'
-
'
lib/bitbucket_server/paginator.rb'
-
'
lib/declarative_policy/runner.rb'
-
'
lib/gitlab/auth/ldap/adapter.rb'
-
'
lib/gitlab/bare_repository_import/importer.rb'
-
'
lib/gitlab/ci/config/external/context.rb'
-
'
lib/gitlab/ci/reports/accessibility_reports_comparer.rb'
-
'
lib/gitlab/cycle_analytics/summary/value.rb'
-
'
lib/gitlab/cycle_analytics/summary_helper.rb'
-
'
lib/gitlab/danger/teammate.rb'
-
'
lib/gitlab/database.rb'
-
'
lib/gitlab/database/connection_timer.rb'
-
'
lib/gitlab/database/migration_helpers.rb'
-
'
lib/gitlab/exclusive_lease.rb'
-
'
lib/gitlab/exclusive_lease_helpers/sleeping_lock.rb'
-
'
lib/gitlab/experimentation.rb'
-
'
lib/gitlab/file_hook.rb'
-
'
lib/gitlab/git/commit.rb'
-
'
lib/gitlab/git/repository.rb'
-
'
lib/gitlab/git/rugged_impl/blob.rb'
-
'
lib/gitlab/gitaly_client.rb'
-
'
lib/gitlab/github_import/user_finder.rb'
-
'
lib/gitlab/hashed_storage/migrator.rb'
-
'
lib/gitlab/import_export/command_line_util.rb'
-
'
lib/gitlab/multi_collection_paginator.rb'
-
'
lib/gitlab/polling_interval.rb'
-
'
lib/gitlab/project_search_results.rb'
-
'
lib/gitlab/seeder.rb'
-
'
lib/gitlab/sidekiq_cluster.rb'
-
'
lib/gitlab/sidekiq_daemon/memory_killer.rb'
-
'
lib/gitlab/sidekiq_middleware/memory_killer.rb'
-
'
lib/gitlab/sidekiq_status.rb'
-
'
lib/gitlab/slash_commands/presenters/issue_show.rb'
-
'
lib/gitlab/task_helpers.rb'
-
'
lib/gitlab/untrusted_regexp.rb'
-
'
lib/gitlab/utils.rb'
-
'
lib/system_check/sidekiq_check.rb'
-
'
lib/tasks/gitlab/gitaly.rake'
-
'
lib/tasks/gitlab/snippets.rake'
-
'
lib/tasks/gitlab/workhorse.rake'
-
'
ee/app/models/ee/project.rb'
-
'
ee/app/models/ee/project.rb'
-
'
lib/gitlab/usage_data/topology.rb'
# Offense count: 117
# Offense count: 117
# Cop supports --auto-correct.
# Cop supports --auto-correct.
...
...
ee/lib/ee/gitlab/auth/ldap/person.rb
View file @
2be85d6b
...
@@ -46,7 +46,7 @@ module EE
...
@@ -46,7 +46,7 @@ module EE
::
Gitlab
::
Auth
::
Ldap
::
DN
.
new
(
dn
).
each_pair
{
|
name
,
value
|
dn_components
<<
{
name:
name
,
value:
value
}
}
::
Gitlab
::
Auth
::
Ldap
::
DN
.
new
(
dn
).
each_pair
{
|
name
,
value
|
dn_components
<<
{
name:
name
,
value:
value
}
}
dn_components
dn_components
.
reverse
.
reverse
.
take_while
{
|
rdn
|
rdn
[
:name
].
casecmp
(
'DC'
)
.
zero?
}
# Domain Component
.
take_while
{
|
rdn
|
rdn
[
:name
].
casecmp
(
'DC'
)
==
0
}
# Domain Component
.
map
{
|
rdn
|
rdn
[
:value
]
}
.
map
{
|
rdn
|
rdn
[
:value
]
}
.
reverse
.
reverse
.
join
(
'.'
)
.
join
(
'.'
)
...
...
ee/lib/ee/gitlab/background_migration/prune_orphaned_geo_events.rb
View file @
2be85d6b
...
@@ -45,7 +45,7 @@ module EE
...
@@ -45,7 +45,7 @@ module EE
def
delete_batch_of_orphans!
def
delete_batch_of_orphans!
deleted
=
where
(
id:
orphans
.
limit
(
BATCH_SIZE
)).
delete_all
deleted
=
where
(
id:
orphans
.
limit
(
BATCH_SIZE
)).
delete_all
vacuum!
if
deleted
.
positive?
vacuum!
if
deleted
>
0
deleted
deleted
end
end
...
@@ -64,7 +64,7 @@ module EE
...
@@ -64,7 +64,7 @@ module EE
return
if
::
Gitlab
::
Database
.
read_only?
return
if
::
Gitlab
::
Database
.
read_only?
deleted_rows
=
prune_orphaned_rows
(
table_name
)
deleted_rows
=
prune_orphaned_rows
(
table_name
)
table_name
=
next_table
(
table_name
)
if
deleted_rows
.
zero?
table_name
=
next_table
(
table_name
)
if
deleted_rows
==
0
::
BackgroundMigrationWorker
.
perform_in
(
RESCHEDULE_DELAY
,
self
.
class
.
name
.
demodulize
,
table_name
)
if
table_name
::
BackgroundMigrationWorker
.
perform_in
(
RESCHEDULE_DELAY
,
self
.
class
.
name
.
demodulize
,
table_name
)
if
table_name
end
end
...
...
ee/lib/ee/gitlab/checks/push_rules/file_size_check.rb
View file @
2be85d6b
...
@@ -8,7 +8,7 @@ module EE
...
@@ -8,7 +8,7 @@ module EE
LOG_MESSAGE
=
"Checking if any files are larger than the allowed size..."
.
freeze
LOG_MESSAGE
=
"Checking if any files are larger than the allowed size..."
.
freeze
def
validate!
def
validate!
return
if
push_rule
.
nil?
||
push_rule
.
max_file_size
.
zero?
return
if
push_rule
.
nil?
||
push_rule
.
max_file_size
==
0
logger
.
log_timed
(
LOG_MESSAGE
)
do
logger
.
log_timed
(
LOG_MESSAGE
)
do
max_file_size
=
push_rule
.
max_file_size
max_file_size
=
push_rule
.
max_file_size
...
...
ee/lib/ee/gitlab/geo_git_access.rb
View file @
2be85d6b
...
@@ -82,7 +82,7 @@ module EE
...
@@ -82,7 +82,7 @@ module EE
end
end
def
current_replication_lag_message
def
current_replication_lag_message
return
if
::
Gitlab
::
Database
.
read_write?
||
current_replication_lag
.
zero?
return
if
::
Gitlab
::
Database
.
read_write?
||
current_replication_lag
==
0
"Current replication lag:
#{
current_replication_lag
}
seconds"
"Current replication lag:
#{
current_replication_lag
}
seconds"
end
end
...
...
ee/lib/gitlab/geo/fdw.rb
View file @
2be85d6b
...
@@ -63,7 +63,7 @@ module Gitlab
...
@@ -63,7 +63,7 @@ module Gitlab
private
private
def
fdw_capable?
def
fdw_capable?
has_foreign_server?
&&
has_foreign_schema?
&&
foreign_schema_tables_count
.
positive?
has_foreign_server?
&&
has_foreign_schema?
&&
foreign_schema_tables_count
>
0
rescue
::
Geo
::
TrackingBase
::
SecondaryNotConfigured
rescue
::
Geo
::
TrackingBase
::
SecondaryNotConfigured
false
false
end
end
...
@@ -74,7 +74,7 @@ module Gitlab
...
@@ -74,7 +74,7 @@ module Gitlab
def
has_foreign_server?
def
has_foreign_server?
::
Geo
::
TrackingBase
.
connection
.
execute
(
::
Geo
::
TrackingBase
.
connection
.
execute
(
"SELECT 1 FROM pg_foreign_server"
"SELECT 1 FROM pg_foreign_server"
).
count
.
positive?
).
count
>
0
end
end
def
has_foreign_schema?
def
has_foreign_schema?
...
@@ -85,7 +85,7 @@ module Gitlab
...
@@ -85,7 +85,7 @@ module Gitlab
WHERE schema_name='
#{
FOREIGN_SCHEMA
}
'
WHERE schema_name='
#{
FOREIGN_SCHEMA
}
'
SQL
SQL
::
Geo
::
TrackingBase
.
connection
.
execute
(
sql
).
count
.
positive?
::
Geo
::
TrackingBase
.
connection
.
execute
(
sql
).
count
>
0
end
end
end
end
...
...
ee/lib/gitlab/geo/log_cursor/lease.rb
View file @
2be85d6b
...
@@ -23,7 +23,7 @@ module Gitlab
...
@@ -23,7 +23,7 @@ module Gitlab
def
self
.
try_obtain_with_ttl
def
self
.
try_obtain_with_ttl
lease
=
exclusive_lease
.
try_obtain_with_ttl
lease
=
exclusive_lease
.
try_obtain_with_ttl
unless
lease
[
:ttl
]
.
zero?
||
exclusive_lease
.
same_uuid?
unless
lease
[
:ttl
]
==
0
||
exclusive_lease
.
same_uuid?
$stdout
.
puts
lease_taken_message
$stdout
.
puts
lease_taken_message
logger
.
debug
(
lease_taken_message
)
logger
.
debug
(
lease_taken_message
)
...
...
ee/lib/tasks/gitlab/elastic.rake
View file @
2be85d6b
...
@@ -108,7 +108,7 @@ namespace :gitlab do
...
@@ -108,7 +108,7 @@ namespace :gitlab do
task
projects_not_indexed: :environment
do
task
projects_not_indexed: :environment
do
not_indexed
=
Project
.
where
.
not
(
id:
IndexStatus
.
select
(
:project_id
).
distinct
)
not_indexed
=
Project
.
where
.
not
(
id:
IndexStatus
.
select
(
:project_id
).
distinct
)
if
not_indexed
.
count
.
zero?
if
not_indexed
.
count
==
0
puts
'All projects are currently indexed'
.
color
(
:green
)
puts
'All projects are currently indexed'
.
color
(
:green
)
else
else
display_unindexed
(
not_indexed
)
display_unindexed
(
not_indexed
)
...
...
lib/api/entities/feature.rb
View file @
2be85d6b
...
@@ -10,7 +10,7 @@ module API
...
@@ -10,7 +10,7 @@ module API
value
=
model
.
gate_values
[
gate
.
key
]
value
=
model
.
gate_values
[
gate
.
key
]
# By default all gate values are populated. Only show relevant ones.
# By default all gate values are populated. Only show relevant ones.
if
(
value
.
is_a?
(
Integer
)
&&
value
.
zero?
)
||
(
value
.
is_a?
(
Set
)
&&
value
.
empty?
)
if
(
value
.
is_a?
(
Integer
)
&&
value
==
0
)
||
(
value
.
is_a?
(
Set
)
&&
value
.
empty?
)
next
next
end
end
...
...
lib/api/helpers/pagination_strategies.rb
View file @
2be85d6b
...
@@ -48,7 +48,7 @@ module API
...
@@ -48,7 +48,7 @@ module API
end
end
def
offset_limit_exceeded?
(
offset_limit
)
def
offset_limit_exceeded?
(
offset_limit
)
offset_limit
.
positive?
&&
params
[
:page
]
*
params
[
:per_page
]
>
offset_limit
offset_limit
>
0
&&
params
[
:page
]
*
params
[
:per_page
]
>
offset_limit
end
end
end
end
end
end
...
...
lib/backup/files.rb
View file @
2be85d6b
...
@@ -26,7 +26,7 @@ module Backup
...
@@ -26,7 +26,7 @@ module Backup
cmd
=
%W(rsync -a --exclude=lost+found
#{
app_files_dir
}
#{
Gitlab
.
config
.
backup
.
path
}
)
cmd
=
%W(rsync -a --exclude=lost+found
#{
app_files_dir
}
#{
Gitlab
.
config
.
backup
.
path
}
)
output
,
status
=
Gitlab
::
Popen
.
popen
(
cmd
)
output
,
status
=
Gitlab
::
Popen
.
popen
(
cmd
)
unless
status
.
zero?
unless
status
==
0
puts
output
puts
output
raise
Backup
::
Error
,
'Backup failed'
raise
Backup
::
Error
,
'Backup failed'
end
end
...
...
lib/banzai/filter/gollum_tags_filter.rb
View file @
2be85d6b
...
@@ -82,7 +82,7 @@ module Banzai
...
@@ -82,7 +82,7 @@ module Banzai
def
process_tag
(
tag
)
def
process_tag
(
tag
)
parts
=
tag
.
split
(
'|'
)
parts
=
tag
.
split
(
'|'
)
return
if
parts
.
size
.
zero
?
return
if
parts
.
empty
?
process_image_tag
(
parts
)
||
process_page_link_tag
(
parts
)
process_image_tag
(
parts
)
||
process_page_link_tag
(
parts
)
end
end
...
...
lib/bitbucket_server/paginator.rb
View file @
2be85d6b
...
@@ -36,7 +36,7 @@ module BitbucketServer
...
@@ -36,7 +36,7 @@ module BitbucketServer
def
over_limit?
def
over_limit?
return
false
unless
@limit
return
false
unless
@limit
@limit
.
positive?
&&
@total
>=
@limit
@limit
>
0
&&
@total
>=
@limit
end
end
def
next_offset
def
next_offset
...
...
lib/declarative_policy/runner.rb
View file @
2be85d6b
...
@@ -170,7 +170,7 @@ module DeclarativePolicy
...
@@ -170,7 +170,7 @@ module DeclarativePolicy
lowest_score
=
score
lowest_score
=
score
end
end
break
if
lowest_score
.
zero?
break
if
lowest_score
==
0
end
end
[
remaining_steps
,
remaining_enablers
,
remaining_preventers
].
each
do
|
set
|
[
remaining_steps
,
remaining_enablers
,
remaining_preventers
].
each
do
|
set
|
...
...
lib/gitlab/auth/ldap/adapter.rb
View file @
2be85d6b
...
@@ -54,7 +54,7 @@ module Gitlab
...
@@ -54,7 +54,7 @@ module Gitlab
if
results
.
nil?
if
results
.
nil?
response
=
ldap
.
get_operation_result
response
=
ldap
.
get_operation_result
unless
response
.
code
.
zero?
unless
response
.
code
==
0
Rails
.
logger
.
warn
(
"LDAP search error:
#{
response
.
message
}
"
)
# rubocop:disable Gitlab/RailsLogger
Rails
.
logger
.
warn
(
"LDAP search error:
#{
response
.
message
}
"
)
# rubocop:disable Gitlab/RailsLogger
end
end
...
...
lib/gitlab/bare_repository_import/importer.rb
View file @
2be85d6b
...
@@ -123,7 +123,7 @@ module Gitlab
...
@@ -123,7 +123,7 @@ module Gitlab
cmd
=
%W(
#{
Gitlab
.
config
.
git
.
bin_path
}
--git-dir=
#{
repo_path
}
bundle create
#{
bundle_path
}
--all)
cmd
=
%W(
#{
Gitlab
.
config
.
git
.
bin_path
}
--git-dir=
#{
repo_path
}
bundle create
#{
bundle_path
}
--all)
output
,
status
=
Gitlab
::
Popen
.
popen
(
cmd
)
output
,
status
=
Gitlab
::
Popen
.
popen
(
cmd
)
raise
output
unless
status
.
zero?
raise
output
unless
status
==
0
bundle_path
bundle_path
end
end
...
...
lib/gitlab/ci/config/external/context.rb
View file @
2be85d6b
...
@@ -54,7 +54,7 @@ module Gitlab
...
@@ -54,7 +54,7 @@ module Gitlab
end
end
def
execution_expired?
def
execution_expired?
return
false
if
execution_deadline
.
zero?
return
false
if
execution_deadline
==
0
current_monotonic_time
>
execution_deadline
current_monotonic_time
>
execution_deadline
end
end
...
...
lib/gitlab/ci/reports/accessibility_reports_comparer.rb
View file @
2be85d6b
...
@@ -17,7 +17,7 @@ module Gitlab
...
@@ -17,7 +17,7 @@ module Gitlab
end
end
def
status
def
status
head_reports
.
errors_count
.
positive?
?
STATUS_FAILED
:
STATUS_SUCCESS
head_reports
.
errors_count
>
0
?
STATUS_FAILED
:
STATUS_SUCCESS
end
end
def
existing_errors
def
existing_errors
...
...
lib/gitlab/cycle_analytics/summary/value.rb
View file @
2be85d6b
...
@@ -34,7 +34,7 @@ module Gitlab
...
@@ -34,7 +34,7 @@ module Gitlab
end
end
def
to_s
def
to_s
value
.
zero?
?
'0'
:
value
.
to_s
value
==
0
?
'0'
:
value
.
to_s
end
end
def
to_i
def
to_i
...
...
lib/gitlab/cycle_analytics/summary_helper.rb
View file @
2be85d6b
...
@@ -4,7 +4,7 @@ module Gitlab
...
@@ -4,7 +4,7 @@ module Gitlab
module
CycleAnalytics
module
CycleAnalytics
module
SummaryHelper
module
SummaryHelper
def
frequency
(
count
,
from
,
to
)
def
frequency
(
count
,
from
,
to
)
return
Summary
::
Value
::
None
.
new
if
count
.
zero?
return
Summary
::
Value
::
None
.
new
if
count
==
0
freq
=
(
count
/
days
(
from
,
to
)).
round
(
1
)
freq
=
(
count
/
days
(
from
,
to
)).
round
(
1
)
...
...
lib/gitlab/danger/teammate.rb
View file @
2be85d6b
...
@@ -80,7 +80,7 @@ module Gitlab
...
@@ -80,7 +80,7 @@ module Gitlab
def
offset_diff_compared_to_author
(
author
)
def
offset_diff_compared_to_author
(
author
)
diff
=
floored_offset_hours
-
author
.
floored_offset_hours
diff
=
floored_offset_hours
-
author
.
floored_offset_hours
return
"same timezone as `@
#{
author
.
username
}
`"
if
diff
.
zero?
return
"same timezone as `@
#{
author
.
username
}
`"
if
diff
==
0
ahead_or_behind
=
diff
<
0
?
'behind'
:
'ahead of'
ahead_or_behind
=
diff
<
0
?
'behind'
:
'ahead of'
pluralized_hours
=
pluralize
(
diff
.
abs
,
'hour'
,
'hours'
)
pluralized_hours
=
pluralize
(
diff
.
abs
,
'hour'
,
'hours'
)
...
...
lib/gitlab/database.rb
View file @
2be85d6b
...
@@ -74,7 +74,7 @@ module Gitlab
...
@@ -74,7 +74,7 @@ module Gitlab
# @deprecated
# @deprecated
def
self
.
postgresql?
def
self
.
postgresql?
adapter_name
.
casecmp
(
'postgresql'
)
.
zero?
adapter_name
.
casecmp
(
'postgresql'
)
==
0
end
end
def
self
.
read_only?
def
self
.
read_only?
...
...
lib/gitlab/database/connection_timer.rb
View file @
2be85d6b
...
@@ -23,7 +23,7 @@ module Gitlab
...
@@ -23,7 +23,7 @@ module Gitlab
end
end
def
interval_with_randomization
def
interval_with_randomization
interval
+
rand
(
RANDOMIZATION_INTERVAL
)
if
interval
.
positive?
interval
+
rand
(
RANDOMIZATION_INTERVAL
)
if
interval
>
0
end
end
def
current_clock_value
def
current_clock_value
...
...
lib/gitlab/database/migration_helpers.rb
View file @
2be85d6b
...
@@ -1062,7 +1062,7 @@ into similar problems in the future (e.g. when new tables are created).
...
@@ -1062,7 +1062,7 @@ into similar problems in the future (e.g. when new tables are created).
AND pg_class.relname = '
#{
table
}
'
AND pg_class.relname = '
#{
table
}
'
SQL
SQL
connection
.
select_value
(
check_sql
)
.
positive?
connection
.
select_value
(
check_sql
)
>
0
end
end
# Adds a check constraint to a table
# Adds a check constraint to a table
...
...
lib/gitlab/exclusive_lease.rb
View file @
2be85d6b
...
@@ -102,7 +102,7 @@ module Gitlab
...
@@ -102,7 +102,7 @@ module Gitlab
Gitlab
::
Redis
::
SharedState
.
with
do
|
redis
|
Gitlab
::
Redis
::
SharedState
.
with
do
|
redis
|
ttl
=
redis
.
ttl
(
@redis_shared_state_key
)
ttl
=
redis
.
ttl
(
@redis_shared_state_key
)
ttl
if
ttl
.
positive?
ttl
if
ttl
>
0
end
end
end
end
...
...
lib/gitlab/exclusive_lease_helpers/sleeping_lock.rb
View file @
2be85d6b
...
@@ -39,7 +39,7 @@ module Gitlab
...
@@ -39,7 +39,7 @@ module Gitlab
end
end
def
first_attempt?
def
first_attempt?
attempts
.
zero?
attempts
==
0
end
end
def
sleep_sec
def
sleep_sec
...
...
lib/gitlab/experimentation.rb
View file @
2be85d6b
...
@@ -170,7 +170,7 @@ module Gitlab
...
@@ -170,7 +170,7 @@ module Gitlab
Experiment
=
Struct
.
new
(
:key
,
:environment
,
:tracking_category
,
keyword_init:
true
)
do
Experiment
=
Struct
.
new
(
:key
,
:environment
,
:tracking_category
,
keyword_init:
true
)
do
def
enabled?
def
enabled?
experiment_percentage
.
positive?
experiment_percentage
>
0
end
end
def
enabled_for_environment?
def
enabled_for_environment?
...
...
lib/gitlab/file_hook.rb
View file @
2be85d6b
...
@@ -27,7 +27,7 @@ module Gitlab
...
@@ -27,7 +27,7 @@ module Gitlab
end
end
exit_status
=
result
.
status
&
.
exitstatus
exit_status
=
result
.
status
&
.
exitstatus
[
exit_status
.
zero?
,
result
.
stderr
]
[
exit_status
==
0
,
result
.
stderr
]
rescue
=>
e
rescue
=>
e
[
false
,
e
.
message
]
[
false
,
e
.
message
]
end
end
...
...
lib/gitlab/git/commit.rb
View file @
2be85d6b
...
@@ -261,7 +261,7 @@ module Gitlab
...
@@ -261,7 +261,7 @@ module Gitlab
end
end
def
has_zero_stats?
def
has_zero_stats?
stats
.
total
.
zero?
stats
.
total
==
0
rescue
rescue
true
true
end
end
...
@@ -423,7 +423,7 @@ module Gitlab
...
@@ -423,7 +423,7 @@ module Gitlab
end
end
def
message_from_gitaly_body
def
message_from_gitaly_body
return
@raw_commit
.
subject
.
dup
if
@raw_commit
.
body_size
.
zero?
return
@raw_commit
.
subject
.
dup
if
@raw_commit
.
body_size
==
0
return
@raw_commit
.
body
.
dup
if
full_body_fetched_from_gitaly?
return
@raw_commit
.
body
.
dup
if
full_body_fetched_from_gitaly?
if
@raw_commit
.
body_size
>
MAX_COMMIT_MESSAGE_DISPLAY_SIZE
if
@raw_commit
.
body_size
>
MAX_COMMIT_MESSAGE_DISPLAY_SIZE
...
...
lib/gitlab/git/repository.rb
View file @
2be85d6b
...
@@ -815,7 +815,7 @@ module Gitlab
...
@@ -815,7 +815,7 @@ module Gitlab
def
fsck
def
fsck
msg
,
status
=
gitaly_repository_client
.
fsck
msg
,
status
=
gitaly_repository_client
.
fsck
raise
GitError
.
new
(
"Could not fsck repository:
#{
msg
}
"
)
unless
status
.
zero?
raise
GitError
.
new
(
"Could not fsck repository:
#{
msg
}
"
)
unless
status
==
0
end
end
def
create_from_bundle
(
bundle_path
)
def
create_from_bundle
(
bundle_path
)
...
...
lib/gitlab/git/rugged_impl/blob.rb
View file @
2be85d6b
...
@@ -48,7 +48,7 @@ module Gitlab
...
@@ -48,7 +48,7 @@ module Gitlab
name:
blob_entry
[
:name
],
name:
blob_entry
[
:name
],
size:
blob
.
size
,
size:
blob
.
size
,
# Rugged::Blob#content is expensive; don't call it if we don't have to.
# Rugged::Blob#content is expensive; don't call it if we don't have to.
data:
limit
.
zero?
?
''
:
blob
.
content
(
limit
),
data:
limit
==
0
?
''
:
blob
.
content
(
limit
),
mode:
blob_entry
[
:filemode
].
to_s
(
8
),
mode:
blob_entry
[
:filemode
].
to_s
(
8
),
path:
path
,
path:
path
,
commit_id:
sha
,
commit_id:
sha
,
...
...
lib/gitlab/gitaly_client.rb
View file @
2be85d6b
...
@@ -476,7 +476,7 @@ module Gitlab
...
@@ -476,7 +476,7 @@ module Gitlab
return
unless
stack_counter
return
unless
stack_counter
max
=
max_call_count
max
=
max_call_count
return
if
max
.
zero?
return
if
max
==
0
stack_counter
.
select
{
|
_
,
v
|
v
==
max
}.
keys
stack_counter
.
select
{
|
_
,
v
|
v
==
max
}.
keys
end
end
...
...
lib/gitlab/github_import/user_finder.rb
View file @
2be85d6b
...
@@ -161,7 +161,7 @@ module Gitlab
...
@@ -161,7 +161,7 @@ module Gitlab
# The cache key may be empty to indicate a previously looked up user for
# The cache key may be empty to indicate a previously looked up user for
# which we couldn't find an ID.
# which we couldn't find an ID.
[
exists
,
number
.
positive?
?
number
:
nil
]
[
exists
,
number
>
0
?
number
:
nil
]
end
end
end
end
end
end
...
...
lib/gitlab/hashed_storage/migrator.rb
View file @
2be85d6b
...
@@ -101,7 +101,7 @@ module Gitlab
...
@@ -101,7 +101,7 @@ module Gitlab
def
any_non_empty_queue?
(
*
workers
)
def
any_non_empty_queue?
(
*
workers
)
workers
.
any?
do
|
worker
|
workers
.
any?
do
|
worker
|
!
Sidekiq
::
Queue
.
new
(
worker
.
queue
).
size
.
zero?
Sidekiq
::
Queue
.
new
(
worker
.
queue
).
size
!=
0
# rubocop:disable Style/ZeroLengthPredicate
end
end
end
end
...
...
lib/gitlab/import_export/command_line_util.rb
View file @
2be85d6b
...
@@ -47,8 +47,8 @@ module Gitlab
...
@@ -47,8 +47,8 @@ module Gitlab
def
execute
(
cmd
)
def
execute
(
cmd
)
output
,
status
=
Gitlab
::
Popen
.
popen
(
cmd
)
output
,
status
=
Gitlab
::
Popen
.
popen
(
cmd
)
@shared
.
error
(
Gitlab
::
ImportExport
::
Error
.
new
(
output
.
to_s
))
unless
status
.
zero?
# rubocop:disable Gitlab/ModuleWithInstanceVariables
@shared
.
error
(
Gitlab
::
ImportExport
::
Error
.
new
(
output
.
to_s
))
unless
status
==
0
# rubocop:disable Gitlab/ModuleWithInstanceVariables
status
.
zero?
status
==
0
end
end
def
git_bin_path
def
git_bin_path
...
...
lib/gitlab/multi_collection_paginator.rb
View file @
2be85d6b
...
@@ -34,7 +34,7 @@ module Gitlab
...
@@ -34,7 +34,7 @@ module Gitlab
@second_collection_pages
||=
Hash
.
new
do
|
hash
,
page
|
@second_collection_pages
||=
Hash
.
new
do
|
hash
,
page
|
second_collection_page
=
page
-
first_collection_page_count
second_collection_page
=
page
-
first_collection_page_count
offset
=
if
second_collection_page
<
1
||
first_collection_page_count
.
zero?
offset
=
if
second_collection_page
<
1
||
first_collection_page_count
==
0
0
0
else
else
per_page
-
first_collection_last_page_size
per_page
-
first_collection_last_page_size
...
...
lib/gitlab/polling_interval.rb
View file @
2be85d6b
...
@@ -20,7 +20,7 @@ module Gitlab
...
@@ -20,7 +20,7 @@ module Gitlab
end
end
def
self
.
polling_enabled?
def
self
.
polling_enabled?
!
Gitlab
::
CurrentSettings
.
polling_interval_multiplier
.
zero?
Gitlab
::
CurrentSettings
.
polling_interval_multiplier
!=
0
end
end
end
end
end
end
lib/gitlab/project_search_results.rb
View file @
2be85d6b
...
@@ -81,7 +81,7 @@ module Gitlab
...
@@ -81,7 +81,7 @@ module Gitlab
counts
=
%i(limited_milestones_count limited_notes_count
counts
=
%i(limited_milestones_count limited_notes_count
limited_merge_requests_count limited_issues_count
limited_merge_requests_count limited_issues_count
limited_blobs_count wiki_blobs_count)
limited_blobs_count wiki_blobs_count)
counts
.
all?
{
|
count_method
|
public_send
(
count_method
)
.
zero?
}
# rubocop:disable GitlabSecurity/PublicSend
counts
.
all?
{
|
count_method
|
public_send
(
count_method
)
==
0
}
# rubocop:disable GitlabSecurity/PublicSend
end
end
private
private
...
...
lib/gitlab/seeder.rb
View file @
2be85d6b
...
@@ -66,7 +66,7 @@ module Gitlab
...
@@ -66,7 +66,7 @@ module Gitlab
estimated_minutes
=
(
size
.
to_f
/
ESTIMATED_INSERT_PER_MINUTE
).
round
estimated_minutes
=
(
size
.
to_f
/
ESTIMATED_INSERT_PER_MINUTE
).
round
humanized_minutes
=
'minute'
.
pluralize
(
estimated_minutes
)
humanized_minutes
=
'minute'
.
pluralize
(
estimated_minutes
)
if
estimated_minutes
.
zero?
if
estimated_minutes
==
0
"Rough estimated time: less than a minute ⏰"
"Rough estimated time: less than a minute ⏰"
else
else
"Rough estimated time:
#{
estimated_minutes
}
#{
humanized_minutes
}
⏰"
"Rough estimated time:
#{
estimated_minutes
}
#{
humanized_minutes
}
⏰"
...
...
lib/gitlab/sidekiq_cluster.rb
View file @
2be85d6b
...
@@ -126,7 +126,7 @@ module Gitlab
...
@@ -126,7 +126,7 @@ module Gitlab
def
self
.
concurrency
(
queues
,
min_concurrency
,
max_concurrency
)
def
self
.
concurrency
(
queues
,
min_concurrency
,
max_concurrency
)
concurrency_from_queues
=
queues
.
length
+
1
concurrency_from_queues
=
queues
.
length
+
1
max
=
max_concurrency
.
positive?
?
max_concurrency
:
concurrency_from_queues
max
=
max_concurrency
>
0
?
max_concurrency
:
concurrency_from_queues
min
=
[
min_concurrency
,
max
].
min
min
=
[
min_concurrency
,
max
].
min
concurrency_from_queues
.
clamp
(
min
,
max
)
concurrency_from_queues
.
clamp
(
min
,
max
)
...
...
lib/gitlab/sidekiq_daemon/memory_killer.rb
View file @
2be85d6b
...
@@ -239,7 +239,7 @@ module Gitlab
...
@@ -239,7 +239,7 @@ module Gitlab
memory_growth_kb
=
get_job_options
(
job
,
'memory_killer_memory_growth_kb'
,
0
).
to_i
memory_growth_kb
=
get_job_options
(
job
,
'memory_killer_memory_growth_kb'
,
0
).
to_i
max_memory_growth_kb
=
get_job_options
(
job
,
'memory_killer_max_memory_growth_kb'
,
DEFAULT_MAX_MEMORY_GROWTH_KB
).
to_i
max_memory_growth_kb
=
get_job_options
(
job
,
'memory_killer_max_memory_growth_kb'
,
DEFAULT_MAX_MEMORY_GROWTH_KB
).
to_i
return
0
if
memory_growth_kb
.
zero?
return
0
if
memory_growth_kb
==
0
time_elapsed
=
[
Gitlab
::
Metrics
::
System
.
monotonic_time
-
job
[
:started_at
],
0
].
max
time_elapsed
=
[
Gitlab
::
Metrics
::
System
.
monotonic_time
-
job
[
:started_at
],
0
].
max
[
memory_growth_kb
*
time_elapsed
,
max_memory_growth_kb
].
min
[
memory_growth_kb
*
time_elapsed
,
max_memory_growth_kb
].
min
...
...
lib/gitlab/sidekiq_middleware/memory_killer.rb
View file @
2be85d6b
...
@@ -55,7 +55,7 @@ module Gitlab
...
@@ -55,7 +55,7 @@ module Gitlab
def
get_rss
def
get_rss
output
,
status
=
Gitlab
::
Popen
.
popen
(
%W(ps -o rss= -p
#{
pid
}
)
,
Rails
.
root
.
to_s
)
output
,
status
=
Gitlab
::
Popen
.
popen
(
%W(ps -o rss= -p
#{
pid
}
)
,
Rails
.
root
.
to_s
)
return
0
unless
status
.
zero?
return
0
unless
status
==
0
output
.
to_i
output
.
to_i
end
end
...
...
lib/gitlab/sidekiq_status.rb
View file @
2be85d6b
...
@@ -50,7 +50,7 @@ module Gitlab
...
@@ -50,7 +50,7 @@ module Gitlab
#
#
# Returns true or false.
# Returns true or false.
def
self
.
all_completed?
(
job_ids
)
def
self
.
all_completed?
(
job_ids
)
self
.
num_running
(
job_ids
)
.
zero?
self
.
num_running
(
job_ids
)
==
0
end
end
# Returns true if the given job is running or enqueued.
# Returns true if the given job is running or enqueued.
...
...
lib/gitlab/slash_commands/presenters/issue_show.rb
View file @
2be85d6b
...
@@ -23,14 +23,14 @@ module Gitlab
...
@@ -23,14 +23,14 @@ module Gitlab
def
text
def
text
message
=
[
"**
#{
status_text
(
resource
)
}
**"
]
message
=
[
"**
#{
status_text
(
resource
)
}
**"
]
if
resource
.
upvotes
.
zero?
&&
resource
.
downvotes
.
zero?
&&
resource
.
user_notes_count
.
zero?
if
resource
.
upvotes
==
0
&&
resource
.
downvotes
==
0
&&
resource
.
user_notes_count
==
0
return
message
.
join
return
message
.
join
end
end
message
<<
" · "
message
<<
" · "
message
<<
":+1:
#{
resource
.
upvotes
}
"
unless
resource
.
upvotes
.
zero?
message
<<
":+1:
#{
resource
.
upvotes
}
"
unless
resource
.
upvotes
==
0
message
<<
":-1:
#{
resource
.
downvotes
}
"
unless
resource
.
downvotes
.
zero?
message
<<
":-1:
#{
resource
.
downvotes
}
"
unless
resource
.
downvotes
==
0
message
<<
":speech_balloon:
#{
resource
.
user_notes_count
}
"
unless
resource
.
user_notes_count
.
zero?
message
<<
":speech_balloon:
#{
resource
.
user_notes_count
}
"
unless
resource
.
user_notes_count
==
0
message
.
join
message
.
join
end
end
...
...
lib/gitlab/task_helpers.rb
View file @
2be85d6b
...
@@ -95,7 +95,7 @@ module Gitlab
...
@@ -95,7 +95,7 @@ module Gitlab
def
run_command!
(
command
)
def
run_command!
(
command
)
output
,
status
=
Gitlab
::
Popen
.
popen
(
command
)
output
,
status
=
Gitlab
::
Popen
.
popen
(
command
)
raise
Gitlab
::
TaskFailedError
.
new
(
output
)
unless
status
.
zero?
raise
Gitlab
::
TaskFailedError
.
new
(
output
)
unless
status
==
0
output
output
end
end
...
...
lib/gitlab/untrusted_regexp.rb
View file @
2be85d6b
...
@@ -31,7 +31,7 @@ module Gitlab
...
@@ -31,7 +31,7 @@ module Gitlab
def
scan
(
text
)
def
scan
(
text
)
matches
=
scan_regexp
.
scan
(
text
).
to_a
matches
=
scan_regexp
.
scan
(
text
).
to_a
matches
.
map!
(
&
:first
)
if
regexp
.
number_of_capturing_groups
.
zero?
matches
.
map!
(
&
:first
)
if
regexp
.
number_of_capturing_groups
==
0
matches
matches
end
end
...
@@ -68,7 +68,7 @@ module Gitlab
...
@@ -68,7 +68,7 @@ module Gitlab
# groups, so work around it
# groups, so work around it
def
scan_regexp
def
scan_regexp
@scan_regexp
||=
@scan_regexp
||=
if
regexp
.
number_of_capturing_groups
.
zero?
if
regexp
.
number_of_capturing_groups
==
0
RE2
::
Regexp
.
new
(
'('
+
regexp
.
source
+
')'
)
RE2
::
Regexp
.
new
(
'('
+
regexp
.
source
+
')'
)
else
else
regexp
regexp
...
...
lib/gitlab/usage_data/topology.rb
View file @
2be85d6b
...
@@ -213,7 +213,7 @@ module Gitlab
...
@@ -213,7 +213,7 @@ module Gitlab
def
normalize_localhost_address
(
instance
)
def
normalize_localhost_address
(
instance
)
ip_addr
=
IPAddr
.
new
(
instance
)
ip_addr
=
IPAddr
.
new
(
instance
)
is_local_ip
=
ip_addr
.
loopback?
||
ip_addr
.
to_i
.
zero?
is_local_ip
=
ip_addr
.
loopback?
||
ip_addr
.
to_i
==
0
is_local_ip
?
'localhost'
:
instance
is_local_ip
?
'localhost'
:
instance
rescue
IPAddr
::
InvalidAddressError
rescue
IPAddr
::
InvalidAddressError
...
...
lib/gitlab/utils.rb
View file @
2be85d6b
...
@@ -50,7 +50,7 @@ module Gitlab
...
@@ -50,7 +50,7 @@ module Gitlab
def
ensure_utf8_size
(
str
,
bytes
:)
def
ensure_utf8_size
(
str
,
bytes
:)
raise
ArgumentError
,
'Empty string provided!'
if
str
.
empty?
raise
ArgumentError
,
'Empty string provided!'
if
str
.
empty?
raise
ArgumentError
,
'Negative string size provided!'
if
bytes
.
negative?
raise
ArgumentError
,
'Negative string size provided!'
if
bytes
<
0
truncated
=
str
.
each_char
.
each_with_object
(
+
''
)
do
|
char
,
object
|
truncated
=
str
.
each_char
.
each_with_object
(
+
''
)
do
|
char
,
object
|
if
object
.
bytesize
+
char
.
bytesize
>
bytes
if
object
.
bytesize
+
char
.
bytesize
>
bytes
...
...
lib/system_check/sidekiq_check.rb
View file @
2be85d6b
...
@@ -32,7 +32,7 @@ module SystemCheck
...
@@ -32,7 +32,7 @@ module SystemCheck
def
only_one_sidekiq_running
def
only_one_sidekiq_running
process_count
=
sidekiq_process_count
process_count
=
sidekiq_process_count
return
if
process_count
.
zero?
return
if
process_count
==
0
$stdout
.
print
'Number of Sidekiq processes ... '
$stdout
.
print
'Number of Sidekiq processes ... '
...
...
lib/tasks/gitlab/gitaly.rake
View file @
2be85d6b
...
@@ -17,7 +17,7 @@ Usage: rake "gitlab:gitaly:install[/installation/dir,/storage/path]")
...
@@ -17,7 +17,7 @@ Usage: rake "gitlab:gitaly:install[/installation/dir,/storage/path]")
command
=
[]
command
=
[]
_
,
status
=
Gitlab
::
Popen
.
popen
(
%w[which gmake]
)
_
,
status
=
Gitlab
::
Popen
.
popen
(
%w[which gmake]
)
command
<<
(
status
.
zero?
?
'gmake'
:
'make'
)
command
<<
(
status
==
0
?
'gmake'
:
'make'
)
if
Rails
.
env
.
test?
if
Rails
.
env
.
test?
command
.
push
(
command
.
push
(
...
...
lib/tasks/gitlab/snippets.rake
View file @
2be85d6b
...
@@ -13,7 +13,7 @@ namespace :gitlab do
...
@@ -13,7 +13,7 @@ namespace :gitlab do
raise
"Please supply the list of ids through the SNIPPET_IDS env var"
raise
"Please supply the list of ids through the SNIPPET_IDS env var"
end
end
raise
"Invalid limit value"
if
limit
.
zero?
raise
"Invalid limit value"
if
limit
==
0
if
migration_running?
if
migration_running?
raise
"There are already snippet migrations running. Please wait until they are finished."
raise
"There are already snippet migrations running. Please wait until they are finished."
...
@@ -37,7 +37,7 @@ namespace :gitlab do
...
@@ -37,7 +37,7 @@ namespace :gitlab do
def
parse_snippet_ids!
def
parse_snippet_ids!
ids
=
ENV
[
'SNIPPET_IDS'
].
delete
(
' '
).
split
(
','
).
map
do
|
id
|
ids
=
ENV
[
'SNIPPET_IDS'
].
delete
(
' '
).
split
(
','
).
map
do
|
id
|
id
.
to_i
.
tap
do
|
value
|
id
.
to_i
.
tap
do
|
value
|
raise
"Invalid id provided"
if
value
.
zero?
raise
"Invalid id provided"
if
value
==
0
end
end
end
end
...
@@ -68,10 +68,10 @@ namespace :gitlab do
...
@@ -68,10 +68,10 @@ namespace :gitlab do
# bundle exec rake gitlab:snippets:list_non_migrated LIMIT=50
# bundle exec rake gitlab:snippets:list_non_migrated LIMIT=50
desc
'GitLab | Show non migrated snippets'
desc
'GitLab | Show non migrated snippets'
task
list_non_migrated: :environment
do
task
list_non_migrated: :environment
do
raise
"Invalid limit value"
if
limit
.
zero?
raise
"Invalid limit value"
if
limit
==
0
non_migrated_count
=
non_migrated_snippets
.
count
non_migrated_count
=
non_migrated_snippets
.
count
if
non_migrated_count
.
zero?
if
non_migrated_count
==
0
puts
"All snippets have been successfully migrated"
puts
"All snippets have been successfully migrated"
else
else
puts
"There are
#{
non_migrated_count
}
snippets that haven't been migrated. Showing a batch of ids of those snippets:
\n
"
puts
"There are
#{
non_migrated_count
}
snippets that haven't been migrated. Showing a batch of ids of those snippets:
\n
"
...
...
lib/tasks/gitlab/workhorse.rake
View file @
2be85d6b
...
@@ -15,7 +15,7 @@ namespace :gitlab do
...
@@ -15,7 +15,7 @@ namespace :gitlab do
checkout_or_clone_version
(
version:
version
,
repo:
args
.
repo
,
target_dir:
args
.
dir
,
clone_opts:
%w[--depth 1]
)
checkout_or_clone_version
(
version:
version
,
repo:
args
.
repo
,
target_dir:
args
.
dir
,
clone_opts:
%w[--depth 1]
)
_
,
status
=
Gitlab
::
Popen
.
popen
(
%w[which gmake]
)
_
,
status
=
Gitlab
::
Popen
.
popen
(
%w[which gmake]
)
command
=
status
.
zero?
?
'gmake'
:
'make'
command
=
status
==
0
?
'gmake'
:
'make'
Dir
.
chdir
(
args
.
dir
)
do
Dir
.
chdir
(
args
.
dir
)
do
run_command!
([
command
])
run_command!
([
command
])
...
...
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