|
24 | 24 | ] |
25 | 25 | end |
26 | 26 |
|
27 | | - let(:commit_message_file) do |
| 27 | + let(:commit_message_tempfile) do |
28 | 28 | Tempfile.new('commit-message').tap do |file| |
29 | 29 | file.write(commit_msg.join("\n")) |
30 | | - file.fsync |
31 | | - end.path |
| 30 | + file.close |
| 31 | + end |
| 32 | + end |
| 33 | + let(:commit_message_file) { commit_message_tempfile.path } |
| 34 | + |
| 35 | + after do |
| 36 | + commit_message_tempfile.close! |
32 | 37 | end |
33 | 38 |
|
34 | 39 | describe '#commit_message' do |
|
317 | 322 | end |
318 | 323 | end |
319 | 324 |
|
320 | | - # Git cannot track Windows symlinks |
321 | | - unless Overcommit::OS.windows? |
322 | | - context 'when a broken symlink is staged' do |
323 | | - around do |example| |
324 | | - repo do |
325 | | - Overcommit::Utils::FileUtils.symlink('non-existent-file', 'symlink') |
326 | | - `git add symlink` |
327 | | - example.run |
328 | | - end |
| 325 | + context 'when a broken symlink is staged' do |
| 326 | + around do |example| |
| 327 | + repo do |
| 328 | + Overcommit::Utils::FileUtils.symlink('non-existent-file', 'symlink') |
| 329 | + `git add symlink` |
| 330 | + example.run |
329 | 331 | end |
| 332 | + end |
330 | 333 |
|
331 | | - it 'does not attempt to update/restore the modification time of the file' do |
332 | | - File.should_not_receive(:mtime) |
333 | | - File.should_not_receive(:utime) |
334 | | - subject |
335 | | - end |
| 334 | + it 'does not attempt to update/restore the modification time of the file' do |
| 335 | + File.should_not_receive(:mtime) |
| 336 | + File.should_not_receive(:utime) |
| 337 | + subject |
336 | 338 | end |
337 | 339 | end |
338 | 340 | end |
|
657 | 659 | end |
658 | 660 | end |
659 | 661 |
|
660 | | - # Git cannot track Windows symlinks |
661 | | - unless Overcommit::OS.windows? |
662 | | - context 'when changing a symlink to a directory during an amendment' do |
663 | | - around do |example| |
664 | | - repo do |
665 | | - `git commit --allow-empty -m "Initial commit"` |
666 | | - FileUtils.mkdir 'some-directory' |
667 | | - symlink('some-directory', 'some-symlink') |
668 | | - `git add some-symlink some-directory` |
669 | | - `git commit -m "Add file"` |
670 | | - `git rm some-symlink` |
671 | | - FileUtils.mkdir 'some-symlink' |
672 | | - touch File.join('some-symlink', 'another-file') |
673 | | - `git add some-symlink` |
674 | | - example.run |
675 | | - end |
| 662 | + context 'when changing a symlink to a directory during an amendment' do |
| 663 | + around do |example| |
| 664 | + repo do |
| 665 | + `git commit --allow-empty -m "Initial commit"` |
| 666 | + FileUtils.mkdir 'some-directory' |
| 667 | + symlink('some-directory', 'some-symlink') |
| 668 | + `git add some-symlink some-directory` |
| 669 | + `git commit -m "Add file"` |
| 670 | + `git rm some-symlink` |
| 671 | + FileUtils.mkdir 'some-symlink' |
| 672 | + touch File.join('some-symlink', 'another-file') |
| 673 | + `git add some-symlink` |
| 674 | + example.run |
676 | 675 | end |
| 676 | + end |
677 | 677 |
|
678 | | - before do |
679 | | - context.stub(:amendment?).and_return(true) |
680 | | - end |
| 678 | + before do |
| 679 | + context.stub(:amendment?).and_return(true) |
| 680 | + end |
681 | 681 |
|
682 | | - it 'does not include the directory in the list of modified files' do |
683 | | - subject.should_not include File.expand_path('some-symlink') |
684 | | - end |
| 682 | + it 'does not include the directory in the list of modified files' do |
| 683 | + subject.should_not include File.expand_path('some-symlink') |
685 | 684 | end |
| 685 | + end |
686 | 686 |
|
687 | | - context 'when breaking a symlink during an amendment' do |
688 | | - around do |example| |
689 | | - repo do |
690 | | - `git commit --allow-empty -m "Initial commit"` |
691 | | - FileUtils.mkdir 'some-directory' |
692 | | - touch File.join('some-directory', 'some-file') |
693 | | - symlink('some-directory', 'some-symlink') |
694 | | - `git add some-symlink some-directory` |
695 | | - `git commit -m "Add file"` |
696 | | - `git rm -rf some-directory` |
697 | | - example.run |
698 | | - end |
| 687 | + context 'when breaking a symlink during an amendment' do |
| 688 | + around do |example| |
| 689 | + repo do |
| 690 | + `git commit --allow-empty -m "Initial commit"` |
| 691 | + FileUtils.mkdir 'some-directory' |
| 692 | + touch File.join('some-directory', 'some-file') |
| 693 | + symlink('some-directory', 'some-symlink') |
| 694 | + `git add some-symlink some-directory` |
| 695 | + `git commit -m "Add file"` |
| 696 | + `git rm -rf some-directory` |
| 697 | + example.run |
699 | 698 | end |
| 699 | + end |
700 | 700 |
|
701 | | - before do |
702 | | - context.stub(:amendment?).and_return(true) |
703 | | - end |
| 701 | + before do |
| 702 | + context.stub(:amendment?).and_return(true) |
| 703 | + end |
704 | 704 |
|
705 | | - it 'still includes the broken symlink in the list of modified files' do |
706 | | - subject.should include File.expand_path('some-symlink') |
707 | | - end |
| 705 | + it 'still includes the broken symlink in the list of modified files' do |
| 706 | + subject.should include File.expand_path('some-symlink') |
708 | 707 | end |
709 | 708 | end |
710 | 709 | end |
|
0 commit comments