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
2a7806b8
Commit
2a7806b8
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
06608b48
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
35 additions
and
3 deletions
+35
-3
creates_commit.rb
app/controllers/concerns/creates_commit.rb
+2
-1
blob_controller.rb
app/controllers/projects/blob_controller.rb
+1
-1
repository.rb
app/models/repository.rb
+30
-0
base_service.rb
app/services/files/base_service.rb
+1
-0
update_service.rb
app/services/files/update_service.rb
+1
-1
No files found.
app/controllers/concerns/creates_commit.rb
View file @
2a7806b8
...
@@ -8,7 +8,8 @@ module CreatesCommit
...
@@ -8,7 +8,8 @@ module CreatesCommit
source_project:
@project
,
source_project:
@project
,
source_branch:
@ref
,
source_branch:
@ref
,
target_branch:
@target_branch
,
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
result
=
service
.
new
(
@tree_edit_project
,
current_user
,
commit_params
).
execute
...
...
app/controllers/projects/blob_controller.rb
View file @
2a7806b8
...
@@ -44,7 +44,7 @@ class Projects::BlobController < Projects::ApplicationController
...
@@ -44,7 +44,7 @@ class Projects::BlobController < Projects::ApplicationController
"#file-path-
#{
hexdigest
(
@path
)
}
"
"#file-path-
#{
hexdigest
(
@path
)
}
"
else
else
unless
params
[
:file_name
]
==
@path
unless
params
[
:file_name
]
==
@path
previous_path
=
@path
@
previous_path
=
@path
@path
=
params
[
:file_name
]
@path
=
params
[
:file_name
]
end
end
...
...
app/models/repository.rb
View file @
2a7806b8
...
@@ -731,6 +731,36 @@ class Repository
...
@@ -731,6 +731,36 @@ class Repository
end
end
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
)
def
remove_file
(
user
,
path
,
message
,
branch
)
commit_with_hooks
(
user
,
branch
)
do
|
ref
|
commit_with_hooks
(
user
,
branch
)
do
|
ref
|
committer
=
user_to_committer
(
user
)
committer
=
user_to_committer
(
user
)
...
...
app/services/files/base_service.rb
View file @
2a7806b8
...
@@ -9,6 +9,7 @@ module Files
...
@@ -9,6 +9,7 @@ module Files
@commit_message
=
params
[
:commit_message
]
@commit_message
=
params
[
:commit_message
]
@file_path
=
params
[
:file_path
]
@file_path
=
params
[
:file_path
]
@previous_path
=
params
[
:previous_path
]
@file_content
=
if
params
[
:file_content_encoding
]
==
'base64'
@file_content
=
if
params
[
:file_content_encoding
]
==
'base64'
Base64
.
decode64
(
params
[
:file_content
])
Base64
.
decode64
(
params
[
:file_content
])
else
else
...
...
app/services/files/update_service.rb
View file @
2a7806b8
...
@@ -4,7 +4,7 @@ module Files
...
@@ -4,7 +4,7 @@ module Files
class
UpdateService
<
Files
::
BaseService
class
UpdateService
<
Files
::
BaseService
def
commit
def
commit
# Need to update file_path with the new filename
# 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
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