diff --git a/Gemfile.lock b/Gemfile.lock index 51d590778b34797c5dcb98a0e2425a22e970cb04..a8d86c88ba6b9a0f0c74edf03f289d3ef3a5d501 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -784,6 +784,7 @@ DEPENDENCIES gitlab-linguist (~> 3.0.1) gitlab_emoji (~> 0.1) <<<<<<< HEAD +<<<<<<< HEAD <<<<<<< HEAD gitlab_git (~> 7.2.6) ======= @@ -792,6 +793,9 @@ DEPENDENCIES ======= gitlab_git (~> 7.2.0) >>>>>>> parent of 27a1585... Fix adding new file to empty repo +======= + gitlab_git (~> 7.1.13) +>>>>>>> parent of 734a4ba... Create and edit files in web editor via rugged gitlab_meta (= 7.0) gitlab_omniauth-ldap (= 1.2.1) gollum-lib (~> 4.0.2) diff --git a/app/models/repository.rb b/app/models/repository.rb index 638e278b49ea2ebb2febac4934a29bb9a6f79c3d..0a62980f93a1b528ad39897c94691bd9be70ba5a 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 c0cf59563267daf3e2f0d1897335d428bab9bf4f..23833aa78ec81e14cea22f95933f5064f1aabd32 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 5efd43d16ceb3d5ad141733496282503050fb7c8..0724d3ae6347b1150c0c40f81cb36fbdb7c9dea8 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