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
56f69746
Commit
56f69746
authored
Dec 09, 2016
by
Lin Jen-Shin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Introduce git_action and normalize previous_path
Feedback:
https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/7237#note_19747456
parent
e7599eb0
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
46 additions
and
26 deletions
+46
-26
repository.rb
app/models/repository.rb
+46
-26
No files found.
app/models/repository.rb
View file @
56f69746
...
...
@@ -862,32 +862,8 @@ class Repository
[]
end
actions
.
each
do
|
action
|
path
=
Gitlab
::
Git
::
PathHelper
.
normalize_path
(
action
[
:file_path
]).
to_s
raise
Gitlab
::
Git
::
Repository
::
InvalidBlobName
.
new
(
"Invalid path"
)
if
path
.
split
(
'/'
).
include?
(
'..'
)
case
action
[
:action
]
when
:create
,
:update
,
:move
mode
=
case
action
[
:action
]
when
:update
index
.
get
(
path
)[
:mode
]
when
:move
index
.
get
(
action
[
:previous_path
])[
:mode
]
end
mode
||=
0
o100644
index
.
remove
(
action
[
:previous_path
])
if
action
[
:action
]
==
:move
content
=
action
[
:encoding
]
==
'base64'
?
Base64
.
decode64
(
action
[:
content
])
:
action
[
:content
]
oid
=
rugged
.
write
(
content
,
:blob
)
index
.
add
(
path:
path
,
oid:
oid
,
mode:
mode
)
when
:delete
index
.
remove
(
path
)
end
actions
.
each
do
|
act
|
git_action
(
index
,
act
)
end
options
=
{
...
...
@@ -1181,6 +1157,50 @@ class Repository
private
def
git_action
(
index
,
action
)
path
=
normalize_path
(
action
[
:file_path
])
if
action
[
:action
]
==
:move
previous_path
=
normalize_path
(
action
[
:previous_path
])
end
case
action
[
:action
]
when
:create
,
:update
,
:move
mode
=
case
action
[
:action
]
when
:update
index
.
get
(
path
)[
:mode
]
when
:move
index
.
get
(
previous_path
)[
:mode
]
end
mode
||=
0
o100644
index
.
remove
(
previous_path
)
if
action
[
:action
]
==
:move
content
=
if
action
[
:encoding
]
==
'base64'
Base64
.
decode64
(
action
[
:content
])
else
action
[
:content
]
end
oid
=
rugged
.
write
(
content
,
:blob
)
index
.
add
(
path:
path
,
oid:
oid
,
mode:
mode
)
when
:delete
index
.
remove
(
path
)
end
end
def
normalize_path
(
path
)
pathname
=
Gitlab
::
Git
::
PathHelper
.
normalize_path
(
path
)
if
pathname
.
each_filename
.
include?
(
'..'
)
raise
Gitlab
::
Git
::
Repository
::
InvalidBlobName
.
new
(
'Invalid path'
)
end
pathname
.
to_s
end
def
refs_directory_exists?
return
false
unless
path_with_namespace
...
...
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