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
9d88ad45
Commit
9d88ad45
authored
Sep 01, 2017
by
Jacob Vosmaer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add Gitaly migration points for branch/tag create/delete
parent
6523ba1d
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
53 additions
and
18 deletions
+53
-18
app/models/repository.rb
app/models/repository.rb
+10
-18
lib/gitlab/git/repository.rb
lib/gitlab/git/repository.rb
+43
-0
No files found.
app/models/repository.rb
View file @
9d88ad45
...
@@ -166,32 +166,25 @@ class Repository
...
@@ -166,32 +166,25 @@ class Repository
end
end
def
add_branch
(
user
,
branch_name
,
ref
)
def
add_branch
(
user
,
branch_name
,
ref
)
newrev
=
commit
(
ref
).
try
(
:sha
)
branch
=
raw_repository
.
add_branch
(
branch_name
,
committer:
user
,
target:
ref
)
return
false
unless
newrev
Gitlab
::
Git
::
OperationService
.
new
(
user
,
raw_repository
).
add_branch
(
branch_name
,
newrev
)
after_create_branch
after_create_branch
find_branch
(
branch_name
)
branch
rescue
Gitlab
::
Git
::
Repository
::
InvalidRef
false
end
end
def
add_tag
(
user
,
tag_name
,
target
,
message
=
nil
)
def
add_tag
(
user
,
tag_name
,
target
,
message
=
nil
)
newrev
=
commit
(
target
).
try
(
:id
)
raw_repository
.
add_tag
(
tag_name
,
committer:
user
,
target:
target
,
message:
message
)
options
=
{
message:
message
,
tagger:
user_to_committer
(
user
)
}
if
message
rescue
Gitlab
::
Git
::
Repository
::
InvalidRef
false
return
false
unless
newrev
Gitlab
::
Git
::
OperationService
.
new
(
user
,
raw_repository
).
add_tag
(
tag_name
,
newrev
,
options
)
find_tag
(
tag_name
)
end
end
def
rm_branch
(
user
,
branch_name
)
def
rm_branch
(
user
,
branch_name
)
before_remove_branch
before_remove_branch
branch
=
find_branch
(
branch_name
)
Gitlab
::
Git
::
OperationService
.
new
(
user
,
raw_repository
).
rm_branch
(
branch
)
raw_repository
.
rm_branch
(
branch_name
,
committer:
user
)
after_remove_branch
after_remove_branch
true
true
...
@@ -199,9 +192,8 @@ class Repository
...
@@ -199,9 +192,8 @@ class Repository
def
rm_tag
(
user
,
tag_name
)
def
rm_tag
(
user
,
tag_name
)
before_remove_tag
before_remove_tag
tag
=
find_tag
(
tag_name
)
Gitlab
::
Git
::
OperationService
.
new
(
user
,
raw_repository
).
rm_tag
(
tag
)
raw_repository
.
rm_tag
(
tag_name
,
committer:
user
)
after_remove_tag
after_remove_tag
true
true
...
...
lib/gitlab/git/repository.rb
View file @
9d88ad45
...
@@ -605,6 +605,49 @@ module Gitlab
...
@@ -605,6 +605,49 @@ module Gitlab
# TODO: implement this method
# TODO: implement this method
end
end
def
add_branch
(
branch_name
,
committer
:,
target
:)
target_object
=
Ref
.
dereference_object
(
lookup
(
target
))
raise
InvalidRef
.
new
(
"target not found:
#{
target
}
"
)
unless
target_object
OperationService
.
new
(
committer
,
self
).
add_branch
(
branch_name
,
target_object
.
oid
)
find_branch
(
branch_name
)
rescue
Rugged
::
ReferenceError
=>
ex
raise
InvalidRef
,
ex
end
def
add_tag
(
tag_name
,
committer
:,
target
:,
message:
nil
)
target_object
=
Ref
.
dereference_object
(
lookup
(
target
))
raise
InvalidRef
.
new
(
"target not found:
#{
target
}
"
)
unless
target_object
committer
=
Committer
.
from_user
(
committer
)
if
committer
.
is_a?
(
User
)
options
=
nil
# Use nil, not the empty hash. Rugged cares about this.
if
message
options
=
{
message:
message
,
tagger:
Gitlab
::
Git
.
committer_hash
(
email:
committer
.
email
,
name:
committer
.
name
)
}
end
OperationService
.
new
(
committer
,
self
).
add_tag
(
tag_name
,
target_object
.
oid
,
options
)
find_tag
(
tag_name
)
rescue
Rugged
::
ReferenceError
=>
ex
raise
InvalidRef
,
ex
end
def
rm_branch
(
branch_name
,
committer
:)
OperationService
.
new
(
committer
,
self
).
rm_branch
(
find_branch
(
branch_name
))
end
def
rm_tag
(
tag_name
,
committer
:)
OperationService
.
new
(
committer
,
self
).
rm_tag
(
find_tag
(
tag_name
))
end
def
find_tag
(
name
)
tags
.
find
{
|
tag
|
tag
.
name
==
name
}
end
# Delete the specified branch from the repository
# Delete the specified branch from the repository
#
#
# Gitaly migration: https://gitlab.com/gitlab-org/gitaly/issues/476
# Gitaly migration: https://gitlab.com/gitlab-org/gitaly/issues/476
...
...
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