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
82904349
Commit
82904349
authored
May 19, 2018
by
GitLab Bot
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'upstream/master' into ce-to-ee-2018-05-19
parents
9af1d758
ad9e0091
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
21 additions
and
12 deletions
+21
-12
changelogs/unreleased/xeodon-gitlab-ce-fix-45743-master-fix-gitaly-delete-refs.yml
...don-gitlab-ce-fix-45743-master-fix-gitaly-delete-refs.yml
+5
-0
lib/gitlab/git/blob.rb
lib/gitlab/git/blob.rb
+10
-10
lib/gitlab/git/path_helper.rb
lib/gitlab/git/path_helper.rb
+1
-1
lib/gitlab/git/repository.rb
lib/gitlab/git/repository.rb
+1
-1
spec/lib/gitlab/git/repository_spec.rb
spec/lib/gitlab/git/repository_spec.rb
+4
-0
No files found.
changelogs/unreleased/xeodon-gitlab-ce-fix-45743-master-fix-gitaly-delete-refs.yml
0 → 100644
View file @
82904349
---
title
:
Fix error when deleting an empty list of refs
merge_request
:
author
:
type
:
fixed
lib/gitlab/git/blob.rb
View file @
82904349
...
...
@@ -104,25 +104,22 @@ module Gitlab
# file.rb # oid: 4a
#
#
# Blob.find_entry_by_path(repo, '1a', '
app/
file.rb') # => '4a'
# Blob.find_entry_by_path(repo, '1a', '
blog', 'app', '
file.rb') # => '4a'
#
def
find_entry_by_path
(
repository
,
root_id
,
path
)
def
find_entry_by_path
(
repository
,
root_id
,
*
path_parts
)
root_tree
=
repository
.
lookup
(
root_id
)
# Strip leading slashes
path
[
%r{^/*}
]
=
''
path_arr
=
path
.
split
(
'/'
)
entry
=
root_tree
.
find
do
|
entry
|
entry
[
:name
]
==
path_
arr
[
0
]
entry
[
:name
]
==
path_
parts
[
0
]
end
return
nil
unless
entry
if
path_
arr
.
size
>
1
if
path_
parts
.
size
>
1
return
nil
unless
entry
[
:type
]
==
:tree
path_
arr
.
shift
find_entry_by_path
(
repository
,
entry
[
:oid
],
path_arr
.
join
(
'/'
)
)
path_
parts
.
shift
find_entry_by_path
(
repository
,
entry
[
:oid
],
*
path_parts
)
else
[
:blob
,
:commit
].
include?
(
entry
[
:type
])
?
entry
:
nil
end
...
...
@@ -185,10 +182,13 @@ module Gitlab
def
find_by_rugged
(
repository
,
sha
,
path
,
limit
:)
return
unless
path
# Strip any leading / characters from the path
path
=
path
.
sub
(
%r{
\A
/*}
,
''
)
rugged_commit
=
repository
.
lookup
(
sha
)
root_tree
=
rugged_commit
.
tree
blob_entry
=
find_entry_by_path
(
repository
,
root_tree
.
oid
,
path
)
blob_entry
=
find_entry_by_path
(
repository
,
root_tree
.
oid
,
*
path
.
split
(
'/'
)
)
return
nil
unless
blob_entry
...
...
lib/gitlab/git/path_helper.rb
View file @
82904349
...
...
@@ -6,7 +6,7 @@ module Gitlab
class
<<
self
def
normalize_path
(
filename
)
# Strip all leading slashes so that //foo -> foo
filename
[
%r{^/*}
]
=
''
filename
=
filename
.
sub
(
%r{
\A
/*}
,
''
)
# Expand relative paths (e.g. foo/../bar)
filename
=
Pathname
.
new
(
filename
)
...
...
lib/gitlab/git/repository.rb
View file @
82904349
...
...
@@ -2381,7 +2381,7 @@ module Gitlab
end
def
gitaly_delete_refs
(
*
ref_names
)
gitaly_ref_client
.
delete_refs
(
refs:
ref_names
)
gitaly_ref_client
.
delete_refs
(
refs:
ref_names
)
if
ref_names
.
any?
end
def
rugged_remove_remote
(
remote_name
)
...
...
spec/lib/gitlab/git/repository_spec.rb
View file @
82904349
...
...
@@ -600,6 +600,10 @@ describe Gitlab::Git::Repository, seed_helper: true do
end
end
it
'does not fail when deleting an empty list of refs'
do
expect
{
repo
.
delete_refs
(
*
[])
}.
not_to
raise_error
end
it
'raises an error if it failed'
do
expect
{
repo
.
delete_refs
(
'refs\heads\fix'
)
}.
to
raise_error
(
Gitlab
::
Git
::
Repository
::
GitError
)
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