Commit 66361f4c authored by tiagonbotelho's avatar tiagonbotelho

refactors blob_controller

parent 9a9ecc31
...@@ -52,7 +52,7 @@ gem "browser", '~> 2.2' ...@@ -52,7 +52,7 @@ gem "browser", '~> 2.2'
# Extracting information from a git repository # Extracting information from a git repository
# Provide access to Gitlab::Git library # Provide access to Gitlab::Git library
gem "gitlab_git", '~> 10.2' gem "gitlab_git", '~> 10.2', path: "~/src/Gitlab/gitlab_git"
# LDAP Auth # LDAP Auth
# GitLab fork with several improvements to original library. For full list of changes # GitLab fork with several improvements to original library. For full list of changes
......
PATH
remote: ~/src/Gitlab/gitlab_git
specs:
gitlab_git (10.3.0)
activesupport (~> 4.0)
charlock_holmes (~> 0.7.3)
github-linguist (~> 4.7.0)
rugged (~> 0.24.0)
GEM GEM
remote: https://rubygems.org/ remote: https://rubygems.org/
specs: specs:
...@@ -274,11 +283,16 @@ GEM ...@@ -274,11 +283,16 @@ GEM
diff-lcs (~> 1.1) diff-lcs (~> 1.1)
mime-types (>= 1.16, < 3) mime-types (>= 1.16, < 3)
posix-spawn (~> 0.3) posix-spawn (~> 0.3)
<<<<<<< 9a9ecc313f7963f134247e0815b285b5733e07c7
gitlab_git (10.2.3) gitlab_git (10.2.3)
activesupport (~> 4.0) activesupport (~> 4.0)
charlock_holmes (~> 0.7.3) charlock_holmes (~> 0.7.3)
github-linguist (~> 4.7.0) github-linguist (~> 4.7.0)
rugged (~> 0.24.0) rugged (~> 0.24.0)
=======
gitlab_emoji (0.3.1)
gemojione (~> 2.2, >= 2.2.1)
>>>>>>> refactors blob_controller
gitlab_meta (7.0) gitlab_meta (7.0)
gitlab_omniauth-ldap (1.2.1) gitlab_omniauth-ldap (1.2.1)
net-ldap (~> 0.9) net-ldap (~> 0.9)
...@@ -389,6 +403,7 @@ GEM ...@@ -389,6 +403,7 @@ GEM
mail_room (0.8.0) mail_room (0.8.0)
method_source (0.8.2) method_source (0.8.2)
mime-types (2.99.2) mime-types (2.99.2)
mime-types-data (3.2016.0521)
mimemagic (0.3.0) mimemagic (0.3.0)
mini_portile2 (2.1.0) mini_portile2 (2.1.0)
minitest (5.7.0) minitest (5.7.0)
......
...@@ -12,8 +12,16 @@ module CreatesCommit ...@@ -12,8 +12,16 @@ module CreatesCommit
previous_path: @previous_path previous_path: @previous_path
) )
puts "#" * 10
puts @previous_path
puts "#" * 10
result = service.new(@tree_edit_project, current_user, commit_params).execute result = service.new(@tree_edit_project, current_user, commit_params).execute
puts "#" * 30
puts result[:status]
puts "#" * 30
if result[:status] == :success if result[:status] == :success
update_flash_notice(success_notice) update_flash_notice(success_notice)
......
...@@ -43,7 +43,7 @@ class Projects::BlobController < Projects::ApplicationController ...@@ -43,7 +43,7 @@ class Projects::BlobController < Projects::ApplicationController
diffs_namespace_project_merge_request_path(from_merge_request.target_project.namespace, from_merge_request.target_project, from_merge_request) + diffs_namespace_project_merge_request_path(from_merge_request.target_project.namespace, from_merge_request.target_project, from_merge_request) +
"#file-path-#{hexdigest(@path)}" "#file-path-#{hexdigest(@path)}"
else else
unless params[:file_name] == @path unless params[:file_name].empty?
@previous_path = @path @previous_path = @path
@path = params[:file_name] @path = params[:file_name]
end end
......
...@@ -739,25 +739,22 @@ class Repository ...@@ -739,25 +739,22 @@ class Repository
options[:author] = committer options[:author] = committer
options[:commit] = { options[:commit] = {
message: message, message: message,
branch: ref, branch: ref
} }
if previous_path
options[:file] = {
path: previous_path
}
Gitlab::Git::Blob.remove(raw_repository, options)
end
options[:file] = { options[:file] = {
content: content, content: content,
path: path, path: path,
update: update update: update
} }
Gitlab::Git::Blob.commit(raw_repository, options) if previous_path
options[:file].merge!(previous_path: previous_path)
Gitlab::Git::Blob.rename(raw_repository, options)
else
Gitlab::Git::Blob.commit(raw_repository, options)
end
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment