Merge ~sbeattie/ubuntu-cve-tracker/+git/ubuntu-cve-tracker:cve.vim-more_improvments into ubuntu-cve-tracker:master

Proposed by Steve Beattie
Status: Merged
Merged at revision: 7431f5be943d4bd1216afc865d0309a2ab8fa3e4
Proposed branch: ~sbeattie/ubuntu-cve-tracker/+git/ubuntu-cve-tracker:cve.vim-more_improvments
Merge into: ubuntu-cve-tracker:master
Diff against target: 52 lines (+28/-5)
1 file modified
scripts/cve.vim (+28/-5)
Reviewer Review Type Date Requested Status
Paulo Flabiano Smorigo Approve
Review via email: mp+461996@code.launchpad.net

Description of the change

Paulo recently enhanced the cve.vim file to support using shortcuts to change priority and status; this couple of commits enhances that by:

1) allowing the mappings to applied to multiple visually selected lines
2) adding the ability to prompt a user for a reason for the status (i.e. the stuff that goes inside the parentheses), and make use of it for a not-affected mapping.

To post a comment you must log in.
Revision history for this message
Paulo Flabiano Smorigo (pfsmorigo) wrote :

LGTM

review: Approve
Revision history for this message
Steve Beattie (sbeattie) wrote :

On Fri, Mar 08, 2024 at 06:35:52PM -0000, Paulo Flabiano Smorigo wrote:
> Review: Approve
>
> LGTM
>
> Diff comments:
>
> > +nnoremap <silent> <leader>3 :NotAffectedCodeNotPresent<CR>
> > +vnoremap <silent> <leader>4 :<c-u>NotAffectedCodeNotPresent<CR>
>
> s/4/3/ for NotAffectedCodeNotPresent

Nice catch, I've fixed that and force-pushed the branch for the MR, I
can merge to master in a bit.

--
Steve Beattie
<email address hidden>

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/scripts/cve.vim b/scripts/cve.vim
2index 7ab42cb..b15687d 100644
3--- a/scripts/cve.vim
4+++ b/scripts/cve.vim
5@@ -97,8 +97,25 @@ command! -bar Negligible call cve#set_priority("negligible")
6
7 " Replace status for current line (maybe add support for selected lines)
8 function! cve#set_status(status)
9- s/: .*$/\=': ' . a:status/
10+ if visualmode(1)==# 'V'
11+ '<,'>s/: .*$/\=': ' . a:status/
12+ else
13+ s/: .*$/\=': ' . a:status/
14+ endif
15 endfunction
16+
17+function! cve#set_status_reason(status, reason)
18+ call cve#set_status(a:status . ' (' . a:reason . ')')
19+endfunction
20+
21+" function to set cve status and prompt for the explanation of the status
22+function! cve#set_status_reason_prompt(status, prompt)
23+ call inputsave()
24+ let reason = input(a:prompt . ": ")
25+ call inputrestore()
26+ call cve#set_status_reason(a:status, reason)
27+endfunction
28+
29 command! -bar DNE call cve#set_status("DNE")
30 command! -bar Ignored call cve#set_status("ignored")
31 command! -bar IgnoredEndStandardSupport call cve#set_status("ignored (end of standard support)")
32@@ -106,10 +123,16 @@ command! -bar IgnoredEndOfLife call cve#set_status("ignored (end of life)")
33 command! -bar Needed call cve#set_status("needed")
34 command! -bar NeedsTriage call cve#set_status("needs-triage")
35 command! -bar NotAffected call cve#set_status("not-affected")
36-command! -bar NotAffectedCodeNotPresent call cve#set_status("not-affected (code not present)")
37-:map <leader>1 :Needed<CR>
38-:map <leader>2 :NotAffected<CR>
39-:map <leader>3 :NotAffectedCodeNotPresent<CR>
40+command! -bar NotAffectedCodeNotPresent call cve#set_status_reason("not-affected", "code not present")
41+command! -bar NotAffectedReason call cve#set_status_reason_prompt("not-affected", "Enter reason for not-affected")
42+nnoremap <silent> <leader>1 :Needed<CR>
43+vnoremap <silent> <leader>1 :<c-u>Needed<CR>
44+nnoremap <silent> <leader>2 :NotAffected<CR>
45+vnoremap <silent> <leader>2 :<c-u>NotAffected<CR>
46+nnoremap <silent> <leader>3 :NotAffectedCodeNotPresent<CR>
47+vnoremap <silent> <leader>3 :<c-u>NotAffectedCodeNotPresent<CR>
48+nnoremap <silent> <leader>4 :NotAffectedReason<CR>
49+vnoremap <silent> <leader>4 :<c-u>NotAffectedReason<CR>
50
51 let b:current_syntax = "cve"
52 " vim: ts=8 sw=2

Subscribers

People subscribed via source and target branches