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
f8e1b44d
Commit
f8e1b44d
authored
Jan 03, 2018
by
James Lopez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add locks chek
parent
bc46c822
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
2 deletions
+28
-2
lib/tasks/gitlab/git.rake
lib/tasks/gitlab/git.rake
+25
-1
spec/tasks/gitlab/git_rake_spec.rb
spec/tasks/gitlab/git_rake_spec.rb
+3
-1
No files found.
lib/tasks/gitlab/git.rake
View file @
f8e1b44d
...
@@ -32,7 +32,10 @@ namespace :gitlab do
...
@@ -32,7 +32,10 @@ namespace :gitlab do
desc
'GitLab | Git | Check all repos integrity'
desc
'GitLab | Git | Check all repos integrity'
task
fsck: :environment
do
task
fsck: :environment
do
failures
=
perform_git_cmd
(
%W(
#{
Gitlab
.
config
.
git
.
bin_path
}
fsck --name-objects --no-progress)
,
"Checking integrity"
)
failures
=
perform_git_cmd
(
%W(
#{
Gitlab
.
config
.
git
.
bin_path
}
fsck --name-objects --no-progress)
,
"Checking integrity"
)
do
|
repo
|
check_config_lock
(
repo
)
check_ref_locks
(
repo
)
end
if
failures
.
empty?
if
failures
.
empty?
puts
"Done"
.
color
(
:green
)
puts
"Done"
.
color
(
:green
)
else
else
...
@@ -50,6 +53,8 @@ namespace :gitlab do
...
@@ -50,6 +53,8 @@ namespace :gitlab do
else
else
failures
<<
repo
failures
<<
repo
end
end
yield
(
repo
)
if
block_given?
end
end
failures
failures
...
@@ -59,5 +64,24 @@ namespace :gitlab do
...
@@ -59,5 +64,24 @@ namespace :gitlab do
puts
"The following repositories reported errors:"
.
color
(
:red
)
puts
"The following repositories reported errors:"
.
color
(
:red
)
failures
.
each
{
|
f
|
puts
"-
#{
f
}
"
}
failures
.
each
{
|
f
|
puts
"-
#{
f
}
"
}
end
end
def
check_config_lock
(
repo_dir
)
config_exists
=
File
.
exist?
(
File
.
join
(
repo_dir
,
'config.lock'
))
config_output
=
config_exists
?
'yes'
.
color
(
:red
)
:
'no'
.
color
(
:green
)
puts
"'config.lock' file exists?"
.
color
(
:yellow
)
+
" ...
#{
config_output
}
"
end
def
check_ref_locks
(
repo_dir
)
lock_files
=
Dir
.
glob
(
File
.
join
(
repo_dir
,
'refs/heads/*.lock'
))
if
lock_files
.
present?
puts
"Ref lock files exist:"
.
color
(
:red
)
lock_files
.
each
{
|
lock_file
|
puts
"
#{
lock_file
}
"
}
else
puts
"No ref lock files exist"
.
color
(
:green
)
end
end
end
end
end
end
spec/tasks/gitlab/git_rake_spec.rb
View file @
f8e1b44d
require
'rake_helper'
require
'rake_helper'
describe
'gitlab:git rake tasks'
do
describe
'gitlab:git rake tasks'
do
...
@@ -6,7 +8,7 @@ describe 'gitlab:git rake tasks' do
...
@@ -6,7 +8,7 @@ describe 'gitlab:git rake tasks' do
storages
=
{
'default'
=>
{
'path'
=>
Settings
.
absolute
(
'tmp/tests/default_storage'
)
}
}
storages
=
{
'default'
=>
{
'path'
=>
Settings
.
absolute
(
'tmp/tests/default_storage'
)
}
}
FileUtils
.
mkdir_p
(
Settings
.
absolute
(
'tmp/tests/default_storage/
repo
/test.git'
))
FileUtils
.
mkdir_p
(
Settings
.
absolute
(
'tmp/tests/default_storage/
@repo/1/2
/test.git'
))
allow
(
Gitlab
.
config
.
repositories
).
to
receive
(
:storages
).
and_return
(
storages
)
allow
(
Gitlab
.
config
.
repositories
).
to
receive
(
:storages
).
and_return
(
storages
)
stub_warn_user_is_not_gitlab
stub_warn_user_is_not_gitlab
end
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