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
3c715011
Commit
3c715011
authored
Dec 06, 2017
by
Alejandro Rodríguez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Unify mirror addition operations to prepare for Gitaly migration
parent
6db99dc1
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
19 deletions
+20
-19
app/models/repository.rb
app/models/repository.rb
+1
-2
lib/gitlab/git/repository.rb
lib/gitlab/git/repository.rb
+5
-3
lib/gitlab/git/repository_mirroring.rb
lib/gitlab/git/repository_mirroring.rb
+14
-14
No files found.
app/models/repository.rb
View file @
3c715011
...
...
@@ -1020,8 +1020,7 @@ class Repository
tmp_remote_name
=
true
end
add_remote
(
remote_name
,
url
)
set_remote_as_mirror
(
remote_name
,
refmap:
refmap
)
add_remote
(
remote_name
,
url
,
mirror_refmap:
refmap
)
fetch_remote
(
remote_name
,
forced:
forced
)
ensure
remove_remote
(
remote_name
)
if
tmp_remote_name
...
...
lib/gitlab/git/repository.rb
View file @
3c715011
...
...
@@ -892,8 +892,11 @@ module Gitlab
end
end
def
add_remote
(
remote_name
,
url
)
# If `mirror_refmap` is present the remote is set as mirror with that mapping
def
add_remote
(
remote_name
,
url
,
mirror_refmap:
nil
)
rugged
.
remotes
.
create
(
remote_name
,
url
)
set_remote_as_mirror
(
remote_name
,
refmap:
mirror_refmap
)
if
mirror_refmap
rescue
Rugged
::
ConfigError
remote_update
(
remote_name
,
url:
url
)
end
...
...
@@ -1147,8 +1150,7 @@ module Gitlab
end
end
add_remote
(
remote_name
,
url
)
set_remote_as_mirror
(
remote_name
)
add_remote
(
remote_name
,
url
,
mirror_refmap: :all_refs
)
fetch_remote
(
remote_name
,
env:
env
)
ensure
remove_remote
(
remote_name
)
...
...
lib/gitlab/git/repository_mirroring.rb
View file @
3c715011
...
...
@@ -17,20 +17,6 @@ module Gitlab
rugged
.
config
[
"remote.
#{
remote_name
}
.prune"
]
=
true
end
def
set_remote_refmap
(
remote_name
,
refmap
)
Array
(
refmap
).
each_with_index
do
|
refspec
,
i
|
refspec
=
REFMAPS
[
refspec
]
||
refspec
# We need multiple `fetch` entries, but Rugged only allows replacing a config, not adding to it.
# To make sure we start from scratch, we set the first using rugged, and use `git` for any others
if
i
==
0
rugged
.
config
[
"remote.
#{
remote_name
}
.fetch"
]
=
refspec
else
run_git
(
%W[config --add remote.
#{
remote_name
}
.fetch
#{
refspec
}
]
)
end
end
end
def
remote_tags
(
remote
)
# Each line has this format: "dc872e9fa6963f8f03da6c8f6f264d0845d6b092\trefs/tags/v1.10.0\n"
# We want to convert it to: [{ 'v1.10.0' => 'dc872e9fa6963f8f03da6c8f6f264d0845d6b092' }, ...]
...
...
@@ -72,6 +58,20 @@ module Gitlab
private
def
set_remote_refmap
(
remote_name
,
refmap
)
Array
(
refmap
).
each_with_index
do
|
refspec
,
i
|
refspec
=
REFMAPS
[
refspec
]
||
refspec
# We need multiple `fetch` entries, but Rugged only allows replacing a config, not adding to it.
# To make sure we start from scratch, we set the first using rugged, and use `git` for any others
if
i
==
0
rugged
.
config
[
"remote.
#{
remote_name
}
.fetch"
]
=
refspec
else
run_git
(
%W[config --add remote.
#{
remote_name
}
.fetch
#{
refspec
}
]
)
end
end
end
def
list_remote_tags
(
remote
)
tag_list
,
exit_code
,
error
=
nil
cmd
=
%W(
#{
Gitlab
.
config
.
git
.
bin_path
}
--git-dir=
#{
path
}
ls-remote --tags
#{
remote
}
)
...
...
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