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
fd13056f
Commit
fd13056f
authored
Aug 02, 2016
by
Alejandro Rodríguez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix EE code after gitlab_git update from CE
parent
4465c13b
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
30 additions
and
20 deletions
+30
-20
app/models/repository.rb
app/models/repository.rb
+12
-7
app/services/projects/update_mirror_service.rb
app/services/projects/update_mirror_service.rb
+5
-4
spec/models/repository_spec.rb
spec/models/repository_spec.rb
+3
-3
spec/services/projects/update_mirror_service_spec.rb
spec/services/projects/update_mirror_service_spec.rb
+1
-1
spec/services/projects/update_remote_mirror_service_spec.rb
spec/services/projects/update_remote_mirror_service_spec.rb
+9
-5
No files found.
app/models/repository.rb
View file @
fd13056f
...
...
@@ -241,7 +241,9 @@ class Repository
def
remote_tags
(
remote
)
gitlab_shell
.
list_remote_tags
(
storage_path
,
path_with_namespace
,
remote
).
map
do
|
name
,
target
|
Gitlab
::
Git
::
Tag
.
new
(
name
,
target
)
# Is the tag annotated or lightweight?
object
=
target
.
is_a?
(
Rugged
::
Tag
::
Annotation
)
?
target
:
nil
Gitlab
::
Git
::
Tag
.
new
(
raw_repository
,
object
,
name
,
target
)
end
end
...
...
@@ -768,7 +770,7 @@ class Repository
name
=
ref
.
name
.
sub
(
/\Arefs\/remotes\/
#{
remote_name
}
\//
,
''
)
begin
branches
<<
Gitlab
::
Git
::
Branch
.
new
(
name
,
ref
.
target
)
branches
<<
Gitlab
::
Git
::
Branch
.
new
(
raw_repository
,
name
,
ref
.
target
)
rescue
Rugged
::
ReferenceError
# Omit invalid branch
end
...
...
@@ -890,16 +892,19 @@ class Repository
end
end
def
ff_merge
(
user
,
source
_sha
,
target_branch
,
options
=
{})
def
ff_merge
(
user
,
source
,
target_branch
,
options
=
{})
our_commit
=
rugged
.
branches
[
target_branch
].
target
their_commit
=
rugged
.
lookup
(
source_sha
)
their_commit
=
if
source
.
is_a?
(
Gitlab
::
Git
::
Commit
)
source
.
raw_commit
else
rugged
.
lookup
(
source
)
end
raise
"Invalid merge target"
if
our_commit
.
nil?
raise
"Invalid merge source"
if
their_commit
.
nil?
commit_with_hooks
(
user
,
target_branch
)
do
source_sha
end
commit_with_hooks
(
user
,
target_branch
)
{
their_commit
.
oid
}
end
def
merge
(
user
,
merge_request
,
options
=
{})
...
...
app/services/projects/update_mirror_service.rb
View file @
fd13056f
...
...
@@ -36,7 +36,7 @@ module Projects
local_branch
=
local_branches
[
name
]
if
local_branch
.
nil?
result
=
CreateBranchService
.
new
(
project
,
current_user
).
execute
(
name
,
upstream_branch
.
target
)
result
=
CreateBranchService
.
new
(
project
,
current_user
).
execute
(
name
,
upstream_branch
.
target
.
sha
)
if
result
[
:status
]
==
:error
errors
<<
result
[
:message
]
end
...
...
@@ -73,16 +73,17 @@ module Projects
tags
.
each
do
|
tag
|
old_tag
=
old_tags
[
tag
.
name
]
old_tag_target
=
old_tag
?
old_tag
.
target
:
Gitlab
::
Git
::
BLANK_SHA
tag_target
=
tag
.
target
.
sha
old_tag_target
=
old_tag
?
old_tag
.
target
.
sha
:
Gitlab
::
Git
::
BLANK_SHA
next
if
old_tag_target
==
tag
.
target
next
if
old_tag_target
==
tag
_
target
GitTagPushService
.
new
(
project
,
current_user
,
{
oldrev:
old_tag_target
,
newrev:
tag
.
target
,
newrev:
tag
_
target
,
ref:
"
#{
Gitlab
::
Git
::
TAG_REF_PREFIX
}#{
tag
.
name
}
"
,
mirror_update:
true
}
...
...
spec/models/repository_spec.rb
View file @
fd13056f
...
...
@@ -1291,7 +1291,7 @@ describe Repository, models: true do
describe
'#remote_tags'
do
it
'gets the remote tags'
do
masterrev
=
repository
.
find_branch
(
'master'
).
target
masterrev
=
repository
.
find_branch
(
'master'
).
target
.
id
expect_any_instance_of
(
Gitlab
::
Shell
).
to
receive
(
:list_remote_tags
).
with
(
repository
.
storage_path
,
repository
.
path_with_namespace
,
'upstream'
).
...
...
@@ -1301,7 +1301,7 @@ describe Repository, models: true do
expect
(
tags
.
first
).
to
be_an_instance_of
(
Gitlab
::
Git
::
Tag
)
expect
(
tags
.
first
.
name
).
to
eq
(
'v0.0.1'
)
expect
(
tags
.
first
.
target
).
to
eq
(
masterrev
)
expect
(
tags
.
first
.
target
.
id
).
to
eq
(
masterrev
)
end
end
...
...
@@ -1368,7 +1368,7 @@ describe Repository, models: true do
def
create_remote_branch
(
remote_name
,
branch_name
,
target
)
rugged
=
repository
.
rugged
rugged
.
references
.
create
(
"refs/remotes/
#{
remote_name
}
/
#{
branch_name
}
"
,
target
)
rugged
.
references
.
create
(
"refs/remotes/
#{
remote_name
}
/
#{
branch_name
}
"
,
target
.
id
)
end
end
spec/services/projects/update_mirror_service_spec.rb
View file @
fd13056f
...
...
@@ -93,7 +93,7 @@ describe Projects::UpdateMirrorService do
def
fetch_mirror
(
repository
)
rugged
=
repository
.
rugged
masterrev
=
repository
.
find_branch
(
'master'
).
target
masterrev
=
repository
.
find_branch
(
'master'
).
target
.
id
parentrev
=
repository
.
commit
(
masterrev
).
parent_id
rugged
.
references
.
create
(
'refs/heads/existing-branch'
,
parentrev
)
...
...
spec/services/projects/update_remote_mirror_service_spec.rb
View file @
fd13056f
...
...
@@ -12,6 +12,10 @@ describe Projects::UpdateRemoteMirrorService do
before
do
create_branch
(
repository
,
'existing-branch'
)
allow
(
repository
).
to
receive
(
:remote_tags
)
{
generate_tags
(
repository
,
'v1.0.0'
,
'v1.1.0'
)
}
gitlab_shell
=
Gitlab
::
Shell
.
new
allow
(
repository
).
to
receive
(
:gitlab_shell
).
and_return
(
gitlab_shell
)
allow
(
gitlab_shell
).
to
receive
(
:push_remote_branches
).
and_return
(
true
)
end
it
"fetches the remote repository"
do
...
...
@@ -123,7 +127,7 @@ describe Projects::UpdateRemoteMirrorService do
def
create_branch
(
repository
,
branch_name
)
rugged
=
repository
.
rugged
masterrev
=
repository
.
find_branch
(
'master'
).
target
masterrev
=
repository
.
find_branch
(
'master'
).
target
.
id
parentrev
=
repository
.
commit
(
masterrev
).
parent_id
rugged
.
references
.
create
(
"refs/heads/
#{
branch_name
}
"
,
parentrev
)
...
...
@@ -136,13 +140,13 @@ describe Projects::UpdateRemoteMirrorService do
local_branch_names
.
each
do
|
branch
|
target
=
repository
.
find_branch
(
branch
).
try
(
:target
)
rugged
.
references
.
create
(
"refs/remotes/
#{
remote_name
}
/
#{
branch
}
"
,
target
)
if
target
rugged
.
references
.
create
(
"refs/remotes/
#{
remote_name
}
/
#{
branch
}
"
,
target
.
id
)
if
target
end
end
def
update_branch
(
repository
,
branch
)
rugged
=
repository
.
rugged
masterrev
=
repository
.
find_branch
(
'master'
).
target
masterrev
=
repository
.
find_branch
(
'master'
).
target
.
id
# Updated existing branch
rugged
.
references
.
create
(
"refs/heads/
#{
branch
}
"
,
masterrev
,
force:
true
)
...
...
@@ -158,8 +162,8 @@ describe Projects::UpdateRemoteMirrorService do
def
generate_tags
(
repository
,
*
tag_names
)
tag_names
.
each_with_object
([])
do
|
name
,
tags
|
ta
g_rev
=
repository
.
find_tag
(
name
).
try
(
:targe
t
)
tags
<<
Gitlab
::
Git
::
Tag
.
new
(
name
,
tag_rev
)
ta
rget_commit
=
repository
.
find_tag
(
name
).
try
(
:target
).
try
(
:raw_commi
t
)
tags
<<
Gitlab
::
Git
::
Tag
.
new
(
repository
.
raw_repository
,
target_commit
,
name
,
target_commit
)
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