diff --git a/app/services/git/providers/github.rb b/app/services/git/providers/github.rb index 2bf52bf8daeb540eb6c3cab79bef8f5e1eb3a8c3..ecf9169e92d43fcfaff8d6afec219b0fa4f47c26 100644 --- a/app/services/git/providers/github.rb +++ b/app/services/git/providers/github.rb @@ -9,10 +9,12 @@ class Git::Providers::Github < Git::Providers::Abstract end def update_file(path, previous_path, content) - file = tree_item_at_path(previous_path) + # Handle newly created GitFiles which update existing remote files while having blank previous_path. + path_to_check = previous_path.present? ? previous_path : path + file = tree_item_at_path(path_to_check) return if file.nil? batch << { - path: previous_path, + path: path_to_check, mode: file[:mode], type: file[:type], sha: nil diff --git a/app/services/git/providers/gitlab.rb b/app/services/git/providers/gitlab.rb index 73f4c87dd8afa616eb90a437ad1ddded4ac689d6..23cfaa330b31d85c1067efa881b78bc92bd42f76 100644 --- a/app/services/git/providers/gitlab.rb +++ b/app/services/git/providers/gitlab.rb @@ -11,8 +11,7 @@ class Git::Providers::Gitlab < Git::Providers::Abstract def update_file(path, previous_path, content) file = find previous_path - return if file.nil? - if previous_path != path + if file.present? && previous_path != path batch << { action: 'move', file_path: path,