mirror of
https://github.com/vim/vim.git
synced 2025-10-06 05:44:14 -04:00
patch 8.2.3843: dep3patch files are not recognized
Problem: Dep3patch files are not recognized. Solution: Recognize dep3patch files by their location and content. (James McCoy, closes #9367)
This commit is contained in:
committed by
Bram Moolenaar
parent
422085f1c8
commit
647ab4cede
17
runtime/autoload/dist/ft.vim
vendored
17
runtime/autoload/dist/ft.vim
vendored
@@ -811,6 +811,23 @@ func dist#ft#Redif()
|
|||||||
endwhile
|
endwhile
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
" This function is called for all files under */debian/patches/*, make sure not
|
||||||
|
" to non-dep3patch files, such as README and other text files.
|
||||||
|
func dist#ft#Dep3patch()
|
||||||
|
if expand('%:t') ==# 'series'
|
||||||
|
return
|
||||||
|
endif
|
||||||
|
|
||||||
|
for ln in getline(1, 100)
|
||||||
|
if ln =~# '^\%(Description\|Subject\|Origin\|Bug\|Forwarded\|Author\|From\|Reviewed-by\|Acked-by\|Last-Updated\|Applied-Upstream\):'
|
||||||
|
setf dep3patch
|
||||||
|
return
|
||||||
|
elseif ln =~# '^---'
|
||||||
|
" end of headers found. stop processing
|
||||||
|
return
|
||||||
|
endif
|
||||||
|
endfor
|
||||||
|
endfunc
|
||||||
|
|
||||||
" Restore 'cpoptions'
|
" Restore 'cpoptions'
|
||||||
let &cpo = s:cpo_save
|
let &cpo = s:cpo_save
|
||||||
|
@@ -490,6 +490,9 @@ au BufNewFile,BufRead dict.conf,.dictrc setf dictconf
|
|||||||
" Dictd config
|
" Dictd config
|
||||||
au BufNewFile,BufRead dictd*.conf setf dictdconf
|
au BufNewFile,BufRead dictd*.conf setf dictdconf
|
||||||
|
|
||||||
|
" DEP3 formatted patch files
|
||||||
|
au BufNewFile,BufRead */debian/patches/* call dist#ft#Dep3patch()
|
||||||
|
|
||||||
" Diff files
|
" Diff files
|
||||||
au BufNewFile,BufRead *.diff,*.rej setf diff
|
au BufNewFile,BufRead *.diff,*.rej setf diff
|
||||||
au BufNewFile,BufRead *.patch
|
au BufNewFile,BufRead *.patch
|
||||||
|
@@ -1029,4 +1029,44 @@ func Test_fs_file()
|
|||||||
filetype off
|
filetype off
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
func Test_dep3patch_file()
|
||||||
|
filetype on
|
||||||
|
|
||||||
|
call assert_true(mkdir('debian/patches', 'p'))
|
||||||
|
|
||||||
|
" series files are not patches
|
||||||
|
call writefile(['Description: some awesome patch'], 'debian/patches/series')
|
||||||
|
split debian/patches/series
|
||||||
|
call assert_notequal('dep3patch', &filetype)
|
||||||
|
bwipe!
|
||||||
|
|
||||||
|
" diff/patch files without the right headers should still show up as ft=diff
|
||||||
|
call writefile([], 'debian/patches/foo.diff')
|
||||||
|
split debian/patches/foo.diff
|
||||||
|
call assert_equal('diff', &filetype)
|
||||||
|
bwipe!
|
||||||
|
|
||||||
|
" Files with the right headers are detected as dep3patch, even if they don't
|
||||||
|
" have a diff/patch extension
|
||||||
|
call writefile(['Subject: dep3patches'], 'debian/patches/bar')
|
||||||
|
split debian/patches/bar
|
||||||
|
call assert_equal('dep3patch', &filetype)
|
||||||
|
bwipe!
|
||||||
|
|
||||||
|
" Files in sub-directories are detected
|
||||||
|
call assert_true(mkdir('debian/patches/s390x', 'p'))
|
||||||
|
call writefile(['Subject: dep3patches'], 'debian/patches/s390x/bar')
|
||||||
|
split debian/patches/s390x/bar
|
||||||
|
call assert_equal('dep3patch', &filetype)
|
||||||
|
bwipe!
|
||||||
|
|
||||||
|
" The detection stops when seeing the "header end" marker
|
||||||
|
call writefile(['---', 'Origin: the cloud'], 'debian/patches/baz')
|
||||||
|
split debian/patches/baz
|
||||||
|
call assert_notequal('dep3patch', &filetype)
|
||||||
|
bwipe!
|
||||||
|
|
||||||
|
call delete('debian/patches', 'rf')
|
||||||
|
endfunc
|
||||||
|
|
||||||
" vim: shiftwidth=2 sts=2 expandtab
|
" vim: shiftwidth=2 sts=2 expandtab
|
||||||
|
@@ -749,6 +749,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
3843,
|
||||||
/**/
|
/**/
|
||||||
3842,
|
3842,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user