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
0
Merge Requests
0
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
Jérome Perrin
gitlab-ce
Commits
91ff0eaa
Commit
91ff0eaa
authored
Mar 12, 2018
by
Nick Thomas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Respect the configured git path for imported gitlab-shell operations
parent
cc72e1bc
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
13 deletions
+13
-13
lib/gitlab/git/gitlab_projects.rb
lib/gitlab/git/gitlab_projects.rb
+6
-6
spec/lib/gitlab/git/gitlab_projects_spec.rb
spec/lib/gitlab/git/gitlab_projects_spec.rb
+7
-7
No files found.
lib/gitlab/git/gitlab_projects.rb
View file @
91ff0eaa
...
@@ -67,7 +67,7 @@ module Gitlab
...
@@ -67,7 +67,7 @@ module Gitlab
tags_option
=
tags
?
'--tags'
:
'--no-tags'
tags_option
=
tags
?
'--tags'
:
'--no-tags'
logger
.
info
"Fetching remote
#{
name
}
for repository
#{
repository_absolute_path
}
."
logger
.
info
"Fetching remote
#{
name
}
for repository
#{
repository_absolute_path
}
."
cmd
=
%W(
git
fetch
#{
name
}
--quiet)
cmd
=
%W(
#{
Gitlab
.
config
.
git
.
bin_path
}
fetch
#{
name
}
--quiet)
cmd
<<
'--prune'
if
prune
cmd
<<
'--prune'
if
prune
cmd
<<
'--force'
if
force
cmd
<<
'--force'
if
force
cmd
<<
tags_option
cmd
<<
tags_option
...
@@ -85,7 +85,7 @@ module Gitlab
...
@@ -85,7 +85,7 @@ module Gitlab
def
push_branches
(
remote_name
,
timeout
,
force
,
branch_names
)
def
push_branches
(
remote_name
,
timeout
,
force
,
branch_names
)
logger
.
info
"Pushing branches from
#{
repository_absolute_path
}
to remote
#{
remote_name
}
:
#{
branch_names
}
"
logger
.
info
"Pushing branches from
#{
repository_absolute_path
}
to remote
#{
remote_name
}
:
#{
branch_names
}
"
cmd
=
%
w(git
push)
cmd
=
%
W(
#{
Gitlab
.
config
.
git
.
bin_path
}
push)
cmd
<<
'--force'
if
force
cmd
<<
'--force'
if
force
cmd
+=
%W(--
#{
remote_name
}
)
.
concat
(
branch_names
)
cmd
+=
%W(--
#{
remote_name
}
)
.
concat
(
branch_names
)
...
@@ -102,7 +102,7 @@ module Gitlab
...
@@ -102,7 +102,7 @@ module Gitlab
branches
=
branch_names
.
map
{
|
branch_name
|
":
#{
branch_name
}
"
}
branches
=
branch_names
.
map
{
|
branch_name
|
":
#{
branch_name
}
"
}
logger
.
info
"Pushing deleted branches from
#{
repository_absolute_path
}
to remote
#{
remote_name
}
:
#{
branch_names
}
"
logger
.
info
"Pushing deleted branches from
#{
repository_absolute_path
}
to remote
#{
remote_name
}
:
#{
branch_names
}
"
cmd
=
%W(
git
push --
#{
remote_name
}
)
.
concat
(
branches
)
cmd
=
%W(
#{
Gitlab
.
config
.
git
.
bin_path
}
push --
#{
remote_name
}
)
.
concat
(
branches
)
success
=
run
(
cmd
,
repository_absolute_path
)
success
=
run
(
cmd
,
repository_absolute_path
)
...
@@ -143,7 +143,7 @@ module Gitlab
...
@@ -143,7 +143,7 @@ module Gitlab
end
end
def
remove_origin_in_repo
def
remove_origin_in_repo
cmd
=
%
w(git
remote rm origin)
cmd
=
%
W(
#{
Gitlab
.
config
.
git
.
bin_path
}
remote rm origin)
run
(
cmd
,
repository_absolute_path
)
run
(
cmd
,
repository_absolute_path
)
end
end
...
@@ -223,7 +223,7 @@ module Gitlab
...
@@ -223,7 +223,7 @@ module Gitlab
masked_source
=
mask_password_in_url
(
source
)
masked_source
=
mask_password_in_url
(
source
)
logger
.
info
"Importing project from <
#{
masked_source
}
> to <
#{
repository_absolute_path
}
>."
logger
.
info
"Importing project from <
#{
masked_source
}
> to <
#{
repository_absolute_path
}
>."
cmd
=
%W(
git
clone --bare --
#{
source
}
#{
repository_absolute_path
}
)
cmd
=
%W(
#{
Gitlab
.
config
.
git
.
bin_path
}
clone --bare --
#{
source
}
#{
repository_absolute_path
}
)
success
=
run_with_timeout
(
cmd
,
timeout
,
nil
)
success
=
run_with_timeout
(
cmd
,
timeout
,
nil
)
...
@@ -266,7 +266,7 @@ module Gitlab
...
@@ -266,7 +266,7 @@ module Gitlab
FileUtils
.
mkdir_p
(
File
.
dirname
(
to_path
),
mode:
0770
)
FileUtils
.
mkdir_p
(
File
.
dirname
(
to_path
),
mode:
0770
)
logger
.
info
"Forking repository from <
#{
from_path
}
> to <
#{
to_path
}
>."
logger
.
info
"Forking repository from <
#{
from_path
}
> to <
#{
to_path
}
>."
cmd
=
%W(
git
clone --bare --no-local --
#{
from_path
}
#{
to_path
}
)
cmd
=
%W(
#{
Gitlab
.
config
.
git
.
bin_path
}
clone --bare --no-local --
#{
from_path
}
#{
to_path
}
)
run
(
cmd
,
nil
)
&&
Gitlab
::
Git
::
Repository
.
create_hooks
(
to_path
,
global_hooks_path
)
run
(
cmd
,
nil
)
&&
Gitlab
::
Git
::
Repository
.
create_hooks
(
to_path
,
global_hooks_path
)
end
end
...
...
spec/lib/gitlab/git/gitlab_projects_spec.rb
View file @
91ff0eaa
...
@@ -28,7 +28,7 @@ describe Gitlab::Git::GitlabProjects do
...
@@ -28,7 +28,7 @@ describe Gitlab::Git::GitlabProjects do
describe
'#push_branches'
do
describe
'#push_branches'
do
let
(
:remote_name
)
{
'remote-name'
}
let
(
:remote_name
)
{
'remote-name'
}
let
(
:branch_name
)
{
'master'
}
let
(
:branch_name
)
{
'master'
}
let
(
:cmd
)
{
%W(
git
push --
#{
remote_name
}
#{
branch_name
}
)
}
let
(
:cmd
)
{
%W(
#{
Gitlab
.
config
.
git
.
bin_path
}
push --
#{
remote_name
}
#{
branch_name
}
)
}
let
(
:force
)
{
false
}
let
(
:force
)
{
false
}
subject
{
gl_projects
.
push_branches
(
remote_name
,
600
,
force
,
[
branch_name
])
}
subject
{
gl_projects
.
push_branches
(
remote_name
,
600
,
force
,
[
branch_name
])
}
...
@@ -46,7 +46,7 @@ describe Gitlab::Git::GitlabProjects do
...
@@ -46,7 +46,7 @@ describe Gitlab::Git::GitlabProjects do
end
end
context
'with --force'
do
context
'with --force'
do
let
(
:cmd
)
{
%W(
git
push --force --
#{
remote_name
}
#{
branch_name
}
)
}
let
(
:cmd
)
{
%W(
#{
Gitlab
.
config
.
git
.
bin_path
}
push --force --
#{
remote_name
}
#{
branch_name
}
)
}
let
(
:force
)
{
true
}
let
(
:force
)
{
true
}
it
'executes the command'
do
it
'executes the command'
do
...
@@ -65,7 +65,7 @@ describe Gitlab::Git::GitlabProjects do
...
@@ -65,7 +65,7 @@ describe Gitlab::Git::GitlabProjects do
let
(
:tags
)
{
true
}
let
(
:tags
)
{
true
}
let
(
:args
)
{
{
force:
force
,
tags:
tags
,
prune:
prune
}.
merge
(
extra_args
)
}
let
(
:args
)
{
{
force:
force
,
tags:
tags
,
prune:
prune
}.
merge
(
extra_args
)
}
let
(
:extra_args
)
{
{}
}
let
(
:extra_args
)
{
{}
}
let
(
:cmd
)
{
%W(
git
fetch
#{
remote_name
}
--quiet --prune --tags)
}
let
(
:cmd
)
{
%W(
#{
Gitlab
.
config
.
git
.
bin_path
}
fetch
#{
remote_name
}
--quiet --prune --tags)
}
subject
{
gl_projects
.
fetch_remote
(
remote_name
,
600
,
args
)
}
subject
{
gl_projects
.
fetch_remote
(
remote_name
,
600
,
args
)
}
...
@@ -98,7 +98,7 @@ describe Gitlab::Git::GitlabProjects do
...
@@ -98,7 +98,7 @@ describe Gitlab::Git::GitlabProjects do
context
'with --force'
do
context
'with --force'
do
let
(
:force
)
{
true
}
let
(
:force
)
{
true
}
let
(
:cmd
)
{
%W(
git
fetch
#{
remote_name
}
--quiet --prune --force --tags)
}
let
(
:cmd
)
{
%W(
#{
Gitlab
.
config
.
git
.
bin_path
}
fetch
#{
remote_name
}
--quiet --prune --force --tags)
}
it
'executes the command with forced option'
do
it
'executes the command with forced option'
do
stub_spawn
(
cmd
,
600
,
tmp_repo_path
,
{},
success:
true
)
stub_spawn
(
cmd
,
600
,
tmp_repo_path
,
{},
success:
true
)
...
@@ -109,7 +109,7 @@ describe Gitlab::Git::GitlabProjects do
...
@@ -109,7 +109,7 @@ describe Gitlab::Git::GitlabProjects do
context
'with --no-tags'
do
context
'with --no-tags'
do
let
(
:tags
)
{
false
}
let
(
:tags
)
{
false
}
let
(
:cmd
)
{
%W(
git
fetch
#{
remote_name
}
--quiet --prune --no-tags)
}
let
(
:cmd
)
{
%W(
#{
Gitlab
.
config
.
git
.
bin_path
}
fetch
#{
remote_name
}
--quiet --prune --no-tags)
}
it
'executes the command'
do
it
'executes the command'
do
stub_spawn
(
cmd
,
600
,
tmp_repo_path
,
{},
success:
true
)
stub_spawn
(
cmd
,
600
,
tmp_repo_path
,
{},
success:
true
)
...
@@ -120,7 +120,7 @@ describe Gitlab::Git::GitlabProjects do
...
@@ -120,7 +120,7 @@ describe Gitlab::Git::GitlabProjects do
context
'with no prune'
do
context
'with no prune'
do
let
(
:prune
)
{
false
}
let
(
:prune
)
{
false
}
let
(
:cmd
)
{
%W(
git
fetch
#{
remote_name
}
--quiet --tags)
}
let
(
:cmd
)
{
%W(
#{
Gitlab
.
config
.
git
.
bin_path
}
fetch
#{
remote_name
}
--quiet --tags)
}
it
'executes the command'
do
it
'executes the command'
do
stub_spawn
(
cmd
,
600
,
tmp_repo_path
,
{},
success:
true
)
stub_spawn
(
cmd
,
600
,
tmp_repo_path
,
{},
success:
true
)
...
@@ -165,7 +165,7 @@ describe Gitlab::Git::GitlabProjects do
...
@@ -165,7 +165,7 @@ describe Gitlab::Git::GitlabProjects do
describe
'#import_project'
do
describe
'#import_project'
do
let
(
:project
)
{
create
(
:project
)
}
let
(
:project
)
{
create
(
:project
)
}
let
(
:import_url
)
{
TestEnv
.
factory_repo_path_bare
}
let
(
:import_url
)
{
TestEnv
.
factory_repo_path_bare
}
let
(
:cmd
)
{
%W(
git
clone --bare --
#{
import_url
}
#{
tmp_repo_path
}
)
}
let
(
:cmd
)
{
%W(
#{
Gitlab
.
config
.
git
.
bin_path
}
clone --bare --
#{
import_url
}
#{
tmp_repo_path
}
)
}
let
(
:timeout
)
{
600
}
let
(
:timeout
)
{
600
}
subject
{
gl_projects
.
import_project
(
import_url
,
timeout
)
}
subject
{
gl_projects
.
import_project
(
import_url
,
timeout
)
}
...
...
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