mirror of
https://github.com/wahyd4/gitlabhq.git
synced 2026-08-09 04:36:11 +10:00
Revert "Create and edit files in web editor via rugged"
This reverts commit 734a4ba87d.
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
This commit is contained in:
committed by
Valery Sizov
parent
aeec708f53
commit
b1958385cd
@@ -364,53 +364,6 @@ class Repository
|
||||
@root_ref ||= raw_repository.root_ref
|
||||
end
|
||||
|
||||
def commit_file(user, path, content, message, ref)
|
||||
path[0] = '' if path[0] == '/'
|
||||
|
||||
committer = user_to_comitter(user)
|
||||
options = {}
|
||||
options[:committer] = committer
|
||||
options[:author] = committer
|
||||
options[:commit] = {
|
||||
message: message,
|
||||
branch: ref
|
||||
}
|
||||
|
||||
options[:file] = {
|
||||
content: content,
|
||||
path: path
|
||||
}
|
||||
|
||||
Gitlab::Git::Blob.commit(raw_repository, options)
|
||||
end
|
||||
|
||||
def remove_file(user, path, message, ref)
|
||||
path[0] = '' if path[0] == '/'
|
||||
|
||||
committer = user_to_comitter(user)
|
||||
options = {}
|
||||
options[:committer] = committer
|
||||
options[:author] = committer
|
||||
options[:commit] = {
|
||||
message: message,
|
||||
branch: ref
|
||||
}
|
||||
|
||||
options[:file] = {
|
||||
path: path
|
||||
}
|
||||
|
||||
Gitlab::Git::Blob.remove(raw_repository, options)
|
||||
end
|
||||
|
||||
def user_to_comitter(user)
|
||||
{
|
||||
email: user.email,
|
||||
name: user.name,
|
||||
time: Time.now
|
||||
}
|
||||
end
|
||||
|
||||
def search_files(query, ref)
|
||||
offset = 2
|
||||
args = %W(git grep -i -n --before-context #{offset} --after-context #{offset} #{query} #{ref || root_ref})
|
||||
|
||||
@@ -33,24 +33,14 @@ module Files
|
||||
end
|
||||
end
|
||||
|
||||
if params[:encoding] == 'base64'
|
||||
new_file_action = Gitlab::Satellite::NewFileAction.new(current_user, project, ref, file_path)
|
||||
created_successfully = new_file_action.commit!(
|
||||
params[:content],
|
||||
params[:commit_message],
|
||||
params[:encoding],
|
||||
params[:new_branch]
|
||||
)
|
||||
else
|
||||
created_successfull = repository.commit_file(
|
||||
current_user,
|
||||
file_path,
|
||||
params[:content],
|
||||
params[:commit_message],
|
||||
params[:new_branch] || ref
|
||||
)
|
||||
end
|
||||
|
||||
new_file_action = Gitlab::Satellite::NewFileAction.new(current_user, project, ref, file_path)
|
||||
created_successfully = new_file_action.commit!(
|
||||
params[:content],
|
||||
params[:commit_message],
|
||||
params[:encoding],
|
||||
params[:new_branch]
|
||||
)
|
||||
|
||||
if created_successfully
|
||||
success
|
||||
|
||||
@@ -19,23 +19,13 @@ module Files
|
||||
return error("You can only edit text files")
|
||||
end
|
||||
|
||||
if params[:encoding] == 'base64'
|
||||
edit_file_action = Gitlab::Satellite::EditFileAction.new(current_user, project, ref, path)
|
||||
edit_file_action.commit!(
|
||||
params[:content],
|
||||
params[:commit_message],
|
||||
params[:encoding],
|
||||
params[:new_branch]
|
||||
)
|
||||
else
|
||||
repository.commit_file(
|
||||
current_user,
|
||||
path,
|
||||
params[:content],
|
||||
params[:commit_message],
|
||||
params[:new_branch] || ref
|
||||
)
|
||||
end
|
||||
edit_file_action = Gitlab::Satellite::EditFileAction.new(current_user, project, ref, path)
|
||||
edit_file_action.commit!(
|
||||
params[:content],
|
||||
params[:commit_message],
|
||||
params[:encoding],
|
||||
params[:new_branch]
|
||||
)
|
||||
|
||||
success
|
||||
rescue Gitlab::Satellite::CheckoutFailed => ex
|
||||
|
||||
Reference in New Issue
Block a user