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
26af4b5a
Commit
26af4b5a
authored
Dec 14, 2016
by
Lin Jen-Shin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Also check blob path from source branch
Feedback:
https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/7237#note_19747244
parent
e5acebd9
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
39 additions
and
18 deletions
+39
-18
repository.rb
app/models/repository.rb
+39
-18
No files found.
app/models/repository.rb
View file @
26af4b5a
...
@@ -738,19 +738,11 @@ class Repository
...
@@ -738,19 +738,11 @@ class Repository
message
:,
branch_name
:,
message
:,
branch_name
:,
author_email:
nil
,
author_name:
nil
,
author_email:
nil
,
author_name:
nil
,
source_branch_name:
nil
,
source_project:
project
)
source_branch_name:
nil
,
source_project:
project
)
if
branch_exists?
(
branch_name
)
check_tree_entry_for_dir
(
branch_name
,
path
)
# tree_entry is private
entry
=
raw_repository
.
send
(
:tree_entry
,
commit
(
branch_name
),
path
)
if
source_branch_name
source_project
.
repository
.
if
entry
check_tree_entry_for_dir
(
source_branch_name
,
path
)
if
entry
[
:type
]
==
:blob
raise
Gitlab
::
Git
::
Repository
::
InvalidBlobName
.
new
(
"Directory already exists as a file"
)
else
raise
Gitlab
::
Git
::
Repository
::
InvalidBlobName
.
new
(
"Directory already exists"
)
end
end
end
end
commit_file
(
commit_file
(
...
@@ -773,11 +765,16 @@ class Repository
...
@@ -773,11 +765,16 @@ class Repository
message
:,
branch_name
:,
update:
true
,
message
:,
branch_name
:,
update:
true
,
author_email:
nil
,
author_name:
nil
,
author_email:
nil
,
author_name:
nil
,
source_branch_name:
nil
,
source_project:
project
)
source_branch_name:
nil
,
source_project:
project
)
if
branch_exists?
(
branch_name
)
&&
update
==
false
unless
update
# tree_entry is private
error_message
=
"Filename already exists; update not allowed"
if
raw_repository
.
send
(
:tree_entry
,
commit
(
branch_name
),
path
)
raise
Gitlab
::
Git
::
Repository
::
InvalidBlobName
.
new
(
if
tree_entry_at
(
branch_name
,
path
)
"Filename already exists; update not allowed"
)
raise
Gitlab
::
Git
::
Repository
::
InvalidBlobName
.
new
(
error_message
)
end
if
source_branch_name
&&
source_project
.
repository
.
tree_entry_at
(
source_branch_name
,
path
)
raise
Gitlab
::
Git
::
Repository
::
InvalidBlobName
.
new
(
error_message
)
end
end
end
end
...
@@ -1140,6 +1137,30 @@ class Repository
...
@@ -1140,6 +1137,30 @@ class Repository
end
end
end
end
protected
def
tree_entry_at
(
branch_name
,
path
)
branch_exists?
(
branch_name
)
&&
# tree_entry is private
raw_repository
.
send
(
:tree_entry
,
commit
(
branch_name
),
path
)
end
def
check_tree_entry_for_dir
(
branch_name
,
path
)
return
unless
branch_exists?
(
branch_name
)
entry
=
tree_entry_at
(
branch_name
,
path
)
return
unless
entry
if
entry
[
:type
]
==
:blob
raise
Gitlab
::
Git
::
Repository
::
InvalidBlobName
.
new
(
"Directory already exists as a file"
)
else
raise
Gitlab
::
Git
::
Repository
::
InvalidBlobName
.
new
(
"Directory already exists"
)
end
end
private
private
def
git_action
(
index
,
action
)
def
git_action
(
index
,
action
)
...
...
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