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
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gitlab-ce
Commits
99518546
Commit
99518546
authored
8 years ago
by
tiagonbotelho
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
creates the update_file method in repository.rb and applies changes accordingly
parent
385afc28
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
35 additions
and
3 deletions
+35
-3
app/controllers/concerns/creates_commit.rb
app/controllers/concerns/creates_commit.rb
+2
-1
app/controllers/projects/blob_controller.rb
app/controllers/projects/blob_controller.rb
+1
-1
app/models/repository.rb
app/models/repository.rb
+30
-0
app/services/files/base_service.rb
app/services/files/base_service.rb
+1
-0
app/services/files/update_service.rb
app/services/files/update_service.rb
+1
-1
No files found.
app/controllers/concerns/creates_commit.rb
View file @
99518546
...
...
@@ -8,7 +8,8 @@ module CreatesCommit
source_project:
@project
,
source_branch:
@ref
,
target_branch:
@target_branch
,
file_path:
@path
file_path:
@path
,
previous_path:
@previous_path
)
result
=
service
.
new
(
@tree_edit_project
,
current_user
,
commit_params
).
execute
...
...
This diff is collapsed.
Click to expand it.
app/controllers/projects/blob_controller.rb
View file @
99518546
...
...
@@ -44,7 +44,7 @@ class Projects::BlobController < Projects::ApplicationController
"#file-path-
#{
hexdigest
(
@path
)
}
"
else
unless
params
[
:file_name
]
==
@path
previous_path
=
@path
@
previous_path
=
@path
@path
=
params
[
:file_name
]
end
namespace_project_blob_path
(
@project
.
namespace
,
@project
,
File
.
join
(
@target_branch
,
@path
))
...
...
This diff is collapsed.
Click to expand it.
app/models/repository.rb
View file @
99518546
...
...
@@ -731,6 +731,36 @@ class Repository
end
end
def
update_file
(
user
,
path
,
previous_path
,
content
,
message
,
branch
,
update
)
commit_with_hooks
(
user
,
branch
)
do
|
ref
|
committer
=
user_to_committer
(
user
)
options
=
{}
options
[
:committer
]
=
committer
options
[
:author
]
=
committer
options
[
:commit
]
=
{
message:
message
,
branch:
ref
,
}
if
previous_path
options
[
:file
]
=
{
path:
previous_path
}
Gitlab
::
Git
::
Blob
.
remove
(
raw_repository
,
options
)
end
options
[
:file
]
=
{
content:
content
,
path:
path
,
update:
update
}
Gitlab
::
Git
::
Blob
.
commit
(
raw_repository
,
options
)
end
end
def
remove_file
(
user
,
path
,
message
,
branch
)
commit_with_hooks
(
user
,
branch
)
do
|
ref
|
committer
=
user_to_committer
(
user
)
...
...
This diff is collapsed.
Click to expand it.
app/services/files/base_service.rb
View file @
99518546
...
...
@@ -9,6 +9,7 @@ module Files
@commit_message
=
params
[
:commit_message
]
@file_path
=
params
[
:file_path
]
@previous_path
=
params
[
:previous_path
]
@file_content
=
if
params
[
:file_content_encoding
]
==
'base64'
Base64
.
decode64
(
params
[
:file_content
])
else
...
...
This diff is collapsed.
Click to expand it.
app/services/files/update_service.rb
View file @
99518546
...
...
@@ -4,7 +4,7 @@ module Files
class
UpdateService
<
Files
::
BaseService
def
commit
# Need to update file_path with the new filename
repository
.
commit_file
(
current_user
,
@file
_path
,
@file_content
,
@commit_message
,
@target_branch
,
true
)
repository
.
update_file
(
current_user
,
@file_path
,
@previous
_path
,
@file_content
,
@commit_message
,
@target_branch
,
true
)
end
end
end
This diff is collapsed.
Click to expand it.
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