forked from sds/overcommit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathresolving_cherry_pick_conflict_spec.rb
52 lines (46 loc) · 1.54 KB
/
resolving_cherry_pick_conflict_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
require 'spec_helper'
describe 'resolving cherry-pick conflicts' do
subject { shell(%w[git commit -m "Resolve conflicts" -i some-file]) }
let(:config) { <<-YML }
PreCommit:
TrailingWhitespace:
enabled: true
YML
around do |example|
repo do
File.open('.overcommit.yml', 'w') { |f| f.write(config) }
`git add .overcommit.yml`
`git commit -m "Add Overcommit config"`
echo('Master', 'some-file')
`git add some-file`
`git commit -m "Add some-file"`
`git checkout -q -b branch1`
echo('Branch 1 Addition', 'some-file')
`git add some-file`
`git commit -m "Add Branch 1 addition"`
`git checkout -q master`
`git checkout -q -b branch2`
echo('Branch 2 Addition', 'some-file')
`git add some-file`
`git commit -m "Add Branch 2 addition"`
`git checkout -q master`
`git cherry-pick branch1 > #{File::NULL} 2>&1`
`overcommit --install > #{File::NULL}`
`git cherry-pick branch2 > #{File::NULL} 2>&1` # Results in cherry-pick conflict
echo('Conflicts Resolved ', 'some-file') # Fail trailing whitespace hook
`git add some-file`
example.run
end
end
it 'exits with a non-zero status' do
subject.status.should_not == 0
end
it 'does not remove the CHERRY_PICK_HEAD file' do
subject
Dir['.git/*'].should include '.git/CHERRY_PICK_HEAD'
end
it 'keeps the commit message from the cherry-picked commit' do
subject
File.read(File.join('.git', 'MERGE_MSG')).should include 'Add Branch 2 addition'
end
end