diff options
author | Mark Chao <mchao@gitlab.com> | 2018-11-28 23:10:48 +0800 |
---|---|---|
committer | Mark Chao <mchao@gitlab.com> | 2018-12-07 21:00:47 +0800 |
commit | c6c53d1c7418b2c83410a21bce068a6dfd7858b0 (patch) | |
tree | 72585e4cbc29c639bc809d33f1b12429a8eb69fb /spec/lib | |
parent | 1f7647f446c9659ec0a41e48433a711e95f0b153 (diff) | |
download | gitlab-ce-c6c53d1c7418b2c83410a21bce068a6dfd7858b0.tar.gz |
Fix commit with two parents is set with wrong direct_ancestor
If a commit has two parents, one is direct ancestor, and one is not,
and the order of `commits` is in such fashion that the non-ancestor
side is visited first, the commit would be determined as non-ancestor,
when in fact it can be.
Therefore we should first determine all direct ancestors
prior to analyzing.
Diffstat (limited to 'spec/lib')
-rw-r--r-- | spec/lib/gitlab/branch_push_merge_commit_analyzer_spec.rb | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/spec/lib/gitlab/branch_push_merge_commit_analyzer_spec.rb b/spec/lib/gitlab/branch_push_merge_commit_analyzer_spec.rb index 45e182358df..1e969542975 100644 --- a/spec/lib/gitlab/branch_push_merge_commit_analyzer_spec.rb +++ b/spec/lib/gitlab/branch_push_merge_commit_analyzer_spec.rb @@ -28,6 +28,25 @@ describe Gitlab::BranchPushMergeCommitAnalyzer do end end + context 'when one parent has two children' do + let(:oldrev) { '1adbdefe31288f3bbe4b614853de4908a0b6f792' } + let(:newrev) { '5f82584f0a907f3b30cfce5bb8df371454a90051' } + + let(:expected_merge_commits) do + { + '5f82584f0a907f3b30cfce5bb8df371454a90051' => '5f82584f0a907f3b30cfce5bb8df371454a90051', + '8a994512e8c8f0dfcf22bb16df6e876be7a61036' => '5f82584f0a907f3b30cfce5bb8df371454a90051', + '689600b91aabec706e657e38ea706ece1ee8268f' => '689600b91aabec706e657e38ea706ece1ee8268f' + } + end + + it 'returns correct merge commit SHA for each commit' do + expected_merge_commits.each do |commit, merge_commit| + expect(subject.get_merge_commit(commit)).to eq(merge_commit) + end + end + end + context 'when relevant_commit_ids is provided' do let(:relevant_commit_id) { '8a994512e8c8f0dfcf22bb16df6e876be7a61036' } subject { described_class.new(commits, relevant_commit_ids: [relevant_commit_id]) } |