Commit a51f26e5 authored by Lin Jen-Shin's avatar Lin Jen-Shin

Use commit_file for commit_dir

parent fff3c526
...@@ -749,22 +749,32 @@ class Repository ...@@ -749,22 +749,32 @@ class Repository
user, path, message, branch, user, path, message, branch,
author_email: nil, author_name: nil, author_email: nil, author_name: nil,
source_branch: nil, source_project: project) source_branch: nil, source_project: project)
GitOperationService.new(user, self).with_branch( if branch_exists?(branch)
# tree_entry is private
entry = raw_repository.send(:tree_entry, commit(branch), path)
if entry
if entry[:type] == :blob
raise Gitlab::Git::Repository::InvalidBlobName.new(
"Directory already exists as a file")
else
raise Gitlab::Git::Repository::InvalidBlobName.new(
"Directory already exists")
end
end
end
commit_file(
user,
"#{Gitlab::Git::PathHelper.normalize_path(path)}/.gitkeep",
'',
message,
branch, branch,
false,
author_email: author_email,
author_name: author_name,
source_branch: source_branch, source_branch: source_branch,
source_project: source_project) do |ref| source_project: source_project)
options = {
commit: {
branch: ref,
message: message,
update_ref: false
}
}
options.merge!(get_committer_and_author(user, email: author_email, name: author_name))
raw_repository.mkdir(path, options)
end
end end
# rubocop:enable Metrics/ParameterLists # rubocop:enable Metrics/ParameterLists
......
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