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
35d3411f
Commit
35d3411f
authored
Jan 07, 2018
by
Stan Hu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix hooks not being set up properly for bare import Rake task
Closes #41739
parent
3576d59a
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
38 additions
and
2 deletions
+38
-2
app/models/repository.rb
app/models/repository.rb
+4
-0
changelogs/unreleased/sh-fix-bare-import-hooks.yml
changelogs/unreleased/sh-fix-bare-import-hooks.yml
+5
-0
lib/gitlab/bare_repository_import/importer.rb
lib/gitlab/bare_repository_import/importer.rb
+1
-0
spec/lib/gitlab/bare_repository_import/importer_spec.rb
spec/lib/gitlab/bare_repository_import/importer_spec.rb
+6
-2
spec/models/repository_spec.rb
spec/models/repository_spec.rb
+22
-0
No files found.
app/models/repository.rb
View file @
35d3411f
...
...
@@ -103,6 +103,10 @@ class Repository
"#<
#{
self
.
class
.
name
}
:
#{
@disk_path
}
>"
end
def
create_hooks
Gitlab
::
Git
::
Repository
.
create_hooks
(
path_to_repo
,
Gitlab
.
config
.
gitlab_shell
.
hooks_path
)
end
def
commit
(
ref
=
'HEAD'
)
return
nil
unless
exists?
return
ref
if
ref
.
is_a?
(
::
Commit
)
...
...
changelogs/unreleased/sh-fix-bare-import-hooks.yml
0 → 100644
View file @
35d3411f
---
title
:
Fix hooks not being set up properly for bare import Rake task
merge_request
:
author
:
type
:
fixed
lib/gitlab/bare_repository_import/importer.rb
View file @
35d3411f
...
...
@@ -63,6 +63,7 @@ module Gitlab
log
" * Created
#{
project
.
name
}
(
#{
project_full_path
}
)"
.
color
(
:green
)
project
.
write_repository_config
project
.
repository
.
create_hooks
ProjectCacheWorker
.
perform_async
(
project
.
id
)
else
...
...
spec/lib/gitlab/bare_repository_import/importer_spec.rb
View file @
35d3411f
...
...
@@ -74,14 +74,18 @@ describe Gitlab::BareRepositoryImport::Importer, repository: true do
importer
.
create_project_if_needed
end
it
'creates the Git repo
in disk
'
do
it
'creates the Git repo
on disk with the proper symlink for hooks
'
do
create_bare_repository
(
"
#{
project_path
}
.git"
)
importer
.
create_project_if_needed
project
=
Project
.
find_by_full_path
(
project_path
)
repo_path
=
File
.
join
(
project
.
repository_storage_path
,
project
.
disk_path
+
'.git'
)
hook_path
=
File
.
join
(
repo_path
,
'hooks'
)
expect
(
File
).
to
exist
(
File
.
join
(
project
.
repository_storage_path
,
project
.
disk_path
+
'.git'
))
expect
(
File
).
to
exist
(
repo_path
)
expect
(
File
.
symlink?
(
hook_path
)).
to
be
true
expect
(
File
.
readlink
(
hook_path
)).
to
eq
(
Gitlab
.
config
.
gitlab_shell
.
hooks_path
)
end
context
'hashed storage enabled'
do
...
...
spec/models/repository_spec.rb
View file @
35d3411f
...
...
@@ -412,6 +412,28 @@ describe Repository do
end
end
describe
'#create_hooks'
do
let
(
:hook_path
)
{
File
.
join
(
repository
.
path_to_repo
,
'hooks'
)
}
it
'symlinks the global hooks directory'
do
repository
.
create_hooks
expect
(
File
.
symlink?
(
hook_path
)).
to
be
true
expect
(
File
.
readlink
(
hook_path
)).
to
eq
(
Gitlab
.
config
.
gitlab_shell
.
hooks_path
)
end
it
'replaces existing symlink with the right directory'
do
FileUtils
.
mkdir_p
(
hook_path
)
expect
(
File
.
symlink?
(
hook_path
)).
to
be
false
repository
.
create_hooks
expect
(
File
.
symlink?
(
hook_path
)).
to
be
true
expect
(
File
.
readlink
(
hook_path
)).
to
eq
(
Gitlab
.
config
.
gitlab_shell
.
hooks_path
)
end
end
describe
"#create_dir"
do
it
"commits a change that creates a new directory"
do
expect
do
...
...
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