diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2015-08-11 11:52:33 +0200 |
---|---|---|
committer | Valery Sizov <vsv2711@gmail.com> | 2015-08-12 13:51:48 +0300 |
commit | b1958385cd30394c13ec5df300ace41394c82881 (patch) | |
tree | 8fe65a116b86280fddbd0287f26d1daaa2fdb0b6 | |
parent | aeec708f53864f3af12c9669f212ad6737ff4121 (diff) | |
download | gitlab-ce-b1958385cd30394c13ec5df300ace41394c82881.tar.gz |
Revert "Create and edit files in web editor via rugged"
This reverts commit 734a4ba87de7bc8cf152c5bc7f93ba04210b282d.
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
-rw-r--r-- | app/models/repository.rb | 47 | ||||
-rw-r--r-- | app/services/files/create_service.rb | 24 | ||||
-rw-r--r-- | app/services/files/update_service.rb | 24 |
3 files changed, 14 insertions, 81 deletions
diff --git a/app/models/repository.rb b/app/models/repository.rb index dae19b9ddca..1b03cd848ca 100644 --- a/app/models/repository.rb +++ b/app/models/repository.rb @@ -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}) diff --git a/app/services/files/create_service.rb b/app/services/files/create_service.rb index c0cf5956326..23833aa78ec 100644 --- a/app/services/files/create_service.rb +++ b/app/services/files/create_service.rb @@ -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 diff --git a/app/services/files/update_service.rb b/app/services/files/update_service.rb index 5efd43d16ce..0724d3ae634 100644 --- a/app/services/files/update_service.rb +++ b/app/services/files/update_service.rb @@ -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 |