BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
35fe9c66
Commit
35fe9c66
authored
Apr 03, 2017
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move methods that are not related to mirroring to the repository model
parent
6e64071e
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
25 deletions
+25
-25
repository_mirroring.rb
app/models/concerns/repository_mirroring.rb
+5
-19
repository.rb
app/models/repository.rb
+20
-6
No files found.
app/models/concerns/repository_mirroring.rb
View file @
35fe9c66
module
RepositoryMirroring
def
storage_path
@project
.
repository_storage_path
end
def
add_remote
(
name
,
url
)
raw_repository
.
remote_add
(
name
,
url
)
rescue
Rugged
::
ConfigError
raw_repository
.
remote_update
(
name
,
url:
url
)
end
def
remove_remote
(
name
)
raw_repository
.
remote_delete
(
name
)
true
rescue
Rugged
::
ConfigError
false
end
def
set_remote_as_mirror
(
name
)
config
=
raw_repository
.
rugged
.
config
...
...
@@ -25,7 +8,10 @@ module RepositoryMirroring
config
[
"remote.
#{
name
}
.prune"
]
=
true
end
def
fetch_remote
(
remote
,
forced:
false
,
no_tags:
false
)
gitlab_shell
.
fetch_remote
(
storage_path
,
path_with_namespace
,
remote
,
forced:
forced
,
no_tags:
no_tags
)
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 @
35fe9c66
...
...
@@ -65,7 +65,7 @@ class Repository
# Return absolute path to repository
def
path_to_repo
@path_to_repo
||=
File
.
expand_path
(
File
.
join
(
@project
.
repository_storage_path
,
path_with_namespace
+
".git"
)
File
.
join
(
repository_storage_path
,
path_with_namespace
+
".git"
)
)
end
...
...
@@ -1034,11 +1034,21 @@ class Repository
rugged
.
references
.
delete
(
tmp_ref
)
if
tmp_ref
end
def
fetch_mirror
(
remote
,
url
)
add_remote
(
remote
,
url
)
set_remote_as_mirror
(
remote
)
fetch_remote
(
remote
,
forced:
true
)
remove_remote
(
remote
)
def
add_remote
(
name
,
url
)
raw_repository
.
remote_add
(
name
,
url
)
rescue
Rugged
::
ConfigError
raw_repository
.
remote_update
(
name
,
url:
url
)
end
def
remove_remote
(
name
)
raw_repository
.
remote_delete
(
name
)
true
rescue
Rugged
::
ConfigError
false
end
def
fetch_remote
(
remote
,
forced:
false
,
no_tags:
false
)
gitlab_shell
.
fetch_remote
(
repository_storage_path
,
path_with_namespace
,
remote
,
forced:
forced
,
no_tags:
no_tags
)
end
def
fetch_ref
(
source_path
,
source_ref
,
target_ref
)
...
...
@@ -1158,4 +1168,8 @@ class Repository
def
repository_event
(
event
,
tags
=
{})
Gitlab
::
Metrics
.
add_event
(
event
,
{
path:
path_with_namespace
}.
merge
(
tags
))
end
def
repository_storage_path
@project
.
repository_storage_path
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