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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
gitlab-ce
Commits
143fa8e7
Commit
143fa8e7
authored
Jul 04, 2016
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
09c77952
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
34 additions
and
2 deletions
+34
-2
app/controllers/concerns/creates_commit.rb
app/controllers/concerns/creates_commit.rb
+2
-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 @
143fa8e7
...
...
@@ -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
...
...
app/models/repository.rb
View file @
143fa8e7
...
...
@@ -741,6 +741,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
)
...
...
app/services/files/base_service.rb
View file @
143fa8e7
...
...
@@ -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
...
...
app/services/files/update_service.rb
View file @
143fa8e7
...
...
@@ -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
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