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
fe4874c4
Commit
fe4874c4
authored
Oct 14, 2017
by
Alejandro Rodríguez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use Gitlab::Git operations for repository mirroring
parent
dea6d054
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
0 additions
and
33 deletions
+0
-33
app/models/concerns/repository_mirroring.rb
app/models/concerns/repository_mirroring.rb
+0
-32
app/models/repository.rb
app/models/repository.rb
+0
-1
No files found.
app/models/concerns/repository_mirroring.rb
deleted
100644 → 0
View file @
dea6d054
module
RepositoryMirroring
IMPORT_HEAD_REFS
=
'+refs/heads/*:refs/heads/*'
.
freeze
IMPORT_TAG_REFS
=
'+refs/tags/*:refs/tags/*'
.
freeze
def
set_remote_as_mirror
(
name
)
# This is used to define repository as equivalent as "git clone --mirror"
raw_repository
.
rugged
.
config
[
"remote.
#{
name
}
.fetch"
]
=
'refs/*:refs/*'
raw_repository
.
rugged
.
config
[
"remote.
#{
name
}
.mirror"
]
=
true
raw_repository
.
rugged
.
config
[
"remote.
#{
name
}
.prune"
]
=
true
end
def
set_import_remote_as_mirror
(
remote_name
)
# Add first fetch with Rugged so it does not create its own.
raw_repository
.
rugged
.
config
[
"remote.
#{
remote_name
}
.fetch"
]
=
IMPORT_HEAD_REFS
add_remote_fetch_config
(
remote_name
,
IMPORT_TAG_REFS
)
raw_repository
.
rugged
.
config
[
"remote.
#{
remote_name
}
.mirror"
]
=
true
raw_repository
.
rugged
.
config
[
"remote.
#{
remote_name
}
.prune"
]
=
true
end
def
add_remote_fetch_config
(
remote_name
,
refspec
)
run_git
(
%W[config --add remote.
#{
remote_name
}
.fetch
#{
refspec
}
]
)
end
def
fetch_mirror
(
remote
,
url
)
add_remote
(
remote
,
url
)
set_remote_as_mirror
(
remote
)
fetch_remote
(
remote
,
forced:
true
)
remove_remote
(
remote
)
end
end
app/models/repository.rb
View file @
fe4874c4
...
...
@@ -15,7 +15,6 @@ class Repository
]
.
freeze
include
Gitlab
::
ShellAdapter
include
RepositoryMirroring
attr_accessor
:full_path
,
:disk_path
,
:project
,
:is_wiki
...
...
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