Commit 89978126 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Remove files in web editor using rugged

Signed-off-by: default avatarDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
parent 8ad5f084
...@@ -45,7 +45,7 @@ gem "browser" ...@@ -45,7 +45,7 @@ gem "browser"
# 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", '~> 7.2.1' gem "gitlab_git", '~> 7.2.2'
# Ruby/Rack Git Smart-HTTP Server Handler # Ruby/Rack Git Smart-HTTP Server Handler
# GitLab fork with a lot of changes (improved thread-safety, better memory usage etc) # GitLab fork with a lot of changes (improved thread-safety, better memory usage etc)
......
...@@ -225,7 +225,7 @@ GEM ...@@ -225,7 +225,7 @@ GEM
mime-types (~> 1.19) mime-types (~> 1.19)
gitlab_emoji (0.1.0) gitlab_emoji (0.1.0)
gemojione (~> 2.0) gemojione (~> 2.0)
gitlab_git (7.2.1) gitlab_git (7.2.2)
activesupport (~> 4.0) activesupport (~> 4.0)
charlock_holmes (~> 0.6) charlock_holmes (~> 0.6)
gitlab-linguist (~> 3.0) gitlab-linguist (~> 3.0)
...@@ -733,7 +733,7 @@ DEPENDENCIES ...@@ -733,7 +733,7 @@ DEPENDENCIES
gitlab-grack (~> 2.0.2) gitlab-grack (~> 2.0.2)
gitlab-linguist (~> 3.0.1) gitlab-linguist (~> 3.0.1)
gitlab_emoji (~> 0.1) gitlab_emoji (~> 0.1)
gitlab_git (~> 7.2.1) gitlab_git (~> 7.2.2)
gitlab_meta (= 7.0) gitlab_meta (= 7.0)
gitlab_omniauth-ldap (= 1.2.1) gitlab_omniauth-ldap (= 1.2.1)
gollum-lib (~> 4.0.2) gollum-lib (~> 4.0.2)
......
...@@ -373,15 +373,10 @@ class Repository ...@@ -373,15 +373,10 @@ class Repository
def commit_file(user, path, content, message, ref) def commit_file(user, path, content, message, ref)
path[0] = '' if path[0] == '/' path[0] = '' if path[0] == '/'
author = { committer = user_to_comitter(user)
email: user.email,
name: user.name,
time: Time.now
}
options = {} options = {}
options[:committer] = author options[:committer] = committer
options[:author] = author options[:author] = committer
options[:commit] = { options[:commit] = {
message: message, message: message,
branch: ref branch: ref
...@@ -395,8 +390,35 @@ class Repository ...@@ -395,8 +390,35 @@ class Repository
Gitlab::Git::Blob.commit(raw_repository, options) Gitlab::Git::Blob.commit(raw_repository, options)
end 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 private
def user_to_comitter(user)
{
email: user.email,
name: user.name,
time: Time.now
}
end
def cache def cache
@cache ||= RepositoryCache.new(path_with_namespace) @cache ||= RepositoryCache.new(path_with_namespace)
end end
......
...@@ -19,14 +19,15 @@ module Files ...@@ -19,14 +19,15 @@ module Files
return error("You can only edit text files") return error("You can only edit text files")
end end
delete_file_action = Gitlab::Satellite::DeleteFileAction.new(current_user, project, ref, path) sha = repository.remove_file(
current_user,
deleted_successfully = delete_file_action.commit!( path,
nil, params[:commit_message],
params[:commit_message] ref
) )
if deleted_successfully if sha
after_commit(sha)
success success
else else
error("Your changes could not be committed, because the file has been changed") error("Your changes could not be committed, because the file has been changed")
......
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