summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2015-06-02 11:41:21 +0200
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2015-06-02 11:41:21 +0200
commit8997812626b85ff0838ec60047d17e0c5f2a5aca (patch)
tree22a7d199ad187919045e05c195304b1687d804e4
parent8ad5f0848361b07d3f50f087da942aea63bc9f33 (diff)
downloadgitlab-ce-8997812626b85ff0838ec60047d17e0c5f2a5aca.tar.gz
Remove files in web editor using rugged
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
-rw-r--r--Gemfile2
-rw-r--r--Gemfile.lock4
-rw-r--r--app/models/repository.rb38
-rw-r--r--app/services/files/delete_service.rb13
4 files changed, 40 insertions, 17 deletions
diff --git a/Gemfile b/Gemfile
index 70f7e5cf41a..78af7f5db69 100644
--- a/Gemfile
+++ b/Gemfile
@@ -45,7 +45,7 @@ gem "browser"
# Extracting information from a git repository
# Provide access to Gitlab::Git library
-gem "gitlab_git", '~> 7.2.1'
+gem "gitlab_git", '~> 7.2.2'
# Ruby/Rack Git Smart-HTTP Server Handler
# GitLab fork with a lot of changes (improved thread-safety, better memory usage etc)
diff --git a/Gemfile.lock b/Gemfile.lock
index ae411a34956..bbc5639c84f 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -225,7 +225,7 @@ GEM
mime-types (~> 1.19)
gitlab_emoji (0.1.0)
gemojione (~> 2.0)
- gitlab_git (7.2.1)
+ gitlab_git (7.2.2)
activesupport (~> 4.0)
charlock_holmes (~> 0.6)
gitlab-linguist (~> 3.0)
@@ -733,7 +733,7 @@ DEPENDENCIES
gitlab-grack (~> 2.0.2)
gitlab-linguist (~> 3.0.1)
gitlab_emoji (~> 0.1)
- gitlab_git (~> 7.2.1)
+ gitlab_git (~> 7.2.2)
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 c5580503281..1ca97017637 100644
--- a/app/models/repository.rb
+++ b/app/models/repository.rb
@@ -373,15 +373,10 @@ class Repository
def commit_file(user, path, content, message, ref)
path[0] = '' if path[0] == '/'
- author = {
- email: user.email,
- name: user.name,
- time: Time.now
- }
-
+ committer = user_to_comitter(user)
options = {}
- options[:committer] = author
- options[:author] = author
+ options[:committer] = committer
+ options[:author] = committer
options[:commit] = {
message: message,
branch: ref
@@ -395,8 +390,35 @@ class Repository
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
+
private
+ def user_to_comitter(user)
+ {
+ email: user.email,
+ name: user.name,
+ time: Time.now
+ }
+ end
+
def cache
@cache ||= RepositoryCache.new(path_with_namespace)
end
diff --git a/app/services/files/delete_service.rb b/app/services/files/delete_service.rb
index 1497a0f883b..fabcdc19648 100644
--- a/app/services/files/delete_service.rb
+++ b/app/services/files/delete_service.rb
@@ -19,14 +19,15 @@ module Files
return error("You can only edit text files")
end
- delete_file_action = Gitlab::Satellite::DeleteFileAction.new(current_user, project, ref, path)
-
- deleted_successfully = delete_file_action.commit!(
- nil,
- params[:commit_message]
+ sha = repository.remove_file(
+ current_user,
+ path,
+ params[:commit_message],
+ ref
)
- if deleted_successfully
+ if sha
+ after_commit(sha)
success
else
error("Your changes could not be committed, because the file has been changed")