Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWill Chandler <wchandler@gitlab.com>2020-01-06 11:43:15 +0300
committerPavlo Strokov <pstrokov@gitlab.com>2020-01-06 11:43:15 +0300
commit6adbbf462bf23007962fb0438822370688839910 (patch)
treea056227cbde21d3d4dad853d503a0629f3630412
parentfd5ac7e15e34c73f2800dd6b3520ffd3a603af7f (diff)
Fix order of branches in git diff when preparing sparse checkout rebase
-rw-r--r--changelogs/unreleased/wc-rebase-diff-reorder.yml5
-rw-r--r--ruby/lib/gitlab/git/repository.rb2
-rw-r--r--ruby/spec/lib/gitlab/git/repository_spec.rb36
3 files changed, 42 insertions, 1 deletions
diff --git a/changelogs/unreleased/wc-rebase-diff-reorder.yml b/changelogs/unreleased/wc-rebase-diff-reorder.yml
new file mode 100644
index 000000000..da6fbdd31
--- /dev/null
+++ b/changelogs/unreleased/wc-rebase-diff-reorder.yml
@@ -0,0 +1,5 @@
+---
+title: Fix order of branches in git diff when preparing sparse checkout rebase
+merge_request: 1716
+author:
+type: other
diff --git a/ruby/lib/gitlab/git/repository.rb b/ruby/lib/gitlab/git/repository.rb
index 73feb2e74..c3d3ab3a2 100644
--- a/ruby/lib/gitlab/git/repository.rb
+++ b/ruby/lib/gitlab/git/repository.rb
@@ -358,7 +358,7 @@ module Gitlab
remote_repo_path = remote_repository.path
end
- diff_range = "#{branch}...#{remote_branch}"
+ diff_range = "#{remote_branch}...#{branch}"
diff_files = begin
run_git!(
%W[diff --name-only #{diff_range}]
diff --git a/ruby/spec/lib/gitlab/git/repository_spec.rb b/ruby/spec/lib/gitlab/git/repository_spec.rb
index 1b5828877..417f60501 100644
--- a/ruby/spec/lib/gitlab/git/repository_spec.rb
+++ b/ruby/spec/lib/gitlab/git/repository_spec.rb
@@ -608,6 +608,42 @@ describe Gitlab::Git::Repository do # rubocop:disable Metrics/BlockLength
end
end
+ describe '#rebase' do
+ let(:repository) { mutable_repository }
+ let(:rebase_id) { '2' }
+ let(:branch_name) { 'rd-add-file-larger-than-1-mb' }
+ let(:branch_sha) { 'c54ad072fabee9f7bf9b2c6c67089db97ebfbecd' }
+ let(:remote_branch) { 'master' }
+
+ subject do
+ opts = {
+ branch: branch_name,
+ branch_sha: branch_sha,
+ remote_repository: repository,
+ remote_branch: remote_branch
+ }
+
+ repository.rebase(user, rebase_id, opts)
+ end
+
+ describe 'sparse checkout' do
+ let(:expected_files) { %w[files/images/emoji.png] }
+
+ it 'lists files modified in source branch in sparse-checkout' do
+ allow(repository).to receive(:with_worktree).and_wrap_original do |m, *args|
+ m.call(*args) do
+ sparse = repository.path + "/worktrees/rebase-#{rebase_id}/info/sparse-checkout"
+ diff_files = IO.readlines(sparse, chomp: true)
+
+ expect(diff_files).to eq(expected_files)
+ end
+ end
+
+ subject
+ end
+ end
+ end
+
describe '#squash' do
let(:repository) { mutable_repository }
let(:squash_id) { '1' }