mirror of
https://github.com/airblade/vim-gitgutter.git
synced 2025-11-11 13:03:45 -05:00
Big refactor.
- Hunk stage/undo/preview no longer saves the buffer.
- Hunk undo no longer makes locations go out of sync.
- Grep can be opted out of (grep output with ansi escapes is number one cause
of issues).
- Replaced g:gitgutter_grep_command with g:gitgutter_grep.
- Always runs git-diff the same way instead of in two possible ways.
- Separated detection of git tracking from diffing.
- Simplified path handling.
- Removed support for xolox shell: Windows taskbar does not flash with async
jobs.
- Removed g:gitgutter_{eager,realtime}.
- Simplified implementation generally.
This commit is contained in:
@@ -64,7 +64,7 @@ endfunction
|
||||
|
||||
function Test_add_lines()
|
||||
normal ggo*
|
||||
write
|
||||
doautocmd CursorHold
|
||||
|
||||
let expected = ["line=2 id=3000 name=GitGutterLineAdded"]
|
||||
call assert_equal(expected, s:signs('fixture.txt'))
|
||||
@@ -76,7 +76,7 @@ function Test_add_lines_fish()
|
||||
set shell=/usr/local/bin/fish
|
||||
|
||||
normal ggo*
|
||||
write
|
||||
doautocmd CursorHold
|
||||
|
||||
let expected = ["line=2 id=3000 name=GitGutterLineAdded"]
|
||||
call assert_equal(expected, s:signs('fixture.txt'))
|
||||
@@ -87,7 +87,7 @@ endfunction
|
||||
|
||||
function Test_modify_lines()
|
||||
normal ggi*
|
||||
write
|
||||
doautocmd CursorHold
|
||||
|
||||
let expected = ["line=1 id=3000 name=GitGutterLineModified"]
|
||||
call assert_equal(expected, s:signs('fixture.txt'))
|
||||
@@ -96,7 +96,7 @@ endfunction
|
||||
|
||||
function Test_remove_lines()
|
||||
execute '5d'
|
||||
write
|
||||
doautocmd CursorHold
|
||||
|
||||
let expected = ["line=4 id=3000 name=GitGutterLineRemoved"]
|
||||
call assert_equal(expected, s:signs('fixture.txt'))
|
||||
@@ -105,7 +105,7 @@ endfunction
|
||||
|
||||
function Test_remove_first_lines()
|
||||
execute '1d'
|
||||
write
|
||||
doautocmd CursorHold
|
||||
|
||||
let expected = ["line=1 id=3000 name=GitGutterLineRemovedFirstLine"]
|
||||
call assert_equal(expected, s:signs('fixture.txt'))
|
||||
@@ -115,7 +115,7 @@ endfunction
|
||||
function Test_edit_file_with_same_name_as_a_branch()
|
||||
normal 5Gi*
|
||||
call system('git checkout -b fixture.txt')
|
||||
write
|
||||
doautocmd CursorHold
|
||||
|
||||
let expected = ["line=5 id=3000 name=GitGutterLineModified"]
|
||||
call assert_equal(expected, s:signs('fixture.txt'))
|
||||
@@ -127,7 +127,7 @@ function Test_file_added_to_git()
|
||||
call system('touch '.tmpfile.' && git add '.tmpfile)
|
||||
execute 'edit '.tmpfile
|
||||
normal ihello
|
||||
write
|
||||
doautocmd CursorHold
|
||||
|
||||
let expected = ["line=1 id=3000 name=GitGutterLineAdded"]
|
||||
call assert_equal(expected, s:signs('fileAddedToGit.tmp'))
|
||||
@@ -138,7 +138,7 @@ function Test_filename_with_equals()
|
||||
call system('touch =fixture=.txt && git add =fixture=.txt')
|
||||
edit =fixture=.txt
|
||||
normal ggo*
|
||||
write
|
||||
doautocmd CursorHold
|
||||
|
||||
let expected = [
|
||||
\ 'line=1 id=3000 name=GitGutterLineAdded',
|
||||
@@ -152,7 +152,7 @@ function Test_filename_with_square_brackets()
|
||||
call system('touch fix[tu]re.txt && git add fix[tu]re.txt')
|
||||
edit fix[tu]re.txt
|
||||
normal ggo*
|
||||
write
|
||||
doautocmd CursorHold
|
||||
|
||||
let expected = [
|
||||
\ 'line=1 id=3000 name=GitGutterLineAdded',
|
||||
@@ -168,7 +168,7 @@ function Test_follow_symlink()
|
||||
call system('ln -nfs fixture.txt '.tmp)
|
||||
execute 'edit '.tmp
|
||||
6d
|
||||
write
|
||||
doautocmd CursorHold
|
||||
|
||||
let expected = ['line=5 id=3000 name=GitGutterLineRemoved']
|
||||
call assert_equal(expected, s:signs('symlink'))
|
||||
@@ -218,26 +218,15 @@ endfunction
|
||||
|
||||
function Test_orphaned_signs()
|
||||
execute "normal 5GoX\<CR>Y"
|
||||
write
|
||||
doautocmd CursorHold
|
||||
6d
|
||||
write
|
||||
doautocmd CursorHold
|
||||
|
||||
let expected = ['line=6 id=3001 name=GitGutterLineAdded']
|
||||
call assert_equal(expected, s:signs('fixture.txt'))
|
||||
endfunction
|
||||
|
||||
|
||||
function Test_sign_column_always()
|
||||
let g:gitgutter_sign_column_always=1
|
||||
write
|
||||
|
||||
let expected = ['line=9999 id=2999 name=GitGutterDummy']
|
||||
call assert_equal(expected, s:signs('fixture.txt'))
|
||||
|
||||
let g:gitgutter_sign_column_always=0
|
||||
endfunction
|
||||
|
||||
|
||||
function Test_untracked_file_outside_repo()
|
||||
let tmp = tempname()
|
||||
call system('touch '.tmp)
|
||||
@@ -301,8 +290,19 @@ function Test_hunk_stage()
|
||||
|
||||
call assert_equal([], s:signs('fixture.txt'))
|
||||
|
||||
call assert_equal([], s:git_diff())
|
||||
" Buffer is unsaved
|
||||
let expected = [
|
||||
\ 'diff --git a/fixture.txt b/fixture.txt',
|
||||
\ 'index ae8e546..f5c6aff 100644',
|
||||
\ '--- a/fixture.txt',
|
||||
\ '+++ b/fixture.txt',
|
||||
\ '@@ -5 +5 @@ d',
|
||||
\ '-*e',
|
||||
\ '+e'
|
||||
\ ]
|
||||
call assert_equal(expected, s:git_diff())
|
||||
|
||||
" Index has been updated
|
||||
let expected = [
|
||||
\ 'diff --git a/fixture.txt b/fixture.txt',
|
||||
\ 'index f5c6aff..ae8e546 100644',
|
||||
@@ -313,6 +313,11 @@ function Test_hunk_stage()
|
||||
\ '+*e'
|
||||
\ ]
|
||||
call assert_equal(expected, s:git_diff_staged())
|
||||
|
||||
" Save the buffer
|
||||
write
|
||||
|
||||
call assert_equal([], s:git_diff())
|
||||
endfunction
|
||||
|
||||
|
||||
@@ -329,6 +334,31 @@ function Test_hunk_stage_nearby_hunk()
|
||||
\ ]
|
||||
call assert_equal(expected, s:signs('fixture.txt'))
|
||||
|
||||
" Buffer is unsaved
|
||||
let expected = [
|
||||
\ 'diff --git a/fixture.txt b/fixture.txt',
|
||||
\ 'index 53b13df..f5c6aff 100644',
|
||||
\ '--- a/fixture.txt',
|
||||
\ '+++ b/fixture.txt',
|
||||
\ '@@ -3,0 +4 @@ c',
|
||||
\ '+d',
|
||||
\ ]
|
||||
call assert_equal(expected, s:git_diff())
|
||||
|
||||
" Index has been updated
|
||||
let expected = [
|
||||
\ 'diff --git a/fixture.txt b/fixture.txt',
|
||||
\ 'index f5c6aff..53b13df 100644',
|
||||
\ '--- a/fixture.txt',
|
||||
\ '+++ b/fixture.txt',
|
||||
\ '@@ -4 +3,0 @@ c',
|
||||
\ '-d',
|
||||
\ ]
|
||||
call assert_equal(expected, s:git_diff_staged())
|
||||
|
||||
" Save the buffer
|
||||
write
|
||||
|
||||
let expected = [
|
||||
\ 'diff --git a/fixture.txt b/fixture.txt',
|
||||
\ 'index 53b13df..8fdfda7 100644',
|
||||
@@ -340,16 +370,6 @@ function Test_hunk_stage_nearby_hunk()
|
||||
\ '+z',
|
||||
\ ]
|
||||
call assert_equal(expected, s:git_diff())
|
||||
|
||||
let expected = [
|
||||
\ 'diff --git a/fixture.txt b/fixture.txt',
|
||||
\ 'index f5c6aff..53b13df 100644',
|
||||
\ '--- a/fixture.txt',
|
||||
\ '+++ b/fixture.txt',
|
||||
\ '@@ -4 +3,0 @@ c',
|
||||
\ '-d',
|
||||
\ ]
|
||||
call assert_equal(expected, s:git_diff_staged())
|
||||
endfunction
|
||||
|
||||
|
||||
@@ -359,7 +379,6 @@ function Test_hunk_undo()
|
||||
|
||||
normal 5Gi*
|
||||
GitGutterUndoHunk
|
||||
write " write file so we can verify git diff (--staged)
|
||||
|
||||
call assert_equal('foo', &shell)
|
||||
let &shell = _shell
|
||||
@@ -374,8 +393,9 @@ function Test_undo_nearby_hunk()
|
||||
execute "normal! 2Gox\<CR>y\<CR>z"
|
||||
normal 2jdd
|
||||
normal k
|
||||
doautocmd CursorHold
|
||||
GitGutterUndoHunk
|
||||
write " write file so we can verify git diff (--staged)
|
||||
doautocmd CursorHold
|
||||
|
||||
let expected = [
|
||||
\ 'line=3 id=3000 name=GitGutterLineAdded',
|
||||
@@ -384,6 +404,13 @@ function Test_undo_nearby_hunk()
|
||||
\ ]
|
||||
call assert_equal(expected, s:signs('fixture.txt'))
|
||||
|
||||
call assert_equal([], s:git_diff())
|
||||
|
||||
call assert_equal([], s:git_diff_staged())
|
||||
|
||||
" Save the buffer
|
||||
write
|
||||
|
||||
let expected = [
|
||||
\ 'diff --git a/fixture.txt b/fixture.txt',
|
||||
\ 'index f5c6aff..3fbde56 100644',
|
||||
@@ -396,5 +423,4 @@ function Test_undo_nearby_hunk()
|
||||
\ ]
|
||||
call assert_equal(expected, s:git_diff())
|
||||
|
||||
call assert_equal([], s:git_diff_staged())
|
||||
endfunction
|
||||
|
||||
Reference in New Issue
Block a user