diff options
author | Nick Thomas <nick@gitlab.com> | 2018-11-27 16:27:51 +0000 |
---|---|---|
committer | Nick Thomas <nick@gitlab.com> | 2018-11-28 11:50:05 +0000 |
commit | 14076062df5d9f369c42796e754b3918965a0623 (patch) | |
tree | 6f3e1a36914178a879002a2872d8e1e114652a1c /app | |
parent | a54352406ae4d85a8c3352b4f6a7dfe669ecd817 (diff) | |
download | gitlab-ce-14076062df5d9f369c42796e754b3918965a0623.tar.gz |
Commits API: Preserve file content in move operations if unspecified
Diffstat (limited to 'app')
-rw-r--r-- | app/services/files/multi_service.rb | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/app/services/files/multi_service.rb b/app/services/files/multi_service.rb index c9d3ee31d82..927634c2159 100644 --- a/app/services/files/multi_service.rb +++ b/app/services/files/multi_service.rb @@ -8,6 +8,7 @@ module Files transformer = Lfs::FileTransformer.new(project, @branch_name) actions = actions_after_lfs_transformation(transformer, params[:actions]) + actions = transform_move_actions(actions) commit_actions!(actions) end @@ -26,6 +27,16 @@ module Files end end + # When moving a file, `content: nil` means "use the contents of the previous + # file", while `content: ''` means "move the file and set it to empty" + def transform_move_actions(actions) + actions.map do |action| + action[:infer_content] = true if action[:content].nil? + + action + end + end + def commit_actions!(actions) repository.multi_action( current_user, |